[FFmpeg-devel] [PATCH v5 0/9] avformat: wav-s337m support + new probe_stream option

2020-11-09 Thread Nicolas Gaullier
>Updates:
>* patch 1 : commit msg amended (anton)
>* patch 3 : 'if' line split (tomas)
>
>Everthing else: unchanged since v4
>
>For remembering: the test sample 512.wav can be downloaded here:
>https://0x0.st/zdW-.wav
>
>Nicolas Gaullier (9):
>  avcodec/dolby_e: set constant frame_size
>  avformat/s337m: Split read_packet/get_packet
>  avformat/s337m: Consider container bit resolution
>  avformat/s337m: New ff_s337m_probe()
>  avformat/wavdec: s337m support
>  avformat/wavdec.c: Reindent after last commit
>  avformat/wavdec: fix s337m/spdif probing beyond data_end
>  avformat/wavdec: Test s337m
>  avformat: Add probe_stream option
>
> doc/formats.texi|  3 ++
> libavcodec/dolby_e.c|  1 +
> libavformat/avformat.h  |  9 -
> libavformat/options_table.h |  1 +
> libavformat/s337m.c | 73 -
> libavformat/s337m.h | 54 +++
> libavformat/utils.c |  2 +
> libavformat/version.h   |  2 +-
> libavformat/wavdec.c| 53 ++-
> tests/Makefile  |  1 +
> tests/fate/audio.mak|  3 ++
> tests/ref/fate/s337m-wav| 11 ++
> 12 files changed, 185 insertions(+), 28 deletions(-)  create mode 100644 
> libavformat/s337m.h  create mode 100644 tests/ref/fate/s337m-wav

I think I have not received any feedback for this v5 posted 3 weeks ago. I can 
rebase everything if it can help for reviewing (or applying if you think it is 
close to be accepted).
NB: I keep an eye on irc (ngaullier).

Thx
Nicolas
___
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 v5 0/9] avformat: wav-s337m support + new probe_stream option

2020-11-09 Thread Nicolas George
Nicolas Gaullier (12020-11-09):
> > doc/formats.texi|  3 ++
> > libavcodec/dolby_e.c|  1 +
> > libavformat/avformat.h  |  9 -
> > libavformat/options_table.h |  1 +
> > libavformat/s337m.c | 73 -
> > libavformat/s337m.h | 54 +++
> > libavformat/utils.c |  2 +
> > libavformat/version.h   |  2 +-
> > libavformat/wavdec.c| 53 ++-
> > tests/Makefile  |  1 +
> > tests/fate/audio.mak|  3 ++
> > tests/ref/fate/s337m-wav| 11 ++
> > 12 files changed, 185 insertions(+), 28 deletions(-)  create mode 100644 
> > libavformat/s337m.h  create mode 100644 tests/ref/fate/s337m-wav
> 
> I think I have not received any feedback for this v5 posted 3 weeks
> ago. I can rebase everything if it can help for reviewing (or applying
> if you think it is close to be accepted).

A patch that mixes so many different changes has little chances to be
accepted as is. You need to separate changes by function. It would also
increase the chances of review.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v5 0/9] avformat: wav-s337m support + new probe_stream option

2020-11-09 Thread Nicolas Gaullier
>Nicolas Gaullier (12020-11-09):
>> > doc/formats.texi|  3 ++
>> > libavcodec/dolby_e.c|  1 +
>> > libavformat/avformat.h  |  9 -
>> > libavformat/options_table.h |  1 +
>> > libavformat/s337m.c | 73 -
>> > libavformat/s337m.h | 54 +++
>> > libavformat/utils.c |  2 +
>> > libavformat/version.h   |  2 +-
>> > libavformat/wavdec.c| 53 ++-
>> > tests/Makefile  |  1 +
>> > tests/fate/audio.mak|  3 ++
>> > tests/ref/fate/s337m-wav| 11 ++
>> > 12 files changed, 185 insertions(+), 28 deletions(-)  create mode
>> > 100644 libavformat/s337m.h  create mode 100644 
>> > tests/ref/fate/s337m-wav
>> 
>> I think I have not received any feedback for this v5 posted 3 weeks 
>> ago. I can rebase everything if it can help for reviewing (or 
>> applying if you think it is close to be accepted).
>
>A patch that mixes so many different changes has little chances to be accepted 
>as is. You need to separate changes by function. It would also increase the 
>chances of review.
>
>Regards,

Thank you for your response.
I fully understand that but the fact is, everything is bind :
- the first patch has not much interest alone, but yes, this one can be 
separated and it has already been discussed with Anton and approved on irc 
(10/06)
- patch 2 -> 8 are about one single thing : s337m support in wav; I could 
potentially remove patch 7 which affects spdif, but it has already been 
reviewed and seems no problem at all
- patch 9 : this is the tricky one as it is the most recent update in this 
patch set and has received few feedbacks

The fact is, as I explained earlier, patch 9 cannot be separated, because users 
must have the choice to disable dolby_e probing, this is a hard requirement.
I thought patchs 1->8 were ready - this thread began a long long time ago, I 
received many reviews ! - and patch 9 could be reviewed "alone".
That would be the best "git history", and I was not afraid by time but...
At the end, I understand your point, for sure.
I will wait another week and if the process is still frozen, I will rework 
everything : I will propose the patch 9 "Add AVOption" alone (ie. not including 
dolby_e), and wait for its approval before going on with the dolby_e serie.

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

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

Re: [FFmpeg-devel] [PATCH] avfilter/af_asoftclip: add oversampling support

2020-11-09 Thread Paul B Mahol
Will apply soon.

On Thu, Nov 5, 2020 at 1:36 PM Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  configure  |   1 +
>  doc/filters.texi   |   3 ++
>  libavfilter/af_asoftclip.c | 106 ++---
>  3 files changed, 103 insertions(+), 7 deletions(-)
>
> diff --git a/configure b/configure
> index 8a9e9b3cd7..2f02d7f5c8 100755
> --- a/configure
> +++ b/configure
> @@ -3501,6 +3501,7 @@ afir_filter_deps="avcodec"
>  afir_filter_select="rdft"
>  amovie_filter_deps="avcodec avformat"
>  aresample_filter_deps="swresample"
> +asoftclip_filter_deps="swresample"
>  asr_filter_deps="pocketsphinx"
>  ass_filter_deps="libass"
>  atempo_filter_deps="avcodec"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 40f8f614fe..8380f6cac2 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -2356,6 +2356,9 @@ It accepts the following values:
>
>  @item param
>  Set additional parameter which controls sigmoid function.
> +
> +@item oversample
> +Set oversampling factor.
>  @end table
>
>  @subsection Commands
> diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c
> index ce1f7ea96a..aaae3c6d4b 100644
> --- a/libavfilter/af_asoftclip.c
> +++ b/libavfilter/af_asoftclip.c
> @@ -21,6 +21,7 @@
>  #include "libavutil/avassert.h"
>  #include "libavutil/channel_layout.h"
>  #include "libavutil/opt.h"
> +#include "libswresample/swresample.h"
>  #include "avfilter.h"
>  #include "audio.h"
>  #include "formats.h"
> @@ -42,14 +43,22 @@ typedef struct ASoftClipContext {
>  const AVClass *class;
>
>  int type;
> +int oversample;
> +int64_t delay;
>  double param;
>
> +SwrContext *up_ctx;
> +SwrContext *down_ctx;
> +
> +AVFrame *frame;
> +
>  void (*filter)(struct ASoftClipContext *s, void **dst, const void
> **src,
> int nb_samples, int channels, int start, int end);
>  } ASoftClipContext;
>
>  #define OFFSET(x) offsetof(ASoftClipContext, x)
>  #define A
> AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
> +#define F AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>
>  static const AVOption asoftclip_options[] = {
>  { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT,
> {.i64=0}, -1, NB_TYPES-1, A, "types" },
> @@ -63,6 +72,7 @@ static const AVOption asoftclip_options[] = {
>  { "sin", NULL,0, AV_OPT_TYPE_CONST,
> {.i64=ASC_SIN},0,  0, A, "types" },
>  { "erf", NULL,0, AV_OPT_TYPE_CONST,
> {.i64=ASC_ERF},0,  0, A, "types" },
>  { "param", "set softclip parameter", OFFSET(param),
> AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.01,3, A },
> +{ "oversample", "set oversample factor", OFFSET(oversample),
> AV_OPT_TYPE_INT, {.i64=1}, 1, 32, F },
>  { NULL }
>  };
>
> @@ -242,6 +252,7 @@ static int config_input(AVFilterLink *inlink)
>  {
>  AVFilterContext *ctx = inlink->dst;
>  ASoftClipContext *s = ctx->priv;
> +int ret;
>
>  switch (inlink->format) {
>  case AV_SAMPLE_FMT_FLT:
> @@ -251,6 +262,38 @@ static int config_input(AVFilterLink *inlink)
>  default: av_assert0(0);
>  }
>
> +if (s->oversample <= 1)
> +return 0;
> +
> +s->up_ctx = swr_alloc();
> +s->down_ctx = swr_alloc();
> +if (!s->up_ctx || !s->down_ctx)
> +return AVERROR(ENOMEM);
> +
> +av_opt_set_int(s->up_ctx, "in_channel_layout",
> inlink->channel_layout, 0);
> +av_opt_set_int(s->up_ctx, "in_sample_rate",
>  inlink->sample_rate, 0);
> +av_opt_set_sample_fmt(s->up_ctx, "in_sample_fmt", inlink->format, 0);
> +
> +av_opt_set_int(s->up_ctx, "out_channel_layout",
> inlink->channel_layout, 0);
> +av_opt_set_int(s->up_ctx, "out_sample_rate",
>  inlink->sample_rate * s->oversample, 0);
> +av_opt_set_sample_fmt(s->up_ctx, "out_sample_fmt", inlink->format, 0);
> +
> +av_opt_set_int(s->down_ctx, "in_channel_layout",
> inlink->channel_layout, 0);
> +av_opt_set_int(s->down_ctx, "in_sample_rate",
>  inlink->sample_rate * s->oversample, 0);
> +av_opt_set_sample_fmt(s->down_ctx, "in_sample_fmt", inlink->format,
> 0);
> +
> +av_opt_set_int(s->down_ctx, "out_channel_layout",
> inlink->channel_layout, 0);
> +av_opt_set_int(s->down_ctx, "out_sample_rate",
>  inlink->sample_rate, 0);
> +av_opt_set_sample_fmt(s->down_ctx, "out_sample_fmt", inlink->format,
> 0);
> +
> +ret = swr_init(s->up_ctx);
> +if (ret < 0)
> +return ret;
> +
> +ret = swr_init(s->down_ctx);
> +if (ret < 0)
> +return ret;
> +
>  return 0;
>  }
>
> @@ -280,8 +323,9 @@ static int filter_channels(AVFilterContext *ctx, void
> *arg, int jobnr, int nb_jo
>  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>  {
>  AVFilterContext *ctx = inlink->dst;
> +ASoftClipContext *s = ctx->priv;
>  AVFilterLink *outlink = ctx->outputs[0];
> -int nb_samples, channels;
> +int ret, nb_sample

[FFmpeg-devel] [PATCH] avcodec: add SpeedHQ encoder

2020-11-09 Thread Paul B Mahol
From: Jean-Baptiste Kempf 

Signed-off-by: Paul B Mahol 
---
 Changelog  |   1 +
 doc/general_contents.texi  |   2 +-
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/mpegutils.h |   1 +
 libavcodec/mpegvideo.h |   5 +-
 libavcodec/mpegvideo_enc.c |  53 +-
 libavcodec/speedhq.c   |   8 +-
 libavcodec/speedhqenc.c| 322 +
 libavcodec/speedhqenc.h|  48 ++
 10 files changed, 433 insertions(+), 9 deletions(-)
 create mode 100644 libavcodec/speedhqenc.c
 create mode 100644 libavcodec/speedhqenc.h

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

[FFmpeg-devel] build ffmpeg.so with h264 and h265 codec support

2020-11-09 Thread Budi
I tried to build ffmpeg.so with h264 and h265 codec so go to compile
as on: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

but cannot find the exact need of this dynamic link build as all refer
to build standalone executable binary
How is actually the definitive way to compile/build ffmpeg.so with
h264/5 support? THANKS
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec: add SpeedHQ encoder

2020-11-09 Thread Andreas Rheinhardt
Paul B Mahol:
> From: Jean-Baptiste Kempf 
> 
> Signed-off-by: Paul B Mahol 
> ---
>  Changelog  |   1 +
>  doc/general_contents.texi  |   2 +-
>  libavcodec/Makefile|   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/mpegutils.h |   1 +
>  libavcodec/mpegvideo.h |   5 +-
>  libavcodec/mpegvideo_enc.c |  53 +-
>  libavcodec/speedhq.c   |   8 +-
>  libavcodec/speedhqenc.c| 322 +
>  libavcodec/speedhqenc.h|  48 ++
>  10 files changed, 433 insertions(+), 9 deletions(-)
>  create mode 100644 libavcodec/speedhqenc.c
>  create mode 100644 libavcodec/speedhqenc.h
> 
> diff --git a/Changelog b/Changelog
> index 3aeada17a4..b200082630 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -43,6 +43,7 @@ version :
>  - adenorm filter
>  - ADPCM IMA AMV encoder
>  - AMV muxer
> +- SpeedHQ encoder
>  
>  
>  version 4.3:
> diff --git a/doc/general_contents.texi b/doc/general_contents.texi
> index 7033816b5a..1be6f9b683 100644
> --- a/doc/general_contents.texi
> +++ b/doc/general_contents.texi
> @@ -972,7 +972,7 @@ following image formats are supported:
>  @item MPEG-4 part 2 Microsoft variant version 1  @tab @tab  X
>  @item MPEG-4 part 2 Microsoft variant version 2  @tab  X  @tab  X
>  @item MPEG-4 part 2 Microsoft variant version 3  @tab  X  @tab  X
> -@item Newtek SpeedHQ   @tab @tab  X
> +@item Newtek SpeedHQ   @tab  X  @tab  X
>  @item Nintendo Gamecube THP video  @tab @tab  X
>  @item NotchLC@tab @tab  X
>  @item NuppelVideo/RTjpeg @tab @tab  X
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 9d75dd68af..eed2a34e07 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -625,6 +625,7 @@ OBJS-$(CONFIG_SONIC_DECODER)   += sonic.o
>  OBJS-$(CONFIG_SONIC_ENCODER)   += sonic.o
>  OBJS-$(CONFIG_SONIC_LS_ENCODER)+= sonic.o
>  OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o mpeg12.o mpeg12data.o 
> simple_idct.o
> +OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o speedhqenc.o
>  OBJS-$(CONFIG_SP5X_DECODER)+= sp5xdec.o
>  OBJS-$(CONFIG_SRGC_DECODER)+= mscc.o
>  OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o htmlsubtitles.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 8bdc0d6bf7..774d5670bf 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -297,6 +297,7 @@ extern AVCodec ff_snow_encoder;
>  extern AVCodec ff_snow_decoder;
>  extern AVCodec ff_sp5x_decoder;
>  extern AVCodec ff_speedhq_decoder;
> +extern AVCodec ff_speedhq_encoder;
>  extern AVCodec ff_srgc_decoder;
>  extern AVCodec ff_sunrast_encoder;
>  extern AVCodec ff_sunrast_decoder;
> diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h
> index 1ed21c19be..81f0b73bb1 100644
> --- a/libavcodec/mpegutils.h
> +++ b/libavcodec/mpegutils.h
> @@ -125,6 +125,7 @@ enum OutputFormat {
>  FMT_H261,
>  FMT_H263,
>  FMT_MJPEG,
> +FMT_SPEEDHQ,
>  };
>  
>  
> diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
> index 29e692f245..cdeadef4cf 100644
> --- a/libavcodec/mpegvideo.h
> +++ b/libavcodec/mpegvideo.h
> @@ -444,7 +444,10 @@ typedef struct MpegEncContext {
>  int inter_intra_pred;
>  int mspel;
>  
> -/* decompression specific */
> +/* SpeedHQ specific */
> +int slice_start;
> +
> + /* decompression specific */
>  GetBitContext gb;
>  
>  /* MPEG-1 specific */
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index f16b26c9f2..7afc789ec0 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -51,6 +51,7 @@
>  #include "mathops.h"
>  #include "mpegutils.h"
>  #include "mjpegenc.h"
> +#include "speedhqenc.h"
>  #include "msmpeg4.h"
>  #include "pixblockdsp.h"
>  #include "qpeldsp.h"
> @@ -326,6 +327,15 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
>  return AVERROR(EINVAL);
>  }
>  break;
> +case AV_CODEC_ID_SPEEDHQ:
> +if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
> +avctx->pix_fmt != AV_PIX_FMT_YUV422P &&
> +avctx->pix_fmt != AV_PIX_FMT_YUV444P) {
> +av_log(avctx, AV_LOG_ERROR,
> +   "only YUV420/YUV422/YUV444 are supported (no alpha 
> support yet)\n");
> +return AVERROR(EINVAL);
> +}
> +break;
>  default:
>  if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
>  av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
> @@ -732,7 +742,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  //return -1;
>  }
>  
> -if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO || 
> s->codec_id == AV_CODEC_ID_MPEG2VIDEO || s->codec_id == AV_CODEC_ID_MJPEG || 
> s->codec_id==AV_CODEC_ID_AMV) {
> +if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO || 
> s->codec_id == AV_CODEC_ID_MPEG2VIDEO || s->codec_id 

[FFmpeg-devel] [PATCH] avcodec: add SpeedHQ encoder

2020-11-09 Thread Paul B Mahol
From: Jean-Baptiste Kempf 

Signed-off-by: Paul B Mahol 
---
 Changelog  |   1 +
 doc/general_contents.texi  |   2 +-
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/mpegutils.h |   1 +
 libavcodec/mpegvideo.h |   3 +
 libavcodec/mpegvideo_enc.c |  53 ++-
 libavcodec/speedhq.c   |   8 +-
 libavcodec/speedhqenc.c| 316 +
 libavcodec/speedhqenc.h|  48 ++
 10 files changed, 426 insertions(+), 8 deletions(-)
 create mode 100644 libavcodec/speedhqenc.c
 create mode 100644 libavcodec/speedhqenc.h

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

Re: [FFmpeg-devel] build ffmpeg.so with h264 and h265 codec support

2020-11-09 Thread Timo Rothenpieler

On 09.11.2020 12:59, Budi wrote:

I tried to build ffmpeg.so with h264 and h265 codec so go to compile
as on: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

but cannot find the exact need of this dynamic link build as all refer
to build standalone executable binary
How is actually the definitive way to compile/build ffmpeg.so with
h264/5 support? THANKS


There is no such thing as "ffmpeg.so".
FFmpeg builds various libraries, avcodec for de/encoding, avformat for 
de/muxing, and so on.

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

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

[FFmpeg-devel] [PATCH] avcodec/utils: clear the packet props queue on flushing

2020-11-09 Thread James Almer
This ensures no queued timestamps or side data are kept and used after
seeking, preventing potential desyncs.

Signed-off-by: James Almer 
---
 libavcodec/utils.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index db51512e15..a8599b3936 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1093,6 +1093,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 av_packet_unref(avci->compat_encode_packet);
 av_packet_unref(avci->buffer_pkt);
 
+av_packet_unref(avci->last_pkt_props);
+avpriv_packet_list_free(&avci->pkt_props,
+&avci->pkt_props_tail);
+
 av_frame_unref(avci->es.in_frame);
 av_packet_unref(avci->ds.in_pkt);
 
-- 
2.29.2

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

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

Re: [FFmpeg-devel] [PATCH 1/6] avformat/rtsp: 16384 -> SDP_MAX_SIZE

2020-11-09 Thread Zhao Zhili


> On Nov 4, 2020, at 9:37 PM, lance.lmw...@gmail.com wrote:
> 
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
> libavformat/rtsp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 49c2d52..1b876c9 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -696,7 +696,7 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
>  *
>  * The Vorbis FMTP line can be up to 16KB - see xiph_parse_sdp_line
>  * in rtpdec_xiph.c. */
> -char buf[16384], *q;
> +char buf[SDP_MAX_SIZE], *q;

The comments before this line should be moved to where SDP_MAX_SIZE
is defined.

> SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
> 
> p = content;
> -- 
> 1.8.3.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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

Re: [FFmpeg-devel] [PATCH] avcodec: add SpeedHQ encoder

2020-11-09 Thread Derek Buitenhuis
On 09/11/2020 12:02, Paul B Mahol wrote:
> +.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,

I think you can add FF_CODEC_CAP_INIT_THREADSAFE since ff_thread_once is
used properly.

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

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

Re: [FFmpeg-devel] [PATCH] avcodec: add SpeedHQ encoder

2020-11-09 Thread Paul B Mahol
On Mon, Nov 9, 2020 at 4:11 PM Derek Buitenhuis 
wrote:

> On 09/11/2020 12:02, Paul B Mahol wrote:
> > +.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>
> I think you can add FF_CODEC_CAP_INIT_THREADSAFE since ff_thread_once is
> used properly.
>

What about the rest of the mpv init code that calls this function, it is
safe too?


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/utils: clear the packet props queue on flushing

2020-11-09 Thread Paul B Mahol
Is this fixing known bugs?

On Mon, Nov 9, 2020 at 3:16 PM James Almer  wrote:

> This ensures no queued timestamps or side data are kept and used after
> seeking, preventing potential desyncs.
>
> Signed-off-by: James Almer 
> ---
>  libavcodec/utils.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index db51512e15..a8599b3936 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -1093,6 +1093,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
>  av_packet_unref(avci->compat_encode_packet);
>  av_packet_unref(avci->buffer_pkt);
>
> +av_packet_unref(avci->last_pkt_props);
> +avpriv_packet_list_free(&avci->pkt_props,
> +&avci->pkt_props_tail);
> +
>  av_frame_unref(avci->es.in_frame);
>  av_packet_unref(avci->ds.in_pkt);
>
> --
> 2.29.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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/utils: clear the packet props queue on flushing

2020-11-09 Thread James Almer

On 11/9/2020 1:14 PM, Paul B Mahol wrote:

Is this fixing known bugs?


https://github.com/mpv-player/mpv/issues/8248 in theory.



On Mon, Nov 9, 2020 at 3:16 PM James Almer  wrote:


This ensures no queued timestamps or side data are kept and used after
seeking, preventing potential desyncs.

Signed-off-by: James Almer 
---
  libavcodec/utils.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index db51512e15..a8599b3936 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1093,6 +1093,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
  av_packet_unref(avci->compat_encode_packet);
  av_packet_unref(avci->buffer_pkt);

+av_packet_unref(avci->last_pkt_props);
+avpriv_packet_list_free(&avci->pkt_props,
+&avci->pkt_props_tail);
+
  av_frame_unref(avci->es.in_frame);
  av_packet_unref(avci->ds.in_pkt);

--
2.29.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 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 0/4] Add NVDEC AV1 hwaccel

2020-11-09 Thread Timo Rothenpieler
Timo Rothenpieler (4):
  avcodec/av1dec: expose skip mode frame index
  avcodec/av1dec: expose coded_lossless
  avcodec/nvdec: add support for separate reference frame
  avcodec/nvdec: add av1 hwaccel

 Changelog  |   1 +
 configure  |   2 +
 libavcodec/Makefile|   1 +
 libavcodec/av1dec.c| 132 +++-
 libavcodec/av1dec.h|   5 +
 libavcodec/hwaccels.h  |   1 +
 libavcodec/nvdec.c |  44 +-
 libavcodec/nvdec.h |   4 +
 libavcodec/nvdec_av1.c | 347 +
 libavcodec/version.h   |   2 +-
 10 files changed, 534 insertions(+), 5 deletions(-)
 create mode 100644 libavcodec/nvdec_av1.c

-- 
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 1/4] avcodec/av1dec: expose skip mode frame index

2020-11-09 Thread Timo Rothenpieler
Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
 libavcodec/av1dec.c | 89 +
 libavcodec/av1dec.h |  3 ++
 2 files changed, 92 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 56712279aa..83295699e1 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -145,6 +145,87 @@ static void global_motion_params(AV1DecContext *s)
 }
 }
 
+static int get_relative_dist(const AV1RawSequenceHeader *seq,
+ unsigned int a, unsigned int b)
+{
+unsigned int diff, m;
+if (!seq->enable_order_hint)
+return 0;
+diff = a - b;
+m = 1 << seq->order_hint_bits_minus_1;
+diff = (diff & (m - 1)) - (diff & m);
+return diff;
+}
+
+static void skip_mode_params(AV1DecContext *s)
+{
+const AV1RawFrameHeader *header = s->raw_frame_header;
+const AV1RawSequenceHeader *seq = s->raw_seq;
+
+int forward_idx,  backward_idx;
+int forward_hint, backward_hint;
+int second_forward_idx, second_forward_hint;
+int ref_hint, dist, i;
+
+s->cur_frame.skip_mode_frame_idx[0] = 0;
+s->cur_frame.skip_mode_frame_idx[1] = 0;
+
+if (header->frame_type == AV1_FRAME_KEY ||
+header->frame_type == AV1_FRAME_INTRA_ONLY ||
+!header->reference_select || !seq->enable_order_hint)
+return;
+
+forward_idx  = -1;
+backward_idx = -1;
+for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+dist = get_relative_dist(seq, ref_hint, header->order_hint);
+if (dist < 0) {
+if (forward_idx < 0 ||
+get_relative_dist(seq, ref_hint, forward_hint) > 0) {
+forward_idx  = i;
+forward_hint = ref_hint;
+}
+} else if (dist > 0) {
+if (backward_idx < 0 ||
+get_relative_dist(seq, ref_hint, backward_hint) < 0) {
+backward_idx  = i;
+backward_hint = ref_hint;
+}
+}
+}
+
+if (forward_idx < 0) {
+return;
+} else if (backward_idx >= 0) {
+s->cur_frame.skip_mode_frame_idx[0] =
+AV1_REF_FRAME_LAST + FFMIN(forward_idx, backward_idx);
+s->cur_frame.skip_mode_frame_idx[1] =
+AV1_REF_FRAME_LAST + FFMAX(forward_idx, backward_idx);
+return;
+}
+
+second_forward_idx = -1;
+for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+if (get_relative_dist(seq, ref_hint, forward_hint) < 0) {
+if (second_forward_idx < 0 ||
+get_relative_dist(seq, ref_hint, second_forward_hint) > 0) {
+second_forward_idx  = i;
+second_forward_hint = ref_hint;
+}
+}
+}
+
+if (second_forward_idx < 0)
+return;
+
+s->cur_frame.skip_mode_frame_idx[0] =
+AV1_REF_FRAME_LAST + FFMIN(forward_idx, second_forward_idx);
+s->cur_frame.skip_mode_frame_idx[1] =
+AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
+}
+
 static int init_tile_data(AV1DecContext *s)
 
 {
@@ -318,6 +399,7 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame 
*f)
 av_buffer_unref(&f->hwaccel_priv_buf);
 f->hwaccel_picture_private = NULL;
 f->spatial_id = f->temporal_id = 0;
+f->order_hint = 0;
 }
 
 static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame 
*src)
@@ -337,12 +419,16 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame 
*dst, const AV1Frame *s
 
 dst->spatial_id = src->spatial_id;
 dst->temporal_id = src->temporal_id;
+memcpy(dst->skip_mode_frame_idx,
+   src->skip_mode_frame_idx,
+   2 * sizeof(uint8_t));
 memcpy(dst->gm_type,
src->gm_type,
AV1_NUM_REF_FRAMES * sizeof(uint8_t));
 memcpy(dst->gm_params,
src->gm_params,
AV1_NUM_REF_FRAMES * 6 * sizeof(int32_t));
+dst->order_hint = src->order_hint;
 
 return 0;
 
@@ -613,6 +699,7 @@ static int get_current_frame(AVCodecContext *avctx)
 }
 
 global_motion_params(s);
+skip_mode_params(s);
 
 return ret;
 }
@@ -740,6 +827,8 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
 s->cur_frame.spatial_id  = header->spatial_id;
 s->cur_frame.temporal_id = header->temporal_id;
 
+s->cur_frame.order_hint = s->raw_frame_header->order_hint;
+
 if (avctx->hwaccel) {
 ret = avctx->hwaccel->start_frame(avctx, unit->data,
   unit->data_size);
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index b58bc53961..8cf50f0d59 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -41,6 +41,9 @@ typedef struct AV1Frame {
 
 uint8_t gm_type[AV1_NUM_REF_FRAMES];
 int32_t gm_params[AV1_NUM_REF_FRAMES][6];
+
+   

[FFmpeg-devel] [PATCH 3/4] avcodec/nvdec: add support for separate reference frame

2020-11-09 Thread Timo Rothenpieler
Signed-off-by: Timo Rothenpieler 
---
 libavcodec/nvdec.c | 40 ++--
 libavcodec/nvdec.h |  3 +++
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 6168a7e3f1..52a431c54d 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -441,6 +441,7 @@ static void nvdec_fdd_priv_free(void *priv)
 
 av_buffer_unref(&cf->idx_ref);
 av_buffer_unref(&cf->decoder_ref);
+av_buffer_unref(&cf->ref_idx_ref);
 
 av_freep(&priv);
 }
@@ -465,6 +466,7 @@ static void nvdec_unmap_mapped_frame(void *opaque, uint8_t 
*data)
 finish:
 av_buffer_unref(&unmap_data->idx_ref);
 av_buffer_unref(&unmap_data->decoder_ref);
+av_buffer_unref(&unmap_data->ref_idx_ref);
 av_free(unmap_data);
 }
 
@@ -576,7 +578,7 @@ int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame 
*frame)
 ret = AVERROR(ENOMEM);
 goto fail;
 }
-cf->idx = *(unsigned int*)cf->idx_ref->data;
+cf->ref_idx = cf->idx = *(unsigned int*)cf->idx_ref->data;
 
 fdd->hwaccel_priv  = cf;
 fdd->hwaccel_priv_free = nvdec_fdd_priv_free;
@@ -589,6 +591,40 @@ fail:
 
 }
 
+int ff_nvdec_start_frame_sep_ref(AVCodecContext *avctx, AVFrame *frame, int 
has_sep_ref)
+{
+NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
+FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
+NVDECFrame *cf;
+int ret;
+
+ret = ff_nvdec_start_frame(avctx, frame);
+if (ret < 0)
+return ret;
+
+cf = fdd->hwaccel_priv;
+
+if (has_sep_ref) {
+if (!cf->ref_idx_ref) {
+cf->ref_idx_ref = av_buffer_pool_get(ctx->decoder_pool);
+if (!cf->ref_idx_ref) {
+av_log(avctx, AV_LOG_ERROR, "No decoder surfaces left\n");
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+}
+cf->ref_idx = *(unsigned int*)cf->ref_idx_ref->data;
+} else {
+av_buffer_unref(&cf->ref_idx_ref);
+cf->ref_idx = cf->idx;
+}
+
+return 0;
+fail:
+nvdec_fdd_priv_free(cf);
+return ret;
+}
+
 int ff_nvdec_end_frame(AVCodecContext *avctx)
 {
 NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
@@ -714,5 +750,5 @@ int ff_nvdec_get_ref_idx(AVFrame *frame)
 if (!cf)
 return -1;
 
-return cf->idx;
+return cf->ref_idx;
 }
diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h
index 09ae8c37e6..22b66d0bc8 100644
--- a/libavcodec/nvdec.h
+++ b/libavcodec/nvdec.h
@@ -43,7 +43,9 @@
 
 typedef struct NVDECFrame {
 unsigned int idx;
+unsigned int ref_idx;
 AVBufferRef *idx_ref;
+AVBufferRef *ref_idx_ref;
 AVBufferRef *decoder_ref;
 } NVDECFrame;
 
@@ -68,6 +70,7 @@ typedef struct NVDECContext {
 int ff_nvdec_decode_init(AVCodecContext *avctx);
 int ff_nvdec_decode_uninit(AVCodecContext *avctx);
 int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame);
+int ff_nvdec_start_frame_sep_ref(AVCodecContext *avctx, AVFrame *frame, int 
has_sep_ref);
 int ff_nvdec_end_frame(AVCodecContext *avctx);
 int ff_nvdec_simple_end_frame(AVCodecContext *avctx);
 int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
-- 
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 4/4] avcodec/nvdec: add av1 hwaccel

2020-11-09 Thread Timo Rothenpieler
Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
 Changelog  |   1 +
 configure  |   2 +
 libavcodec/Makefile|   1 +
 libavcodec/av1dec.c|  11 +-
 libavcodec/hwaccels.h  |   1 +
 libavcodec/nvdec.c |   4 +
 libavcodec/nvdec.h |   1 +
 libavcodec/nvdec_av1.c | 347 +
 libavcodec/version.h   |   2 +-
 9 files changed, 368 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/nvdec_av1.c

diff --git a/Changelog b/Changelog
index 3aeada17a4..8f5b319ef1 100644
--- a/Changelog
+++ b/Changelog
@@ -43,6 +43,7 @@ version :
 - adenorm filter
 - ADPCM IMA AMV encoder
 - AMV muxer
+- NVDEC AV1 hwaccel
 
 
 version 4.3:
diff --git a/configure b/configure
index 8a9e9b3cd7..c92824c376 100755
--- a/configure
+++ b/configure
@@ -2918,6 +2918,8 @@ videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
 xvmc_deps="X11_extensions_XvMClib_h"
 
+av1_nvdec_hwaccel_deps="nvdec CUVIDAV1PICPARAMS"
+av1_nvdec_hwaccel_select="av1_decoder"
 av1_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferAV1_bit_depth_idx"
 av1_vaapi_hwaccel_select="av1_decoder"
 h263_vaapi_hwaccel_deps="vaapi"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9d75dd68af..0c8aee39b3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -912,6 +912,7 @@ OBJS-$(CONFIG_VAAPI)  += vaapi_decode.o
 OBJS-$(CONFIG_VIDEOTOOLBOX)   += videotoolbox.o
 OBJS-$(CONFIG_VDPAU)  += vdpau.o
 
+OBJS-$(CONFIG_AV1_NVDEC_HWACCEL)  += nvdec_av1.o
 OBJS-$(CONFIG_AV1_VAAPI_HWACCEL)  += vaapi_av1.o
 OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o
 OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index bde1124434..62c26160fa 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -324,7 +324,7 @@ static int get_pixel_format(AVCodecContext *avctx)
 uint8_t bit_depth;
 int ret;
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
-#define HWACCEL_MAX (CONFIG_AV1_VAAPI_HWACCEL)
+#define HWACCEL_MAX (CONFIG_AV1_NVDEC_HWACCEL + CONFIG_AV1_VAAPI_HWACCEL)
 enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
 
 if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
@@ -387,11 +387,17 @@ static int get_pixel_format(AVCodecContext *avctx)
 
 switch (s->pix_fmt) {
 case AV_PIX_FMT_YUV420P:
+#if CONFIG_AV1_NVDEC_HWACCEL
+*fmtp++ = AV_PIX_FMT_CUDA;
+#endif
 #if CONFIG_AV1_VAAPI_HWACCEL
 *fmtp++ = AV_PIX_FMT_VAAPI;
 #endif
 break;
 case AV_PIX_FMT_YUV420P10:
+#if CONFIG_AV1_NVDEC_HWACCEL
+*fmtp++ = AV_PIX_FMT_CUDA;
+#endif
 #if CONFIG_AV1_VAAPI_HWACCEL
 *fmtp++ = AV_PIX_FMT_VAAPI;
 #endif
@@ -972,6 +978,9 @@ AVCodec ff_av1_decoder = {
 .flush = av1_decode_flush,
 .profiles  = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
 .hw_configs= (const AVCodecHWConfigInternal * []) {
+#if CONFIG_AV1_NVDEC_HWACCEL
+HWACCEL_NVDEC(av1),
+#endif
 #if CONFIG_AV1_VAAPI_HWACCEL
 HWACCEL_VAAPI(av1),
 #endif
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index 18e9079c55..6c698f6764 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -21,6 +21,7 @@
 
 #include "avcodec.h"
 
+extern const AVHWAccel ff_av1_nvdec_hwaccel;
 extern const AVHWAccel ff_av1_vaapi_hwaccel;
 extern const AVHWAccel ff_h263_vaapi_hwaccel;
 extern const AVHWAccel ff_h263_videotoolbox_hwaccel;
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 52a431c54d..48281293ce 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -62,6 +62,9 @@ typedef struct NVDECFramePool {
 static int map_avcodec_id(enum AVCodecID id)
 {
 switch (id) {
+#if CONFIG_AV1_NVDEC_HWACCEL
+case AV_CODEC_ID_AV1:return cudaVideoCodec_AV1;
+#endif
 case AV_CODEC_ID_H264:   return cudaVideoCodec_H264;
 case AV_CODEC_ID_HEVC:   return cudaVideoCodec_HEVC;
 case AV_CODEC_ID_MJPEG:  return cudaVideoCodec_JPEG;
@@ -258,6 +261,7 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx)
 NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
 
 av_freep(&ctx->bitstream);
+av_freep(&ctx->bitstream_internal);
 ctx->bitstream_len   = 0;
 ctx->bitstream_allocated = 0;
 
diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h
index 22b66d0bc8..66f3ca59e7 100644
--- a/libavcodec/nvdec.h
+++ b/libavcodec/nvdec.h
@@ -59,6 +59,7 @@ typedef struct NVDECContext {
 uint8_t  *bitstream;
 int   bitstream_len;
 unsigned int  bitstream_allocated;
+uint8_t  *bitstream_internal;
 
 unsigned *slice_offsets;
 int   nb_slices;
diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c
new file mode 100644
index 00..89eb43da84
--- /dev/null
+++ b/libavcodec/nvdec_av1.c
@@ -0,0 +1,347 @@
+/*
+ *

[FFmpeg-devel] [PATCH 2/4] avcodec/av1dec: expose coded_lossless

2020-11-09 Thread Timo Rothenpieler
Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
 libavcodec/av1dec.c | 32 +++-
 libavcodec/av1dec.h |  2 ++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 83295699e1..bde1124434 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -226,6 +226,34 @@ static void skip_mode_params(AV1DecContext *s)
 AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
 }
 
+static void coded_lossless_param(AV1DecContext *s)
+{
+const AV1RawFrameHeader *header = s->raw_frame_header;
+int i;
+
+if (header->delta_q_y_dc || header->delta_q_u_ac ||
+header->delta_q_u_dc || header->delta_q_v_ac ||
+header->delta_q_v_dc)
+return;
+
+s->cur_frame.coded_lossless = 1;
+for (i = 0; i < AV1_MAX_SEGMENTS; i++) {
+int qindex;
+if (header->feature_enabled[i][AV1_SEG_LVL_ALT_Q]) {
+qindex = (header->base_q_idx +
+  header->feature_value[i][AV1_SEG_LVL_ALT_Q]);
+} else {
+qindex = header->base_q_idx;
+}
+qindex = av_clip_uintp2(qindex, 8);
+
+if (qindex) {
+s->cur_frame.coded_lossless = 0;
+return;
+}
+}
+}
+
 static int init_tile_data(AV1DecContext *s)
 
 {
@@ -398,7 +426,7 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame 
*f)
 ff_thread_release_buffer(avctx, &f->tf);
 av_buffer_unref(&f->hwaccel_priv_buf);
 f->hwaccel_picture_private = NULL;
-f->spatial_id = f->temporal_id = 0;
+f->spatial_id = f->temporal_id = f->coded_lossless = 0;
 f->order_hint = 0;
 }
 
@@ -419,6 +447,7 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame 
*dst, const AV1Frame *s
 
 dst->spatial_id = src->spatial_id;
 dst->temporal_id = src->temporal_id;
+dst->coded_lossless = src->coded_lossless;
 memcpy(dst->skip_mode_frame_idx,
src->skip_mode_frame_idx,
2 * sizeof(uint8_t));
@@ -700,6 +729,7 @@ static int get_current_frame(AVCodecContext *avctx)
 
 global_motion_params(s);
 skip_mode_params(s);
+coded_lossless_param(s);
 
 return ret;
 }
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 8cf50f0d59..32a77425cd 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -44,6 +44,8 @@ typedef struct AV1Frame {
 
 uint8_t order_hint;
 uint8_t skip_mode_frame_idx[2];
+
+int coded_lossless;
 } AV1Frame;
 
 typedef struct TileGroupInfo {
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtsp: support infinite initial_timeout for rtsp option

2020-11-09 Thread Andriy Gelman
Hi Limin, 

On Sat, 07. Nov 02:14, Limin Wang wrote:
> ffmpeg | branch: master | Limin Wang  | Tue Nov  3 
> 18:15:21 2020 +0800| [c8101aabee654f6d147a4d89f77fa73e18908610] | committer: 
> Limin Wang
> 
> avformat/rtsp: support infinite initial_timeout for rtsp option
> 
> Signed-off-by: Limin Wang 
> 
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8101aabee654f6d147a4d89f77fa73e18908610
> ---
> 
>  libavformat/rtsp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 49c2d52375..4427bd268f 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2049,7 +2049,7 @@ static int udp_read_packet(AVFormatContext *s, 
> RTSPStream **prtsp_st,
>  }
>  }
>  #endif
> -} else if (n == 0 && --runs <= 0) {
> +} else if (n == 0 && rt->initial_timeout > 0 && --runs <= 0) {
>  return AVERROR(ETIMEDOUT);
>  } else if (n < 0 && errno != EINTR)
>  return AVERROR(errno);

Please ping before applying. 

This breaks:
ffplay -loglevel trace 
rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

The above link requires a timeout on the first call. After a timeout it will
switch from udp to tcp and the stream will work.

The issue now is that rtsp must have an infinite timeout from your changes. 
If a user tries to set a timeout it will switch to rtsp listen mode (which is
probably not what they intend if they are trying to stream from a server). 

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/utils: clear the packet props queue on flushing

2020-11-09 Thread Jan Ekström
On Mon, Nov 9, 2020 at 4:16 PM James Almer  wrote:
>
> This ensures no queued timestamps or side data are kept and used after
> seeking, preventing potential desyncs.
>
> Signed-off-by: James Almer 
> ---

I can verify this patch fixes seeking issues reported downstream with
ASF+WMApro.

Patchwork also shows FATE green, although we only have a few seek
tests and I'm not sure if they decode in the middle.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/mov: adjust skip_samples according to seek timestamp

2020-11-09 Thread Matthieu Bouron
On Mon, Nov 02, 2020 at 12:42:19PM +0100, Matthieu Bouron wrote:
> Currently skip_samples is set to start_pad if sample_time is lesser or
> equal to 0. This can cause issues if the stream starts with packets that
> have negative pts. Calling avformat_seek_file() with ts set to 0 on such
> streams makes the mov demuxer return the right corresponding packets
> (near the 0 timestamp) but set skip_samples to start_pad which is
> incorrect as the audio decoder will discard the returned samples
> according to skip_samples from the first packet it receives (which has
> its timestamp near 0).
> 
> For example, considering the following audio stream with start_pad=1344:
> 
>  [PKT pts=-1344] [PKT pts=-320] [PKT pts=704] [PKT pts=1728] [...]
> 
> Calling avformat_seek_file() with ts=0 makes the next call to
> av_read_frame() return the packet with pts=-320 and a skip samples
> side data set to 1344 (start_pad). This makes the audio decoder
> incorrectly discard (1344 - 320) samples.
> 
> This commit makes the move demuxer adjust skip_samples according to the
> stream start_pad, seek timestamp and first sample timestamp.
> 
> The above example will now result in av_read_frame() still returning the
> packet with pts=-320 but with a skip samples side data set to 320
> (src_pad - (seek_timestamp - first_timestamp)). This makes the audio
> decoder only discard 320 samples (from pts=-320 to pts=0).
> ---
>  libavformat/mov.c | 18 --
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index dd0db6bca79..f99cb0df25a 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -8098,20 +8098,34 @@ static int mov_read_seek(AVFormatContext *s, int 
> stream_index, int64_t sample_ti
>  return sample;
>  
>  if (mc->seek_individually) {
> +MOVStreamContext *sc = s->streams[stream_index]->priv_data;
> +
>  /* adjust seek timestamp to found sample timestamp */
> +int64_t first_timestamp = st->internal->index_entries[0].timestamp;
>  int64_t seek_timestamp = 
> st->internal->index_entries[sample].timestamp;
>  
> +/* adjust skip samples according to stream start_pad, seek timestamp 
> and first timestamp */
> +int64_t skip_samples = FFMAX(sc->start_pad - (seek_timestamp - 
> first_timestamp), 0);
> +st->internal->skip_samples = skip_samples;
> +
>  for (i = 0; i < s->nb_streams; i++) {
>  int64_t timestamp;
>  MOVStreamContext *sc = s->streams[i]->priv_data;
>  st = s->streams[i];
> -st->internal->skip_samples = (sample_time <= 0) ? sc->start_pad 
> : 0;
>  
>  if (stream_index == i)
>  continue;
>  
>  timestamp = av_rescale_q(seek_timestamp, 
> s->streams[stream_index]->time_base, st->time_base);
> -mov_seek_stream(s, st, timestamp, flags);
> +sample = mov_seek_stream(s, st, timestamp, flags);
> +if (sample >= 0) {
> +first_timestamp = st->internal->index_entries[0].timestamp;
> +seek_timestamp = 
> st->internal->index_entries[sample].timestamp;
> +
> +/* adjust skip samples according to stream start_pad, seek 
> timestamp and first timestamp */
> +skip_samples = FFMAX(sc->start_pad - (seek_timestamp - 
> first_timestamp), 0);
> +st->internal->skip_samples = skip_samples;
> +}
>  }
>  } else {
>  for (i = 0; i < s->nb_streams; i++) {
> -- 
> 2.29.2
> 

Ping.

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

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

Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtsp: support infinite initial_timeout for rtsp option

2020-11-09 Thread Andriy Gelman
On Mon, 09. Nov 12:52, Andriy Gelman wrote:
> Hi Limin, 
> 
> On Sat, 07. Nov 02:14, Limin Wang wrote:
> > ffmpeg | branch: master | Limin Wang  | Tue Nov  3 
> > 18:15:21 2020 +0800| [c8101aabee654f6d147a4d89f77fa73e18908610] | 
> > committer: Limin Wang
> > 
> > avformat/rtsp: support infinite initial_timeout for rtsp option
> > 
> > Signed-off-by: Limin Wang 
> > 
> > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8101aabee654f6d147a4d89f77fa73e18908610
> > ---
> > 
> >  libavformat/rtsp.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index 49c2d52375..4427bd268f 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -2049,7 +2049,7 @@ static int udp_read_packet(AVFormatContext *s, 
> > RTSPStream **prtsp_st,
> >  }
> >  }
> >  #endif
> > -} else if (n == 0 && --runs <= 0) {
> > +} else if (n == 0 && rt->initial_timeout > 0 && --runs <= 0) {
> >  return AVERROR(ETIMEDOUT);
> >  } else if (n < 0 && errno != EINTR)
> >  return AVERROR(errno);
> 
> Please ping before applying. 

> 
> This breaks:
> ffplay -loglevel trace 
> rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov
> 

The link may work for you when you test. I'm behind a firewall that blocks udp
traffic, which is why the switch from udp to tcp is needed after a timeout. 

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/utils: clear the packet props queue on flushing

2020-11-09 Thread James Almer

On 11/9/2020 2:20 PM, Jan Ekström wrote:

On Mon, Nov 9, 2020 at 4:16 PM James Almer  wrote:


This ensures no queued timestamps or side data are kept and used after
seeking, preventing potential desyncs.

Signed-off-by: James Almer 
---


I can verify this patch fixes seeking issues reported downstream with
ASF+WMApro.

Patchwork also shows FATE green, although we only have a few seek
tests and I'm not sure if they decode in the middle.


Will apply, thanks.
___
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] Add enable_keyframe_filtering option for libaom-av1 encoder.

2020-11-09 Thread Bohan Li
I have added a feature request in the libaom issue tracker for the key &
value api, although it may take some time for the api to land. Meanwhile I
still suggest that we apply this patch to ffmpeg since as mentioned this
option can be quite important for subjective quality control.
Please let me know if there are any concerns.

Thanks!
Bohan

On Fri, Nov 6, 2020 at 9:31 AM Bohan Li  wrote:

> Thanks a lot for the comment, Jan and Steven! Yes I very much agree that
> the number of options is quite large and this is not a great path to go
> for. But for the moment I still suggest that we apply this patch, while
> proposing to libaom for a key & value api.
>
> This option gives users the option to control the keyframe filtering
> method, which is quite essential to both objective and subjective quality.
> When turned on (default) the objective quality/compression efficiency is
> greatly improved, but at the cost of potential subjective quality loss at
> keyframes (because they are filtered and can appear blurry). Therefore
> users who do not want to have such artifacts may want to disable the
> option. This is actually a long-standing trade-off that libaom users have
> to (sometimes painfully) choose, and they cannot do so with ffmpeg right
> now. Also recently a new experimental option (=2) was added to libaom in
> order to mitigate the subjective loss. It would be nice to expose this
> option for people to be able to test it using ffmpeg with various decoders
> too. I've observed a few related discussions in the AV1 community (e.g. the
> reddit thread on the experimental option:
> https://www.reddit.com/r/AV1/comments/ic7ktu/aom_fixed_its_filtered_reference_frame_issues/
> ).
>
> That said, I do understand the rationale and the reason why people might
> be opposed to adding another option, though I still suggest that we add the
> option for now, and when the API is available, we can make decisions and
> deprecate certain ones that are not necessary. Please let me know your
> thoughts on this, meanwhile I'll file a feature request to the aomedia bug
> tracker for the API.
>
> Thank you again for the comments!
> Best,
> Bohan
>
> On Fri, Nov 6, 2020 at 3:16 AM Jan Ekström  wrote:
>
>> On Fri, Nov 6, 2020 at 11:46 AM Steven Liu  wrote:
>> >
>> >
>> >
>> > > 2020年11月6日 下午4:42,Bohan Li  写道:
>> > >
>> > > Thanks for the reply, Steven!
>> > >
>> > > Regarding JEEB’s comment, the suggestion was to add an api to the
>> *libaom* library, not to ffmpeg. I do agree with the rationale, but when
>> such an api would be available for ffmpeg to use is quite uncertain. In the
>> meanwhile, I believe it is reasonable to add in this patch to expose the
>> option to the users. I don’t think this is a “middle version”, since as
>> mentioned, this option could be quite useful in certain scenarios and IMHO
>> should be added in.
>> > What about use av1_param arguments? As x264opts, x265opts?
>>
>> The problem with this is that libaom as far as I can tell doesn't have
>> an API like that. Thus each and every API user that needs to have
>> options defined as strings will have to *duplicate* those mappings
>> (which already are defined in the aomenc command line application, but
>> not exposed through the API).
>>
>> This has been the butt of jokes and reason for lamentations on IRC for
>> quite a while, but unfortunately nobody actually seems to have voiced
>> an opinion on this on the mailing list until now?
>>
>> Thus there generally speaking are only two ways forward for this:
>> 1. This is really spammy and unfortunate (and getting these removed
>> will be a PITA after we actually do get a key & value based API), but
>> we take the additional option in.
>> 2. This is apparently a low usage option and the amount of AVOptions
>> in this encoder is getting higher and higher, thus we deny the patch
>> until a key, value based API is provided.
>>
>> Personally I lean somewhat towards 2, but if the option is
>> needed/useful (use cases can be provided), then begrudgingly I could
>> go for 1.
>>
>> So far the lack of comments has mostly been regarding people not
>> having high enough stakes/care regarding this module, methinks?
>>
>> Jan
>> ___
>> 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/4] avcodec/av1dec: expose skip mode frame index

2020-11-09 Thread Mark Thompson

On 09/11/2020 16:30, Timo Rothenpieler wrote:

Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
  libavcodec/av1dec.c | 89 +
  libavcodec/av1dec.h |  3 ++
  2 files changed, 92 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 56712279aa..83295699e1 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -145,6 +145,87 @@ static void global_motion_params(AV1DecContext *s)
  }
  }
  
+static int get_relative_dist(const AV1RawSequenceHeader *seq,

+ unsigned int a, unsigned int b)
+{
+unsigned int diff, m;
+if (!seq->enable_order_hint)
+return 0;


This never gets called if !enable_order_hint, so the argument isn't needed.


+diff = a - b;
+m = 1 << seq->order_hint_bits_minus_1;
+diff = (diff & (m - 1)) - (diff & m);
+return diff;
+}
+
+static void skip_mode_params(AV1DecContext *s)
+{
+const AV1RawFrameHeader *header = s->raw_frame_header;
+const AV1RawSequenceHeader *seq = s->raw_seq;
+
+int forward_idx,  backward_idx;
+int forward_hint, backward_hint;
+int second_forward_idx, second_forward_hint;
+int ref_hint, dist, i;
+
+s->cur_frame.skip_mode_frame_idx[0] = 0;
+s->cur_frame.skip_mode_frame_idx[1] = 0;


0 is AV1_REF_FRAME_INTRA, which doesn't make sense for skip.  Does this value 
actually get used?


+
+if (header->frame_type == AV1_FRAME_KEY ||
+header->frame_type == AV1_FRAME_INTRA_ONLY ||
+!header->reference_select || !seq->enable_order_hint)


if (!header->skip_mode_present)

would be much simpler and short-cut some empty cases that this condition misses.


+return;
+
+forward_idx  = -1;
+backward_idx = -1;
+for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+dist = get_relative_dist(seq, ref_hint, header->order_hint);
+if (dist < 0) {
+if (forward_idx < 0 ||
+get_relative_dist(seq, ref_hint, forward_hint) > 0) {
+forward_idx  = i;
+forward_hint = ref_hint;
+}
+} else if (dist > 0) {
+if (backward_idx < 0 ||
+get_relative_dist(seq, ref_hint, backward_hint) < 0) {
+backward_idx  = i;
+backward_hint = ref_hint;
+}
+}
+}
+
+if (forward_idx < 0) {
+return;
+} else if (backward_idx >= 0) {
+s->cur_frame.skip_mode_frame_idx[0] =
+AV1_REF_FRAME_LAST + FFMIN(forward_idx, backward_idx);
+s->cur_frame.skip_mode_frame_idx[1] =
+AV1_REF_FRAME_LAST + FFMAX(forward_idx, backward_idx);
+return;
+}
+
+second_forward_idx = -1;
+for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+if (get_relative_dist(seq, ref_hint, forward_hint) < 0) {
+if (second_forward_idx < 0 ||
+get_relative_dist(seq, ref_hint, second_forward_hint) > 0) {
+second_forward_idx  = i;
+second_forward_hint = ref_hint;
+}
+}
+}
+
+if (second_forward_idx < 0)
+return;
+
+s->cur_frame.skip_mode_frame_idx[0] =
+AV1_REF_FRAME_LAST + FFMIN(forward_idx, second_forward_idx);
+s->cur_frame.skip_mode_frame_idx[1] =
+AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
+}
+
  static int init_tile_data(AV1DecContext *s)
  
  {

@@ -318,6 +399,7 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame 
*f)
  av_buffer_unref(&f->hwaccel_priv_buf);
  f->hwaccel_picture_private = NULL;
  f->spatial_id = f->temporal_id = 0;
+f->order_hint = 0;
  }
  
  static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)

@@ -337,12 +419,16 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame 
*dst, const AV1Frame *s
  
  dst->spatial_id = src->spatial_id;

  dst->temporal_id = src->temporal_id;
+memcpy(dst->skip_mode_frame_idx,
+   src->skip_mode_frame_idx,
+   2 * sizeof(uint8_t));


Keeping this in the same order as the structure would make it easier to check 
that all fields are copied.


  memcpy(dst->gm_type,
 src->gm_type,
 AV1_NUM_REF_FRAMES * sizeof(uint8_t));
  memcpy(dst->gm_params,
 src->gm_params,
 AV1_NUM_REF_FRAMES * 6 * sizeof(int32_t));
+dst->order_hint = src->order_hint;
  
  return 0;
  
@@ -613,6 +699,7 @@ static int get_current_frame(AVCodecContext *avctx)

  }
  
  global_motion_params(s);

+skip_mode_params(s);
  
  return ret;

  }
@@ -740,6 +827,8 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
  s->cur_frame.spatial_id  = header->spatial_id;
  s->cur_frame.temporal_id = header->temporal_id;
  
+s->cur_frame.order

Re: [FFmpeg-devel] [PATCH 2/4] avcodec/av1dec: expose coded_lossless

2020-11-09 Thread Mark Thompson

On 09/11/2020 16:30, Timo Rothenpieler wrote:

Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
  libavcodec/av1dec.c | 32 +++-
  libavcodec/av1dec.h |  2 ++
  2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 83295699e1..bde1124434 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -226,6 +226,34 @@ static void skip_mode_params(AV1DecContext *s)
  AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
  }
  
+static void coded_lossless_param(AV1DecContext *s)

+{
+const AV1RawFrameHeader *header = s->raw_frame_header;
+int i;
+
+if (header->delta_q_y_dc || header->delta_q_u_ac ||
+header->delta_q_u_dc || header->delta_q_v_ac ||
+header->delta_q_v_dc)
+return;


Just write the field here.  Relying on the reset to zero by the previous unref 
is nonobvious enough that it looked like an error.


+
+s->cur_frame.coded_lossless = 1;
+for (i = 0; i < AV1_MAX_SEGMENTS; i++) {
+int qindex;
+if (header->feature_enabled[i][AV1_SEG_LVL_ALT_Q]) {
+qindex = (header->base_q_idx +
+  header->feature_value[i][AV1_SEG_LVL_ALT_Q]);
+} else {
+qindex = header->base_q_idx;
+}
+qindex = av_clip_uintp2(qindex, 8);
+
+if (qindex) {
+s->cur_frame.coded_lossless = 0;
+return;
+}
+} > +}
+
  static int init_tile_data(AV1DecContext *s)
  
  {

@@ -398,7 +426,7 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame 
*f)
  ff_thread_release_buffer(avctx, &f->tf);
  av_buffer_unref(&f->hwaccel_priv_buf);
  f->hwaccel_picture_private = NULL;
-f->spatial_id = f->temporal_id = 0;
+f->spatial_id = f->temporal_id = f->coded_lossless = 0;


Mild dislike for combining with an unrelated assignment which happens to have 
the same value.


  f->order_hint = 0;
  }
  
@@ -419,6 +447,7 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s
  
  dst->spatial_id = src->spatial_id;

  dst->temporal_id = src->temporal_id;
+dst->coded_lossless = src->coded_lossless;
  memcpy(dst->skip_mode_frame_idx,
 src->skip_mode_frame_idx,
 2 * sizeof(uint8_t));
@@ -700,6 +729,7 @@ static int get_current_frame(AVCodecContext *avctx)
  
  global_motion_params(s);

  skip_mode_params(s);
+coded_lossless_param(s);
  
  return ret;

  }
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 8cf50f0d59..32a77425cd 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -44,6 +44,8 @@ typedef struct AV1Frame {
  
  uint8_t order_hint;

  uint8_t skip_mode_frame_idx[2];
+
+int coded_lossless;


uint8_t - it's a single bit.


  } AV1Frame;
  
  typedef struct TileGroupInfo {




- Mark
___
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 4/4] avcodec/nvdec: add av1 hwaccel

2020-11-09 Thread Mark Thompson

On 09/11/2020 16:30, Timo Rothenpieler wrote:

Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
  Changelog  |   1 +
  configure  |   2 +
  libavcodec/Makefile|   1 +
  libavcodec/av1dec.c|  11 +-
  libavcodec/hwaccels.h  |   1 +
  libavcodec/nvdec.c |   4 +
  libavcodec/nvdec.h |   1 +
  libavcodec/nvdec_av1.c | 347 +
  libavcodec/version.h   |   2 +-
  9 files changed, 368 insertions(+), 2 deletions(-)
  create mode 100644 libavcodec/nvdec_av1.c

...
diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c
new file mode 100644
index 00..89eb43da84
--- /dev/null
+++ b/libavcodec/nvdec_av1.c
@@ -0,0 +1,347 @@
+/*
+ * VP9 HW decode acceleration through NVDEC


VP9?

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

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

Re: [FFmpeg-devel] [PATCH 1/4] avcodec/av1dec: expose skip mode frame index

2020-11-09 Thread Timo Rothenpieler

On 09.11.2020 23:30, Mark Thompson wrote:

On 09/11/2020 16:30, Timo Rothenpieler wrote:

Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
  libavcodec/av1dec.c | 89 +
  libavcodec/av1dec.h |  3 ++
  2 files changed, 92 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 56712279aa..83295699e1 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -145,6 +145,87 @@ static void global_motion_params(AV1DecContext *s)
  }
  }
+static int get_relative_dist(const AV1RawSequenceHeader *seq,
+ unsigned int a, unsigned int b)
+{
+    unsigned int diff, m;
+    if (!seq->enable_order_hint)
+    return 0;


This never gets called if !enable_order_hint, so the argument isn't needed.


+    diff = a - b;
+    m = 1 << seq->order_hint_bits_minus_1;
+    diff = (diff & (m - 1)) - (diff & m);
+    return diff;
+}
+
+static void skip_mode_params(AV1DecContext *s)
+{
+    const AV1RawFrameHeader *header = s->raw_frame_header;
+    const AV1RawSequenceHeader *seq = s->raw_seq;
+
+    int forward_idx,  backward_idx;
+    int forward_hint, backward_hint;
+    int second_forward_idx, second_forward_hint;
+    int ref_hint, dist, i;
+
+    s->cur_frame.skip_mode_frame_idx[0] = 0;
+    s->cur_frame.skip_mode_frame_idx[1] = 0;


0 is AV1_REF_FRAME_INTRA, which doesn't make sense for skip.  Does this 
value actually get used?


What else would you set it to in that case?
It's set to 0 to indicate an invalid value.


+
+    if (header->frame_type == AV1_FRAME_KEY ||
+    header->frame_type == AV1_FRAME_INTRA_ONLY ||
+    !header->reference_select || !seq->enable_order_hint)


if (!header->skip_mode_present)

would be much simpler and short-cut some empty cases that this condition 
misses.


But that's not equivalent to the CBS code, is it?
Cause skip_mode_allowed can be 1 and the flag it reads into 
skip_mode_present can still be 0?


The code is trying to behave the same the skip_mode_params params 
function in the cbs_av1 parser does.




+    return;
+
+    forward_idx  = -1;
+    backward_idx = -1;
+    for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+    ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+    dist = get_relative_dist(seq, ref_hint, header->order_hint);
+    if (dist < 0) {
+    if (forward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, forward_hint) > 0) {
+    forward_idx  = i;
+    forward_hint = ref_hint;
+    }
+    } else if (dist > 0) {
+    if (backward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, backward_hint) < 0) {
+    backward_idx  = i;
+    backward_hint = ref_hint;
+    }
+    }
+    }
+
+    if (forward_idx < 0) {
+    return;
+    } else if (backward_idx >= 0) {
+    s->cur_frame.skip_mode_frame_idx[0] =
+    AV1_REF_FRAME_LAST + FFMIN(forward_idx, backward_idx);
+    s->cur_frame.skip_mode_frame_idx[1] =
+    AV1_REF_FRAME_LAST + FFMAX(forward_idx, backward_idx);
+    return;
+    }
+
+    second_forward_idx = -1;
+    for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+    ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+    if (get_relative_dist(seq, ref_hint, forward_hint) < 0) {
+    if (second_forward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, second_forward_hint) 
> 0) {

+    second_forward_idx  = i;
+    second_forward_hint = ref_hint;
+    }
+    }
+    }
+
+    if (second_forward_idx < 0)
+    return;
+
+    s->cur_frame.skip_mode_frame_idx[0] =
+    AV1_REF_FRAME_LAST + FFMIN(forward_idx, second_forward_idx);
+    s->cur_frame.skip_mode_frame_idx[1] =
+    AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
+}
+
  static int init_tile_data(AV1DecContext *s)
  {
@@ -318,6 +399,7 @@ static void av1_frame_unref(AVCodecContext *avctx, 
AV1Frame *f)

  av_buffer_unref(&f->hwaccel_priv_buf);
  f->hwaccel_picture_private = NULL;
  f->spatial_id = f->temporal_id = 0;
+    f->order_hint = 0;
  }
  static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const 
AV1Frame *src)
@@ -337,12 +419,16 @@ static int av1_frame_ref(AVCodecContext *avctx, 
AV1Frame *dst, const AV1Frame *s

  dst->spatial_id = src->spatial_id;
  dst->temporal_id = src->temporal_id;
+    memcpy(dst->skip_mode_frame_idx,
+   src->skip_mode_frame_idx,
+   2 * sizeof(uint8_t));


Keeping this in the same order as the structure would make it easier to 
check that all fields are copied.



  memcpy(dst->gm_type,
 src->gm_type,
 AV1_NUM_REF_FRAMES * sizeof(uint8_t));
  memcpy(dst->gm_params,
 src->gm_params,
 AV1_NUM_REF_FRAMES * 6 * sizeof(int32_t));
+    dst->order_hint = src->order_hint;
  return 0;
@@ -613,6 +699,7 @@ static int get_cu

Re: [FFmpeg-devel] [PATCH v4] Unbreak av_malloc_max(0) API/ABI

2020-11-09 Thread Joakim Tjernlund
On Sun, 2020-11-08 at 15:13 +0100, Michael Niedermayer wrote:
> CAUTION: This email originated from outside of the organization. Do not click 
> links or open attachments unless you recognize the sender and know the 
> content is safe.
> 
> 
> On Sun, Nov 08, 2020 at 11:35:43AM +0100, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> > > On Fri, Oct 16, 2020 at 10:57:22AM +0200, Joakim Tjernlund wrote:
> > > > From 
> > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1095962&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C0c52cb182fa941b874c908d883f07c2c%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637404416183627186%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=7wEFER5KUD1KEnTJ7mr2xnfmOzctpDsb0Bld%2BfAvjAc%3D&reserved=0
> > > > 
> > > > This seems to be caused by the custom handling of "av_max_alloc(0)" in
> > > > Chromium's ffmpeg fork to mean unlimited (added in [1]).
> > > > 
> > > > Upstream ffmpeg doesn't treat 0 as a special value; versions before 4.3 
> > > > seemingly worked
> > > > because 32 was subtracted from max_alloc_size (set to 0 by Chromium) 
> > > > resulting in an
> > > > integer underflow, making the effective limit be SIZE_MAX - 31.
> > > > 
> > > > Now that the above underflow doesn't happen, the tab just crashes. The 
> > > > upstream change
> > > > for no longer subtracting 32 from max_alloc_size was included in ffmpeg 
> > > > 4.3. [2]
> > > > 
> > > > [1] 
> > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fthird_party%2Fffmpeg%2F%2B%2F73563&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C0c52cb182fa941b874c908d883f07c2c%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637404416183627186%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=s%2BnujuFPv6QwNlIKjuXQNcDR3wvA%2BY7Uu4Qnr%2FsHjnE%3D&reserved=0
> > > > [2] 
> > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFFmpeg%2FFFmpeg%2Fcommit%2F731c77589841&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C0c52cb182fa941b874c908d883f07c2c%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637404416183637145%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ftg9ysBzC5YD9uEe%2BgJwZIecW8a6fAXXNS9kGqDMnp8%3D&reserved=0
> > > > ---
> > > > 
> > > > Restore av_malloc_max(0) to MAX_INT fixing MS Teams, Discord older 
> > > > chromium etc.
> > > > 
> > > > Signed-off-by: Joakim Tjernlund 
> > > > ---
> > > > 
> > > >  v2: Cover the full API range 0-31
> > > > 
> > > >  v3: Closer compat with < 4.3 ffmpeg
> > > > 
> > > >  v4: Adjust size accoriding to Andreas Rheinhardt comments
> > > > 
> > > >  libavutil/mem.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > 
> > > "Unbreak av_malloc_max(0) API/ABI"
> > > The commit message of this is incorrect
> > > 
> > > The API before and after this documented the current git master behavior
> > > more correct would be
> > > "Break API of av_malloc_max() for 0-31, to restore ABI behavior so 
> > > applications using this do not need to be changed"
> > > 
> > 
> > I agree.
> > 
> > > Also id like to raise awareness that this function had a big warning:
> > > *
> > > * @warning Exercise extreme caution when using this function. Don't 
> > > touch
> > > *  this if you do not understand the full consequence of 
> > > doing so.
> > > */
> > > void av_max_alloc(size_t max);
> > > 
> > > And also id like to raise awareness that the default limit is INT_MAX
> > > while with 0 as argument it becomes SIZE_MAX.
> > 
> > No: With the old version 0 was effectively SIZE_MAX - 31, with current
> > git head 0 means that all allocations of > 0 fail (yet requests of size
> > 0 still result in an allocation of size 1); with the proposed version
> > av_max_alloc(0) would set the limit to SIZE_MAX - 32. This off-by-one is
> > surely unintentional.
> > 
> 
> > I would expect that is
> > > not safe everywhere and could open security issues.
> > > If anything 0 should be interpreted as the default INT_MAX
> > 
> > That would be an API break.
> 
> yes, that was meant as a "less bad" alternative to SIZE_MAX - 31
> 
> 
> > 
> > > If its not obvious where SIZE_MAX can be an issue, consider what we
> > > use to index arrays, int, and that doesnt go to SIZE_MAX but instead
> > > hits undefined behavior maybe becomes negative and accesses out of array
> > 
> > Any code that relies on allocations > INT_MAX to fail is buggy and must
> > be fixed;
> 
> YES
> 
> 
> > and so is any code that uses an index parameter of type int
> > and uses a comparison with a value of type size_t as its loop condition.
> 
> YES
> though there are more complex failure cases
> for example a
> array[i + j*C]
> here the 2 loops for i a

Re: [FFmpeg-devel] build ffmpeg.so with h264 and h265 codec support

2020-11-09 Thread Budi
I tried to build libffmpeg.so with h264 and h265 codec so go to compile
as on: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

but cannot find the exact need of this dynamic link build as all refer
to build standalone executable binary
How is actually the definitive way to compile/build libffmpeg.so with
h264/5 support? THANKS

On 11/9/20, Timo Rothenpieler  wrote:
> On 09.11.2020 12:59, Budi wrote:
>> I tried to build ffmpeg.so with h264 and h265 codec so go to compile
>> as on: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
>>
>> but cannot find the exact need of this dynamic link build as all refer
>> to build standalone executable binary
>> How is actually the definitive way to compile/build ffmpeg.so with
>> h264/5 support? THANKS
>
> There is no such thing as "ffmpeg.so".
> FFmpeg builds various libraries, avcodec for de/encoding, avformat for
> de/muxing, and so on.
> ___
> 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/4] avcodec/av1dec: expose skip mode frame index

2020-11-09 Thread Mark Thompson

On 09/11/2020 22:50, Timo Rothenpieler wrote:

On 09.11.2020 23:30, Mark Thompson wrote:

On 09/11/2020 16:30, Timo Rothenpieler wrote:

Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
  libavcodec/av1dec.c | 89 +
  libavcodec/av1dec.h |  3 ++
  2 files changed, 92 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 56712279aa..83295699e1 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -145,6 +145,87 @@ static void global_motion_params(AV1DecContext *s)
  }
  }
+static int get_relative_dist(const AV1RawSequenceHeader *seq,
+ unsigned int a, unsigned int b)
+{
+    unsigned int diff, m;
+    if (!seq->enable_order_hint)
+    return 0;


This never gets called if !enable_order_hint, so the argument isn't needed.


+    diff = a - b;
+    m = 1 << seq->order_hint_bits_minus_1;
+    diff = (diff & (m - 1)) - (diff & m);
+    return diff;
+}
+
+static void skip_mode_params(AV1DecContext *s)
+{
+    const AV1RawFrameHeader *header = s->raw_frame_header;
+    const AV1RawSequenceHeader *seq = s->raw_seq;
+
+    int forward_idx,  backward_idx;
+    int forward_hint, backward_hint;
+    int second_forward_idx, second_forward_hint;
+    int ref_hint, dist, i;
+
+    s->cur_frame.skip_mode_frame_idx[0] = 0;
+    s->cur_frame.skip_mode_frame_idx[1] = 0;


0 is AV1_REF_FRAME_INTRA, which doesn't make sense for skip.  Does this value 
actually get used?


What else would you set it to in that case?
It's set to 0 to indicate an invalid value.


If it isn't used then don't set it at all?  If it has to be set then I guess 
use a value outside the 0..7 valid range of ref frames.


+
+    if (header->frame_type == AV1_FRAME_KEY ||
+    header->frame_type == AV1_FRAME_INTRA_ONLY ||
+    !header->reference_select || !seq->enable_order_hint)


if (!header->skip_mode_present)

would be much simpler and short-cut some empty cases that this condition misses.


But that's not equivalent to the CBS code, is it?
Cause skip_mode_allowed can be 1 and the flag it reads into skip_mode_present 
can still be 0?


skip_mode_present is set iff skip modes are present.  If they aren't then 
calculating what frames could have been used for skip references had they been 
present is meaningless.


The code is trying to behave the same the skip_mode_params params function in 
the cbs_av1 parser does.


Which isn't what you want, because here we know more than the parser did.  
(Notably: whether frames you have headers for were actually complete, which you 
are doing.)


+    return;
+
+    forward_idx  = -1;
+    backward_idx = -1;
+    for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+    ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+    dist = get_relative_dist(seq, ref_hint, header->order_hint);
+    if (dist < 0) {
+    if (forward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, forward_hint) > 0) {
+    forward_idx  = i;
+    forward_hint = ref_hint;
+    }
+    } else if (dist > 0) {
+    if (backward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, backward_hint) < 0) {
+    backward_idx  = i;
+    backward_hint = ref_hint;
+    }
+    }
+    }
+
+    if (forward_idx < 0) {
+    return;
+    } else if (backward_idx >= 0) {
+    s->cur_frame.skip_mode_frame_idx[0] =
+    AV1_REF_FRAME_LAST + FFMIN(forward_idx, backward_idx);
+    s->cur_frame.skip_mode_frame_idx[1] =
+    AV1_REF_FRAME_LAST + FFMAX(forward_idx, backward_idx);
+    return;
+    }
+
+    second_forward_idx = -1;
+    for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+    ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+    if (get_relative_dist(seq, ref_hint, forward_hint) < 0) {
+    if (second_forward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, second_forward_hint) > 0) {
+    second_forward_idx  = i;
+    second_forward_hint = ref_hint;
+    }
+    }
+    }
+
+    if (second_forward_idx < 0)
+    return;
+
+    s->cur_frame.skip_mode_frame_idx[0] =
+    AV1_REF_FRAME_LAST + FFMIN(forward_idx, second_forward_idx);
+    s->cur_frame.skip_mode_frame_idx[1] =
+    AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
+}
+
  static int init_tile_data(AV1DecContext *s)
  {
@@ -318,6 +399,7 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame 
*f)
  av_buffer_unref(&f->hwaccel_priv_buf);
  f->hwaccel_picture_private = NULL;
  f->spatial_id = f->temporal_id = 0;
+    f->order_hint = 0;
  }
  static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame 
*src)
@@ -337,12 +419,16 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame 
*dst, const AV1Frame *s
  dst->spatial_id = src->spatial_id;
  dst->temporal_id = src->temporal_id;
+    me

[FFmpeg-devel] [PATCH 2/7] avcodec/vp3dsp: Use unsigned constant to avoid undefined integer overflow in ff_vp3dsp_set_bounding_values()

2020-11-09 Thread Michael Niedermayer
Fixes: signed integer overflow: 64 * 33686018 cannot be represented in type 
'int'
Fixes: 
26911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-4904975073017856

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

diff --git a/libavcodec/vp3dsp.c b/libavcodec/vp3dsp.c
index f485fba1f6..ec859a679d 100644
--- a/libavcodec/vp3dsp.c
+++ b/libavcodec/vp3dsp.c
@@ -490,5 +490,5 @@ void ff_vp3dsp_set_bounding_values(int * 
bounding_values_array, int filter_limit
 }
 if (value)
 bounding_values[128] = value;
-bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202;
+bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202U;
 }
-- 
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 6/7] avformat/avidec: dv does not support palettes

2020-11-09 Thread Michael Niedermayer
Fixes: memleak
Fixes: 
26937/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5763003338981376

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

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 7e527e15ee..0044499c6d 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1446,6 +1446,7 @@ resync:
 if (avi->stream_index >= 0) {
 AVStream *st   = s->streams[avi->stream_index];
 AVIStream *ast = st->priv_data;
+int dv_demux = CONFIG_DV_DEMUXER && avi->dv_demux;
 int size, err;
 
 if (get_subtitle_pkt(s, st, pkt))
@@ -1468,7 +1469,7 @@ resync:
 return err;
 size = err;
 
-if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2) {
+if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2 && !dv_demux) {
 uint8_t *pal;
 pal = av_packet_new_side_data(pkt,
   AV_PKT_DATA_PALETTE,
@@ -1482,7 +1483,7 @@ resync:
 }
 }
 
-if (CONFIG_DV_DEMUXER && avi->dv_demux) {
+if (dv_demux) {
 AVBufferRef *avbuf = pkt->buf;
 size = avpriv_dv_produce_packet(avi->dv_demux, pkt,
 pkt->data, pkt->size, pkt->pos);
-- 
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 1/7] avformat/sbgdec: Check that end is not before start

2020-11-09 Thread Michael Niedermayer
Fixes: signed integer overflow: -9223372036854775808 + -5279949906739200 cannot 
be represented in type 'long'
Fixes: 
26908/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6329610851319808

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

diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index 4d6ae7abc5..f56eb9ff59 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -1416,6 +1416,11 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
 if (r < 0)
 goto fail;
 
+if (script.end_ts != AV_NOPTS_VALUE && script.end_ts < script.start_ts) {
+r = AVERROR_INVALIDDATA;
+goto fail;
+}
+
 st = avformat_new_stream(avf, NULL);
 if (!st)
 return AVERROR(ENOMEM);
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 3/7] libavformat/utils: consider avio_size() failure in ffio_limit()

2020-11-09 Thread Michael Niedermayer
Fixes: Timeout (>20sec -> 3ms)
Fixes: 
26918/clusterfuzz-testcase-minimized-ffmpeg_dem_THP_fuzzer-5750425191710720

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

diff --git a/libavformat/utils.c b/libavformat/utils.c
index e4a4e7651b..f6120663ac 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -244,13 +244,16 @@ int av_format_get_probe_score(const AVFormatContext *s)
 int ffio_limit(AVIOContext *s, int size)
 {
 if (s->maxsize>= 0) {
-int64_t remaining= s->maxsize - avio_tell(s);
+int64_t pos = avio_tell(s);
+int64_t remaining= s->maxsize - pos;
 if (remaining < size) {
 int64_t newsize = avio_size(s);
 if (!s->maxsize || s->maxsizemaxsize = newsize - !newsize;
-remaining= s->maxsize - avio_tell(s);
-remaining= FFMAX(remaining, 0);
+if (pos > s->maxsize && s->maxsize >= 0)
+s->maxsize = AVERROR(EIO);
+if (s->maxsize >= 0)
+remaining = s->maxsize - pos;
 }
 
 if (s->maxsize>= 0 && remaining+1 < size) {
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 4/7] avformat/au: cleanup on EOF return in au_read_annotation()

2020-11-09 Thread Michael Niedermayer
On Fri, Nov 06, 2020 at 12:29:37AM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: memleak
> > Fixes: 
> > 26841/clusterfuzz-testcase-minimized-ffmpeg_dem_AU_fuzzer-5174166309044224
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/au.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/au.c b/libavformat/au.c
> > index b4eb4f8477..4f2b81119f 100644
> > --- a/libavformat/au.c
> > +++ b/libavformat/au.c
> > @@ -84,8 +84,11 @@ static int au_read_annotation(AVFormatContext *s, int 
> > size)
> >  av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED);
> >  
> >  while (size-- > 0) {
> > -if (avio_feof(pb))
> > +if (avio_feof(pb)) {
> > +av_bprint_finalize(&bprint, NULL);
> > +av_freep(&key);
> >  return AVERROR_EOF;
> > +}
> >  c = avio_r8(pb);
> >  switch(state) {
> >  case PARSE_KEY:
> > 
> You could reuse the ordinary freeing code at the end of the function.
> LGTM either way. (That's a regression since
> e680d50eb4feddafb2d8575b21fc5fc8764f4801, isn't it?)

will add a note about the regression an will apply

thx

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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 4/7] avformat/dhav: Break out of infinite dhav search loop

2020-11-09 Thread Michael Niedermayer
Fixes: Infinite loop
Fixes: 
26922/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5794549613723648

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

diff --git a/libavformat/dhav.c b/libavformat/dhav.c
index 53deaff77e..6989b9bc01 100644
--- a/libavformat/dhav.c
+++ b/libavformat/dhav.c
@@ -290,6 +290,8 @@ static int dhav_read_header(AVFormatContext *s)
 int seek_back;
 
 seek_back = avio_rl32(s->pb) + 8;
+if (seek_back < 9)
+break;
 dhav->last_good_pos = avio_tell(s->pb);
 avio_seek(s->pb, -seek_back, SEEK_CUR);
 }
-- 
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 5/7] avformat/wavdec: Avoid zeroing written to array

2020-11-09 Thread Michael Niedermayer
Fixes: OOM
Fixes: 
26934/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5996784213819392

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

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index a81f2c7a67..6e5f4ccc12 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -920,7 +920,7 @@ static int w64_read_header(AVFormatContext *s)
 if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > 
filesize))
 return AVERROR_INVALIDDATA;
 
-value = av_mallocz(chunk_size + 1);
+value = av_malloc(chunk_size + 1);
 if (!value)
 return AVERROR(ENOMEM);
 
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 4/5] avformat/lvfdec: Check stream_index before use

2020-11-09 Thread Michael Niedermayer
On Sun, Nov 08, 2020 at 09:21:45PM +0100, Paul B Mahol wrote:
> LGTM

will apply

thx

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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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 7/7] avcodec/cri: check for available input in unpack_10bit()

2020-11-09 Thread Michael Niedermayer
Fixes: Timeout (>20sec -> 56ms)
Fixes: 
26995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5107217080254464

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

diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index dafbc1f1be..9bcd2ebfc6 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -80,10 +80,13 @@ static void unpack_10bit(GetByteContext *gb, uint16_t *dst, 
int shift,
 int pos = 0;
 
 while (count > 0) {
-uint32_t a0 = bytestream2_get_le32(gb);
-uint32_t a1 = bytestream2_get_le32(gb);
-uint32_t a2 = bytestream2_get_le32(gb);
-uint32_t a3 = bytestream2_get_le32(gb);
+uint32_t a0, a1,a2,a3;
+if (bytestream2_get_bytes_left(gb) < 4)
+break;
+a0 = bytestream2_get_le32(gb);
+a1 = bytestream2_get_le32(gb);
+a2 = bytestream2_get_le32(gb);
+a3 = bytestream2_get_le32(gb);
 dst[pos] = (((a0 >> 1) & 0xE00) | (a0 & 0x1FF)) << shift;
 pos++;
 if (pos >= w) {
-- 
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/4] avfilter/vf_fade: config_props -> config_input

2020-11-09 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_fade.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index af4795c..51eea04 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -404,7 +404,7 @@ static int filter_slice_alpha16(AVFilterContext *ctx, void 
*arg, int jobnr,
 return 0;
 }
 
-static int config_props(AVFilterLink *inlink)
+static int config_input(AVFilterLink *inlink)
 {
 FadeContext *s = inlink->dst->priv;
 const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format);
@@ -553,7 +553,7 @@ static const AVFilterPad avfilter_vf_fade_inputs[] = {
 {
 .name   = "default",
 .type   = AVMEDIA_TYPE_VIDEO,
-.config_props   = config_props,
+.config_props   = config_input,
 .filter_frame   = filter_frame,
 .needs_writable = 1,
 },
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH 1/4] avfilter/vf_fade: simplify code to use pts timebase for time check

2020-11-09 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_fade.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index 58d7f8c..af4795c 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -62,6 +62,7 @@ typedef struct FadeContext {
 int alpha;
 int is_planar;
 uint64_t start_time, duration;
+uint64_t start_time_pts, duration_pts;
 enum {VF_FADE_WAITING=0, VF_FADE_FADING, VF_FADE_DONE} fade_state;
 uint8_t color_rgba[4];  ///< fade color
 int black_fade; ///< if color_rgba is black
@@ -422,6 +423,11 @@ static int config_props(AVFilterLink *inlink)
 s->is_rgb = pixdesc->flags & AV_PIX_FMT_FLAG_RGB;
 s->is_packed_rgb = !s->is_planar && s->is_rgb;
 
+if (s->duration)
+s->duration_pts = av_rescale_q(s->duration, AV_TIME_BASE_Q, 
inlink->time_base);
+if (s->start_time)
+s->start_time_pts = av_rescale_q(s->start_time, AV_TIME_BASE_Q, 
inlink->time_base);
+
 /* use CCIR601/709 black level for studio-level pixel non-alpha components 
*/
 s->black_level =
 ff_fmt_is_in(inlink->format, studio_level_pix_fmts) && !s->alpha ? 
16 * (1 << (s->depth - 8)): 0;
@@ -440,29 +446,28 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 {
 AVFilterContext *ctx = inlink->dst;
 FadeContext *s   = ctx->priv;
-double frame_timestamp = frame->pts == AV_NOPTS_VALUE ? -1 : frame->pts * 
av_q2d(inlink->time_base);
 
 // Calculate Fade assuming this is a Fade In
 if (s->fade_state == VF_FADE_WAITING) {
 s->factor=0;
-if (frame_timestamp >= s->start_time/(double)AV_TIME_BASE
+if (frame->pts >= s->start_time_pts
 && inlink->frame_count_out >= s->start_frame) {
 // Time to start fading
 s->fade_state = VF_FADE_FADING;
 
 // Save start time in case we are starting based on frames and 
fading based on time
-if (s->start_time == 0 && s->start_frame != 0) {
-s->start_time = frame_timestamp*(double)AV_TIME_BASE;
+if (s->start_time_pts == 0 && s->start_frame != 0) {
+s->start_time_pts = frame->pts;
 }
 
 // Save start frame in case we are starting based on time and 
fading based on frames
-if (s->start_time != 0 && s->start_frame == 0) {
+if (s->start_time_pts != 0 && s->start_frame == 0) {
 s->start_frame = inlink->frame_count_out;
 }
 }
 }
 if (s->fade_state == VF_FADE_FADING) {
-if (s->duration == 0) {
+if (s->duration_pts == 0) {
 // Fading based on frame count
 s->factor = (inlink->frame_count_out - s->start_frame) * 
s->fade_per_frame;
 if (inlink->frame_count_out > s->start_frame + s->nb_frames) {
@@ -471,10 +476,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 
 } else {
 // Fading based on duration
-s->factor = (frame_timestamp - s->start_time/(double)AV_TIME_BASE)
-* (float) UINT16_MAX / 
(s->duration/(double)AV_TIME_BASE);
-if (frame_timestamp > s->start_time/(double)AV_TIME_BASE
-  + s->duration/(double)AV_TIME_BASE) {
+s->factor = (frame->pts - s->start_time_pts) * UINT16_MAX / 
s->duration_pts;
+if (frame->pts > s->start_time_pts + s->duration_pts) {
 s->fade_state = VF_FADE_DONE;
 }
 }
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH 3/4] avformat/dvenc: s->streams[i] -> st

2020-11-09 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/dvenc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index b04d604..1c38673 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -307,14 +307,15 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
 
 /* We have to sort out where audio and where video stream is */
 for (i=0; inb_streams; i++) {
-switch (s->streams[i]->codecpar->codec_type) {
+AVStream *st = s->streams[i];
+switch (st->codecpar->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
 if (vst) return NULL;
-vst = s->streams[i];
+vst = st;
 break;
 case AVMEDIA_TYPE_AUDIO:
 if (c->n_ast > 1) return NULL;
-c->ast[c->n_ast++] = s->streams[i];
+c->ast[c->n_ast++] = st;
 break;
 default:
 goto bail_out;
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH 4/4] avformat/dvenc: check the format before vst and ast[i] are initialized

2020-11-09 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/dvenc.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 1c38673..6c0d40f 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -311,10 +311,20 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
 switch (st->codecpar->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
 if (vst) return NULL;
+if (st->codecpar->codec_id != AV_CODEC_ID_DVVIDEO)
+goto bail_out;
 vst = st;
 break;
 case AVMEDIA_TYPE_AUDIO:
 if (c->n_ast > 1) return NULL;
+/* Some checks -- DV format is very picky about its incoming 
streams */
+if(st->codecpar->codec_id!= AV_CODEC_ID_PCM_S16LE ||
+   st->codecpar->channels!= 2)
+goto bail_out;
+if (st->codecpar->sample_rate != 48000 &&
+st->codecpar->sample_rate != 44100 &&
+st->codecpar->sample_rate != 32000)
+goto bail_out;
 c->ast[c->n_ast++] = st;
 break;
 default:
@@ -322,20 +332,9 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
 }
 }
 
-/* Some checks -- DV format is very picky about its incoming streams */
-if (!vst || vst->codecpar->codec_id != AV_CODEC_ID_DVVIDEO)
+if (!vst)
 goto bail_out;
-for (i=0; in_ast; i++) {
-if (c->ast[i]) {
-if(c->ast[i]->codecpar->codec_id!= AV_CODEC_ID_PCM_S16LE ||
-   c->ast[i]->codecpar->channels!= 2)
-goto bail_out;
-if (c->ast[i]->codecpar->sample_rate != 48000 &&
-c->ast[i]->codecpar->sample_rate != 44100 &&
-c->ast[i]->codecpar->sample_rate != 32000)
-goto bail_out;
-}
-}
+
 c->sys = av_dv_codec_profile2(vst->codecpar->width, vst->codecpar->height,
   vst->codecpar->format, vst->time_base);
 if (!c->sys)
-- 
1.8.3.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 1/6] avformat/rtsp: 16384 -> SDP_MAX_SIZE

2020-11-09 Thread lance . lmwang
On Mon, Nov 09, 2020 at 10:51:05PM +0800, Zhao Zhili wrote:
> 
> 
> > On Nov 4, 2020, at 9:37 PM, lance.lmw...@gmail.com wrote:
> > 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/rtsp.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index 49c2d52..1b876c9 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -696,7 +696,7 @@ int ff_sdp_parse(AVFormatContext *s, const char 
> > *content)
> >  *
> >  * The Vorbis FMTP line can be up to 16KB - see xiph_parse_sdp_line
> >  * in rtpdec_xiph.c. */
> > -char buf[16384], *q;
> > +char buf[SDP_MAX_SIZE], *q;
> 
> The comments before this line should be moved to where SDP_MAX_SIZE
> is defined.

Yes, I have noticed the comments also, but SDP_MAX_SIZE is more general usage
for rtpdec and rtpenc, so I don't think 16KB is necessary for Vorbis only. 
I prefer to remove the comments and keep the log in comment message. 

> 
> > SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
> > 
> > p = content;
> > -- 
> > 1.8.3.1
> > 
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
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 7/7] avcodec/cri: check for available input in unpack_10bit()

2020-11-09 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: Timeout (>20sec -> 56ms)
> Fixes: 
> 26995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5107217080254464
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cri.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/cri.c b/libavcodec/cri.c
> index dafbc1f1be..9bcd2ebfc6 100644
> --- a/libavcodec/cri.c
> +++ b/libavcodec/cri.c
> @@ -80,10 +80,13 @@ static void unpack_10bit(GetByteContext *gb, uint16_t 
> *dst, int shift,
>  int pos = 0;
>  
>  while (count > 0) {
> -uint32_t a0 = bytestream2_get_le32(gb);
> -uint32_t a1 = bytestream2_get_le32(gb);
> -uint32_t a2 = bytestream2_get_le32(gb);
> -uint32_t a3 = bytestream2_get_le32(gb);
> +uint32_t a0, a1,a2,a3;
> +if (bytestream2_get_bytes_left(gb) < 4)
> +break;
> +a0 = bytestream2_get_le32(gb);
> +a1 = bytestream2_get_le32(gb);
> +a2 = bytestream2_get_le32(gb);
> +a3 = bytestream2_get_le32(gb);
>  dst[pos] = (((a0 >> 1) & 0xE00) | (a0 & 0x1FF)) << shift;
>  pos++;
>  if (pos >= w) {
> 
Wouldn't it make sense to check for 16 bytes to be left given that
that's the amount that is read immediately afterwards? And if you check
for this, you could just use bytestream2_get_le32u().

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

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

Re: [FFmpeg-devel] [PATCH 1/4] avcodec/av1dec: expose skip mode frame index

2020-11-09 Thread James Almer

On 11/9/2020 8:02 PM, Mark Thompson wrote:

On 09/11/2020 22:50, Timo Rothenpieler wrote:

On 09.11.2020 23:30, Mark Thompson wrote:

On 09/11/2020 16:30, Timo Rothenpieler wrote:

Signed-off-by: Timo Rothenpieler 
Co-authored-by: James Almer 
---
  libavcodec/av1dec.c | 89 
+

  libavcodec/av1dec.h |  3 ++
  2 files changed, 92 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 56712279aa..83295699e1 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -145,6 +145,87 @@ static void global_motion_params(AV1DecContext *s)
  }
  }
+static int get_relative_dist(const AV1RawSequenceHeader *seq,
+ unsigned int a, unsigned int b)
+{
+    unsigned int diff, m;
+    if (!seq->enable_order_hint)
+    return 0;


This never gets called if !enable_order_hint, so the argument isn't 
needed.



+    diff = a - b;
+    m = 1 << seq->order_hint_bits_minus_1;
+    diff = (diff & (m - 1)) - (diff & m);
+    return diff;
+}
+
+static void skip_mode_params(AV1DecContext *s)
+{
+    const AV1RawFrameHeader *header = s->raw_frame_header;
+    const AV1RawSequenceHeader *seq = s->raw_seq;
+
+    int forward_idx,  backward_idx;
+    int forward_hint, backward_hint;
+    int second_forward_idx, second_forward_hint;
+    int ref_hint, dist, i;
+
+    s->cur_frame.skip_mode_frame_idx[0] = 0;
+    s->cur_frame.skip_mode_frame_idx[1] = 0;


0 is AV1_REF_FRAME_INTRA, which doesn't make sense for skip.  Does 
this value actually get used?


What else would you set it to in that case?
It's set to 0 to indicate an invalid value.


If it isn't used then don't set it at all?  If it has to be set then I 
guess use a value outside the 0..7 valid range of ref frames.


He should do whatever cuviddec does, since one would assume is what the 
hardware expects. primary_ref_frame in CUVIDAV1PICPARAMS for example is 
set to -1 (255) to signal AV1_PRIMARY_REF_NONE.


Also, both AV1Frame and CUVIDAV1PICPARAMS are zero initialized, so not 
setting it to anything is the same as setting it to 0.





+
+    if (header->frame_type == AV1_FRAME_KEY ||
+    header->frame_type == AV1_FRAME_INTRA_ONLY ||
+    !header->reference_select || !seq->enable_order_hint)


if (!header->skip_mode_present)

would be much simpler and short-cut some empty cases that this 
condition misses.


But that's not equivalent to the CBS code, is it?
Cause skip_mode_allowed can be 1 and the flag it reads into 
skip_mode_present can still be 0?


skip_mode_present is set iff skip modes are present.  If they aren't 
then calculating what frames could have been used for skip references 
had they been present is meaningless.


The code is trying to behave the same the skip_mode_params params 
function in the cbs_av1 parser does.


Which isn't what you want, because here we know more than the parser 
did.  (Notably: whether frames you have headers for were actually 
complete, which you are doing.)



+    return;
+
+    forward_idx  = -1;
+    backward_idx = -1;
+    for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+    ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+    dist = get_relative_dist(seq, ref_hint, header->order_hint);
+    if (dist < 0) {
+    if (forward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, forward_hint) > 0) {
+    forward_idx  = i;
+    forward_hint = ref_hint;
+    }
+    } else if (dist > 0) {
+    if (backward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, backward_hint) < 0) {
+    backward_idx  = i;
+    backward_hint = ref_hint;
+    }
+    }
+    }
+
+    if (forward_idx < 0) {
+    return;
+    } else if (backward_idx >= 0) {
+    s->cur_frame.skip_mode_frame_idx[0] =
+    AV1_REF_FRAME_LAST + FFMIN(forward_idx, backward_idx);
+    s->cur_frame.skip_mode_frame_idx[1] =
+    AV1_REF_FRAME_LAST + FFMAX(forward_idx, backward_idx);
+    return;
+    }
+
+    second_forward_idx = -1;
+    for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+    ref_hint = s->ref[header->ref_frame_idx[i]].order_hint;
+    if (get_relative_dist(seq, ref_hint, forward_hint) < 0) {
+    if (second_forward_idx < 0 ||
+    get_relative_dist(seq, ref_hint, 
second_forward_hint) > 0) {

+    second_forward_idx  = i;
+    second_forward_hint = ref_hint;
+    }
+    }
+    }
+
+    if (second_forward_idx < 0)
+    return;
+
+    s->cur_frame.skip_mode_frame_idx[0] =
+    AV1_REF_FRAME_LAST + FFMIN(forward_idx, second_forward_idx);
+    s->cur_frame.skip_mode_frame_idx[1] =
+    AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
+}
+
  static int init_tile_data(AV1DecContext *s)
  {
@@ -318,6 +399,7 @@ static void av1_frame_unref(AVCodecContext 
*avctx, AV1Frame *f)

  av_buffer_unref(&f->hwaccel_priv_buf);
  f->hwa

Re: [FFmpeg-devel] [PATCH] avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

2020-11-09 Thread Dave Rice


> On Nov 6, 2020, at 4:03 PM, Michael Niedermayer  
> wrote:
> 
> On Wed, Nov 04, 2020 at 10:44:56PM +0100, Marton Balint wrote:
>> 
>> On Wed, 4 Nov 2020, Michael Niedermayer wrote:
>> 
>>> we have "millisecond" based formats, rounded timestamps
>>> we have "exact" cases, maybe the timebase being 1 packet/frame per tick
>>> we have "high precission" where the timebase is so precisse it doesnt matter
>>> 
>>> This here though is a bit an oddball, the size if 1 PCM frame is 1 sample
>>> The timebase is not a millisecond based one, its not 1 frame either nor is
>>> it exact nor high precission.
>>> Its 1 video frame, and whatever amount of audio there is in the container
>>> 
>>> which IIUC can differ from 1 video frame even rounded.
>>> maybe this just doesnt occur and each frame has a count of samples always
>>> rounded to the closes integer count for the video frame.
>> 
>> The difference between the audio timestamp and the video timestamp for
>> packets from the same DV frame is at most 0.3929636797*frame_duration as the
>> specification says, as Dave quoted, so I don't see how the error can be
>> bigger than this.
>> 
>> It looks to me you are mixing timestamps coming from a demuxer, and
>> timestamps you calculate by counting the number of demuxed/decoded audio
>> samples or video frames. Synchronization is done using the former.
>> 
> 
>>> 
>>> But if for example some hardware was using internally a 16 sample buffer
>>> and only put multiplies of 16 samples in frames this would introduce a
>>> considerable amount of jitter in the timestamps in relation to the actual
>>> duration. And using async to fix this without introducing more problems
>>> might require some care.
>> 
>> I still don't see why timestamp or duration jitter is a problem 
> 
>> as long as
>> the error is below frame_duration/2. You can safely use async with
>> min_hard_comp set to frame_duration/2.
> 
> Thats exactly what i meant. an async like filter which behaves differently
> or async with a different value there can mess this up.
> IMHO such mess up is ok when the input is corrupted or invalid. OTOH
> here it is valid and correct data.
> 
>> In general, don't you find it problematic that the dv demuxer can return
>> different timestamps if you read packets sequentially and if you seek to the
>> end of a file? It looks like a huge bug
> 
> yes, this is not great
> but even with your patch you still have this effect
> when seeking to some point in time a player has to output video and
> audio to the user at an exact time and that will differ even with async
> from linear playbacks presentation

When trying to workaround the loss of audio sync, I use -skip_initial_bytes on 
the dv input to jump to the frame after a missing audio pack to read from that 
point to keep audio and video in sync from that offset in the bytestream (at 
least until the next missing audio source pack).

>> which is not fixable if you insist
>> on sample counting...
> 
> I think you misunderstood me, or maybe i didnt state my opinion well,
> iam not saying that i consider what dv in git does good. Rather that there
> is a problem beyond what these patches fix. 
> Some concept of timestamp accuracy independant of the distance of 
> representable
> values would be usefull.
> if you take teh 1/25 or whatever they are based on dv timestamps and convert 
> that
> to teh mpeg 90khz based ones thats not making it that accurate.
> OTOH if you take 1/25 based audio where each packet is 1/25sec worth of 
> samples
> that very well might be sample accurate or even beyond.
> knowing this accuracy is usefull for configuring a async like filter or also 
> in
> knowing how to deal with inconsistencies, is that timestamp jtter ? or the 
> sample
> rate jittering / some droped samples ? 
> Its important to know as in one instance its the timestamps that need 
> adjustment 
> while in the other the samples need adjustment
> ATM its down to the user to figure out on a file by file base how to deal or
> ignore this. Instead it should be possible for an automated system to 
> compensate such issues ...

As mentioned elsewhere, some automation (or at least a logged hint) would be 
helpful to add or suggest aresample=async=1 to fill the gaps when using 
containers that don’t support sparse audio. With Marton’s patch, the user has 
the opportunity to use that filter to keep the audio in sync.

[…]

Dave Rice

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