Re: [FFmpeg-devel] [PATCH 2/4] avcodec/libx264: Don't use init_static_data for newer versions

2021-02-26 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> x264 versions >= 153 can support multiple bitdepths; they also don't
> export x264_bit_depth any more. The actual check whether a bitdepth
> is supported is therefore performed at runtime in x264_encoder_open.
> Ergo it is unnecessary to use init_static_data for these versions:
> One can already set ff_libx264_encoder.pix_fmts to the value that
> X264_init_static always sets it to.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> The actual aim is of course to enable to make ff_libx264_encoder const
> after the next major bump if a new libx264 version is used. I am
> currently working on this.
> 
>  libavcodec/libx264.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index ca7cc3a540..212ed7d015 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -1051,19 +1051,17 @@ static const enum AVPixelFormat pix_fmts_8bit_rgb[] = 
> {
>  };
>  #endif
>  
> +#if X264_BUILD < 153
>  static av_cold void X264_init_static(AVCodec *codec)
>  {
> -#if X264_BUILD < 153
>  if (x264_bit_depth == 8)
>  codec->pix_fmts = pix_fmts_8bit;
>  else if (x264_bit_depth == 9)
>  codec->pix_fmts = pix_fmts_9bit;
>  else if (x264_bit_depth == 10)
>  codec->pix_fmts = pix_fmts_10bit;
> -#else
> -codec->pix_fmts = pix_fmts_all;
> -#endif
>  }
> +#endif
>  
>  #define OFFSET(x) offsetof(X264Context, x)
>  #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> @@ -1208,7 +1206,11 @@ AVCodec ff_libx264_encoder = {
>  AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
>  .priv_class   = _class,
>  .defaults = x264_defaults,
> +#if X264_BUILD < 153
>  .init_static_data = X264_init_static,
> +#else
> +.pix_fmts = pix_fmts_all,
> +#endif
>  #if X264_BUILD >= 158
>  .caps_internal= FF_CODEC_CAP_INIT_CLEANUP | 
> FF_CODEC_CAP_INIT_THREADSAFE,
>  #else
> 
Will apply the remaining two patches of this patchset tomorrow unless
there are objections.

- 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 V3 1/5] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-26 Thread Guo, Yejun


> -Original Message-
> From: Nicolas George 
> Sent: 2021年2月26日 17:28
> To: FFmpeg development discussions and patches 
> Cc: Guo, Yejun 
> Subject: Re: [FFmpeg-devel] [PATCH V3 1/5] libavdevice/v4l2.c: fix build
> warning for [-Wformat-truncation=]
> 
> Guo, Yejun (12021-02-26):
> > Here is the warning message:
> > src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
> > src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be
> truncated writing up to 255 bytes into a region of size 251
> [-Wformat-truncation=]
> >  snprintf(device_name, sizeof(device_name), "/dev/%s",
> entry->d_name);
> >   ^~
> > src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261
> bytes into a destination of size 256
> >  snprintf(device_name, sizeof(device_name), "/dev/%s",
> entry->d_name);
> >
> >
> ^~~
> ~
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> >  libavdevice/v4l2.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index
> > 365bacd771..cb426cf2d5 100644
> > --- a/libavdevice/v4l2.c
> > +++ b/libavdevice/v4l2.c
> > @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext
> *ctx, AVDeviceInfoList *device_l
> >  return ret;
> >  }
> >  while ((entry = readdir(dir))) {
> > -char device_name[256];
> 
> > +char device_name[sizeof(entry->d_name) + 5];
> 
> Unfortunately, that is not guaranteed to work: entry->d_name can be declared
> as char d_name[0] and the space dynamically allocated at the end of the
> structure.

'man readdir' on my system shows that it is d_name[256], see below.

   struct dirent {
   ino_t  d_ino;   /* Inode number */
   off_t  d_off;   /* Not an offset; see below */
   unsigned short d_reclen;/* Length of this record */
   unsigned char  d_type;  /* Type of file; not supported
  by all filesystem types */
   char   d_name[256]; /* Null-terminated filename */
   };

If there is a possibility for 'char d_name[0]', yes, it is an issue in the 
patch.

> 
> I think a better course of action would be to acknowledge that this warning is
> a waste of time and disable it.

agree, and maybe we can just let this build warning there.

> 
> That does not mean we should not fix the cases where the buffer can be too
> small. We should, and we will find them without this warning, by making use
> of common sense. This instance is not one, because even with a billion
> webcams, /dev/video9 fits in 256 chars.
> 
> >
> >  if (!v4l2_is_v4l_dev(entry->d_name))
> >  continue;
> 
> Regards,
> 
> --
>   Nicolas George
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V2 1/7] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-26 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Reimar
> D?ffinger
> Sent: 2021年2月26日 17:21
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V2 1/7] libavdevice/v4l2.c: fix build
> warning for [-Wformat-truncation=]
> 
> 
> > On 25 Feb 2021, at 18:52, Chad Fraleigh  wrote:
> >
> > On 2/24/2021 10:38 PM, Guo, Yejun wrote:
> >>  libavdevice/v4l2.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> >> index 365bacd771..e11d10d20e 100644
> >> --- a/libavdevice/v4l2.c
> >> +++ b/libavdevice/v4l2.c
> >> @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext
> *ctx, AVDeviceInfoList *device_l
> >>  return ret;
> >>  }
> >>  while ((entry = readdir(dir))) {
> >> -char device_name[256];
> >> +char device_name[512];
> >
> > Is there a portable path max constant that would be better for cases like 
> > this,
> rather than just picking another arbitrary buffer size?
> 
> There is PATH_MAX/MAX_PATH, however the problems are:
> 1) They are not necessarily a strict limit on path length, so no guarantee 
> all file
> names fit
> 2) Even if there is such a guarantee, that only applies to VALID file names,
> however the files here are user input ans not necessarily valid, so using 
> those
> defines does not fix things anyway
> 
> Speaking generally I have doubts that these patches actually IMPROVE security
> and don’t make it actually worse.
> On the plus side I see:
> - they fix truncations in those specific cases
> On the minus side I see:
> - file names can clearly be longer, so there is still a truncation issue even 
> after
> these patches, truncation just happens elsewhere and at larger lengths
> - the warning is removed, so now there is nothing that reminds developers of
> this issue existing
> - it relies on “magic constants” that can easily become outdated and
> re-introduce the issue again at any time
> - there is as far as I can tell no evidence that any of these truncations 
> cause
> actual issues, or if so in which circumstances, so there is no evidence of 
> benefit.
> However as with all changes there is a risk of introducing new bugs
> - size of on-stack variables are increased which may decrease effectiveness of
> stack protection

For the code in this function, max length of file name is fixed, see the code 
below.
Anyway, it still increases the on-stack variable size which might have 
potential security
issue.

snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);

'man readdir' shows:
   struct dirent {
   ino_t  d_ino;   /* Inode number */
   off_t  d_off;   /* Not an offset; see below */
   unsigned short d_reclen;/* Length of this record */
   unsigned char  d_type;  /* Type of file; not supported
  by all filesystem types */
   char   d_name[256]; /* Null-terminated filename */
   };

> 
> As a result personally I am mostly worried about these patches if they are
> applied without a deep security review of each and ensuring the issues are
> understood and thoroughly fixed.
> I before suggested using av_asprintf, which does at least permanently solve 
> the
> truncation issue without magic constants and eliminates on-stack arrays,
> however I should also add that it might create a allocation failure issue, 
> which
> then opens up the whole “how to handle allocation failure without
> introducing a even more tricky security issue”.
> So I am afraid that these issues will be annoyingly costly to fix, and I am 
> not
> sure how big the desire is to do so...

with such concern, maybe we can just let this build warning there.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/3] avcodec: add SGA Video decoder

2021-02-26 Thread James Almer

On 2/26/2021 8:29 AM, Paul B Mahol wrote:

Signed-off-by: Paul B Mahol 
---
  libavcodec/Makefile |   1 +
  libavcodec/allcodecs.c  |   1 +
  libavcodec/codec_desc.c |   7 +
  libavcodec/codec_id.h   |   1 +
  libavcodec/sga.c| 534 
  5 files changed, 544 insertions(+)
  create mode 100644 libavcodec/sga.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fe7026c1db..850657ae3c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -609,6 +609,7 @@ OBJS-$(CONFIG_SANM_DECODER)+= sanm.o
  OBJS-$(CONFIG_SCPR_DECODER)+= scpr.o
  OBJS-$(CONFIG_SCREENPRESSO_DECODER)+= screenpresso.o
  OBJS-$(CONFIG_SDX2_DPCM_DECODER)   += dpcm.o
+OBJS-$(CONFIG_SGA_DECODER) += sga.o
  OBJS-$(CONFIG_SGI_DECODER) += sgidec.o
  OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o
  OBJS-$(CONFIG_SGIRLE_DECODER)  += sgirledec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 990998b64b..a04faead16 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -289,6 +289,7 @@ extern AVCodec ff_s302m_decoder;
  extern AVCodec ff_sanm_decoder;
  extern AVCodec ff_scpr_decoder;
  extern AVCodec ff_screenpresso_decoder;
+extern AVCodec ff_sga_decoder;
  extern AVCodec ff_sgi_encoder;
  extern AVCodec ff_sgi_decoder;
  extern AVCodec ff_sgirle_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index f64ba488f2..17f8a14044 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1849,6 +1849,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
  .long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"),
  .props = AV_CODEC_PROP_LOSSY,
  },
+{
+.id= AV_CODEC_ID_SGA_VIDEO,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "sga",
+.long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"),
+.props = AV_CODEC_PROP_LOSSY,
+},
  
  /* various PCM "codecs" */

  {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 7dd316afd2..ab7bc68ee2 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -306,6 +306,7 @@ enum AVCodecID {
  AV_CODEC_ID_ARGO,
  AV_CODEC_ID_CRI,
  AV_CODEC_ID_SIMBIOSIS_IMX,
+AV_CODEC_ID_SGA_VIDEO,
  
  /* various PCM "codecs" */

  AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/sga.c b/libavcodec/sga.c
new file mode 100644
index 00..00752a5843
--- /dev/null
+++ b/libavcodec/sga.c


sgadec.c?

[...]


+memcpy(frame->data[1], s->pal, AVPALETTE_SIZE);
+frame->palette_has_changed = 1;
+frame->pict_type = AV_PICTURE_TYPE_I;


Missing intra only in codec_desc.c, then?


+frame->key_frame = 1;


The demuxer does not seem to set every packet as key frame, only some. 
Which is it?



+
+*got_frame = 1;
+
+return avpkt->size;
+}
+
+static av_cold int sga_decode_end(AVCodecContext *avctx)
+{
+SGAVideoContext *s = avctx->priv_data;
+
+av_freep(>tileindex_data);
+s->tileindex_size = 0;
+
+av_freep(>palmapindex_data);
+s->palmapindex_size = 0;
+
+return 0;
+}
+
+AVCodec ff_sga_decoder = {
+.name   = "sga",
+.long_name  = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_SGA_VIDEO,
+.priv_data_size = sizeof(SGAVideoContext),
+.init   = sga_decode_init,
+.decode = sga_decode_frame,
+.close  = sga_decode_end,
+.capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+};



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

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

Re: [FFmpeg-devel] [PATCH 01/15] avformat/movenc: Remove always true check

2021-02-26 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/movenc.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 545b0885ae..cdfcbd3d76 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -6395,7 +6395,6 @@ static int mov_init(AVFormatContext *s)
>  /* Default mode == MP4 */
>  mov->mode = MODE_MP4;
>  
> -if (s->oformat) {
>  if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
>  else if (!strcmp("3g2", s->oformat->name)) mov->mode = 
> MODE_3GP|MODE_3G2;
>  else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
> @@ -6403,7 +6402,6 @@ static int mov_init(AVFormatContext *s)
>  else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
>  else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
>  else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V;
> -}
>  
>  if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
>  mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
> 
Will apply this patchset tomorrow unless there are objections.
(I already fixed the typo "avformt" in the commit title of the last
patch locally.)

- 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] avcodec/x86: add cfhdenc SIMD

2021-02-26 Thread James Almer

On 2/26/2021 9:27 PM, Paul B Mahol wrote:

Signed-off-by: Paul B Mahol 
---
  libavcodec/cfhdencdsp.c  |   3 +
  libavcodec/x86/Makefile  |   2 +
  libavcodec/x86/cfhdencdsp.asm| 431 +++
  libavcodec/x86/cfhdencdsp_init.c |  48 
  4 files changed, 484 insertions(+)
  create mode 100644 libavcodec/x86/cfhdencdsp.asm
  create mode 100644 libavcodec/x86/cfhdencdsp_init.c

diff --git a/libavcodec/cfhdencdsp.c b/libavcodec/cfhdencdsp.c
index 0becb76d1d..b979e9e09a 100644
--- a/libavcodec/cfhdencdsp.c
+++ b/libavcodec/cfhdencdsp.c
@@ -73,4 +73,7 @@ av_cold void ff_cfhdencdsp_init(CFHDEncDSPContext *c)
  {
  c->horiz_filter = horiz_filter;
  c->vert_filter = vert_filter;
+
+if (ARCH_X86)
+ff_cfhdencdsp_init_x86(c);
  }
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 884dc0c759..6361161180 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -51,6 +51,7 @@ OBJS-$(CONFIG_ALAC_DECODER)+= x86/alacdsp_init.o
  OBJS-$(CONFIG_APNG_DECODER)+= x86/pngdsp_init.o
  OBJS-$(CONFIG_CAVS_DECODER)+= x86/cavsdsp.o
  OBJS-$(CONFIG_CFHD_DECODER)+= x86/cfhddsp_init.o
+OBJS-$(CONFIG_CFHD_ENCODER)+= x86/cfhdencdsp_init.o
  OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o 
x86/synth_filter_init.o
  OBJS-$(CONFIG_DNXHD_ENCODER)   += x86/dnxhdenc_init.o
  OBJS-$(CONFIG_EXR_DECODER) += x86/exrdsp_init.o
@@ -154,6 +155,7 @@ X86ASM-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp.o
  X86ASM-OBJS-$(CONFIG_ALAC_DECODER) += x86/alacdsp.o
  X86ASM-OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp.o
  X86ASM-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsidct.o
+X86ASM-OBJS-$(CONFIG_CFHD_ENCODER) += x86/cfhdencdsp.o
  X86ASM-OBJS-$(CONFIG_CFHD_DECODER) += x86/cfhddsp.o
  X86ASM-OBJS-$(CONFIG_DCA_DECODER)  += x86/dcadsp.o x86/synth_filter.o
  X86ASM-OBJS-$(CONFIG_DIRAC_DECODER)+= x86/diracdsp.o\
diff --git a/libavcodec/x86/cfhdencdsp.asm b/libavcodec/x86/cfhdencdsp.asm
new file mode 100644
index 00..be51c77c46
--- /dev/null
+++ b/libavcodec/x86/cfhdencdsp.asm
@@ -0,0 +1,431 @@
+;**
+;* x86-optimized functions for the CFHD encoder
+;* Copyright (c) 2021 Paul B Mahol
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;**
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+pw_p1_n1:  dw  1, -1, 1, -1, 1, -1, 1, -1
+pw_n1_p1:  dw  -1, 1, -1, 1, -1, 1, -1, 1
+pw_p5_n11: dw  5, -11, 5, -11, 5, -11, 5, -11
+pw_n5_p11: dw -5, 11, -5, 11, -5, 11, -5, 11
+pw_p11_n5: dw 11, -5, 11, -5, 11, -5, 11, -5
+pw_n11_p5: dw -11, 5, -11, 5, -11, 5, -11, 5
+pd_4:  times 4 dd  4
+pw_n4: times 8 dw -4
+pw_n1: times 8 dw -1


cextern pw_m1


+cextern pw_1
+cextern pw_4
+
+SECTION .text
+
+%if ARCH_X86_64
+INIT_XMM sse2
+cglobal cfhdenc_horiz_filter, 8, 10, 11, input, low, high, istride, lwidth, 
hwidth, width, y, x, temp
+shl  istrided, 1
+shl   lwidthd, 1
+shl   hwidthd, 1


These are ptrdiff_t, so you can use the q suffix just fine.


+mova   m7, [pd_4]
+mova   m8, [pw_1]
+mova   m9, [pw_n1]
+mova   m10,[pw_p1_n1]
+negyq


This one is int, so:

movsxdifnidn yq, yd
neg  yq


+.looph:
+movsx  xq, word [inputq]
+
+movsx   tempq, word [inputq + 2]
+add tempq, xq
+
+movd  xm0, tempd
+packssdw   m0, m0
+pextrw  tempd, xm0, 0


movd tempd, m0

There's no reason to use pextrw if you're going to read only 16 bits 
right below, then discard the value.



+mov   word [lowq], tempw
+
+movsx  xq, word [inputq]
+imul   xq, 5
+movsx   tempq, word [inputq + 2]
+imultempq, -11
+add tempq, xq
+
+movsx  xq, word [inputq + 4]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 6]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 8]
+imul   xq, -1
+add tempq, xq
+
+movsx  

[FFmpeg-devel] [PATCH 1] avcodec/x86: add cfhdenc SIMD

2021-02-26 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/cfhdencdsp.c  |   3 +
 libavcodec/x86/Makefile  |   2 +
 libavcodec/x86/cfhdencdsp.asm| 431 +++
 libavcodec/x86/cfhdencdsp_init.c |  48 
 4 files changed, 484 insertions(+)
 create mode 100644 libavcodec/x86/cfhdencdsp.asm
 create mode 100644 libavcodec/x86/cfhdencdsp_init.c

diff --git a/libavcodec/cfhdencdsp.c b/libavcodec/cfhdencdsp.c
index 0becb76d1d..b979e9e09a 100644
--- a/libavcodec/cfhdencdsp.c
+++ b/libavcodec/cfhdencdsp.c
@@ -73,4 +73,7 @@ av_cold void ff_cfhdencdsp_init(CFHDEncDSPContext *c)
 {
 c->horiz_filter = horiz_filter;
 c->vert_filter = vert_filter;
+
+if (ARCH_X86)
+ff_cfhdencdsp_init_x86(c);
 }
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 884dc0c759..6361161180 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -51,6 +51,7 @@ OBJS-$(CONFIG_ALAC_DECODER)+= x86/alacdsp_init.o
 OBJS-$(CONFIG_APNG_DECODER)+= x86/pngdsp_init.o
 OBJS-$(CONFIG_CAVS_DECODER)+= x86/cavsdsp.o
 OBJS-$(CONFIG_CFHD_DECODER)+= x86/cfhddsp_init.o
+OBJS-$(CONFIG_CFHD_ENCODER)+= x86/cfhdencdsp_init.o
 OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o 
x86/synth_filter_init.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += x86/dnxhdenc_init.o
 OBJS-$(CONFIG_EXR_DECODER) += x86/exrdsp_init.o
@@ -154,6 +155,7 @@ X86ASM-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp.o
 X86ASM-OBJS-$(CONFIG_ALAC_DECODER) += x86/alacdsp.o
 X86ASM-OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp.o
 X86ASM-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsidct.o
+X86ASM-OBJS-$(CONFIG_CFHD_ENCODER) += x86/cfhdencdsp.o
 X86ASM-OBJS-$(CONFIG_CFHD_DECODER) += x86/cfhddsp.o
 X86ASM-OBJS-$(CONFIG_DCA_DECODER)  += x86/dcadsp.o x86/synth_filter.o
 X86ASM-OBJS-$(CONFIG_DIRAC_DECODER)+= x86/diracdsp.o\
diff --git a/libavcodec/x86/cfhdencdsp.asm b/libavcodec/x86/cfhdencdsp.asm
new file mode 100644
index 00..be51c77c46
--- /dev/null
+++ b/libavcodec/x86/cfhdencdsp.asm
@@ -0,0 +1,431 @@
+;**
+;* x86-optimized functions for the CFHD encoder
+;* Copyright (c) 2021 Paul B Mahol
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;**
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+pw_p1_n1:  dw  1, -1, 1, -1, 1, -1, 1, -1
+pw_n1_p1:  dw  -1, 1, -1, 1, -1, 1, -1, 1
+pw_p5_n11: dw  5, -11, 5, -11, 5, -11, 5, -11
+pw_n5_p11: dw -5, 11, -5, 11, -5, 11, -5, 11
+pw_p11_n5: dw 11, -5, 11, -5, 11, -5, 11, -5
+pw_n11_p5: dw -11, 5, -11, 5, -11, 5, -11, 5
+pd_4:  times 4 dd  4
+pw_n4: times 8 dw -4
+pw_n1: times 8 dw -1
+cextern pw_1
+cextern pw_4
+
+SECTION .text
+
+%if ARCH_X86_64
+INIT_XMM sse2
+cglobal cfhdenc_horiz_filter, 8, 10, 11, input, low, high, istride, lwidth, 
hwidth, width, y, x, temp
+shl  istrided, 1
+shl   lwidthd, 1
+shl   hwidthd, 1
+mova   m7, [pd_4]
+mova   m8, [pw_1]
+mova   m9, [pw_n1]
+mova   m10,[pw_p1_n1]
+negyq
+.looph:
+movsx  xq, word [inputq]
+
+movsx   tempq, word [inputq + 2]
+add tempq, xq
+
+movd  xm0, tempd
+packssdw   m0, m0
+pextrw  tempd, xm0, 0
+mov   word [lowq], tempw
+
+movsx  xq, word [inputq]
+imul   xq, 5
+movsx   tempq, word [inputq + 2]
+imultempq, -11
+add tempq, xq
+
+movsx  xq, word [inputq + 4]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 6]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 8]
+imul   xq, -1
+add tempq, xq
+
+movsx  xq, word [inputq + 10]
+imul   xq, -1
+add tempq, xq
+
+add tempq, 4
+sar tempq, 3
+
+movd  xm0, tempd
+packssdw   m0, m0
+pextrw  tempd, xm0, 0
+mov  word [highq], tempw
+
+movxq, 2
+
+.loopw:
+movu   m0, [inputq + xq * 2]
+movu 

Re: [FFmpeg-devel] [PATCH v3] libsvtav1: Add logical_processors option

2021-02-26 Thread Christopher Degawa
> Maybe I am reading this wrong or not understanding but this says it is
> used for limiting threads and then in the next sentence says it does
> not limit threads?
>
> It is quite confusing.
>
it's confusing for me too, but the idea is that it doesn't set n threads,
but it can be used to make it so instead of t * nproc threads, you can make
it t * logical_processor amount of threads
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] libsvtav1: Add logical_processors option

2021-02-26 Thread Marvin Scholz



On 27 Feb 2021, at 1:00, Christopher Degawa wrote:


From: Christopher Degawa 

Used for limiting the size of memory buffers and threads for a target
logical processor count, but does not set thread affinity or limit the
amount of threads used, although thread affinities can be controlled
with an additional parameters, it is prefered to add them until
a svtav1-params option or similar is added

Signed-off-by: Christopher Degawa 
---
 doc/encoders.texi  | 5 +
 libavcodec/libsvtav1.c | 7 +++
 2 files changed, 12 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index c9c8785afb..e3b5ae8bab 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1795,6 +1795,11 @@ Set log2 of the number of rows of tiles to use 
(0-6).

 @item tile_columns
 Set log2 of the number of columns of tiles to use (0-4).

+@item logical_processors
+Number of logical processors to run the encoder on, threads are 
managed by the OS scheduler.
+Used for limiting the size of memory buffers and threads for a target 
logical processor count.

+Does not set thread affinity or limit threads.
+


Maybe I am reading this wrong or not understanding but this says it is
used for limiting threads and then in the next sentence says it does
not limit threads?

It is quite confusing.


 @end table

 @section libkvazaar
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index eb6043bcac..087b14099f 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -71,6 +71,8 @@ typedef struct SvtContext {

 int tile_columns;
 int tile_rows;
+
+unsigned logical_processors;
 } SvtContext;

 static const struct {
@@ -218,6 +220,8 @@ static int 
config_enc_params(EbSvtAv1EncConfiguration *param,

 param->tile_columns = svt_enc->tile_columns;
 param->tile_rows= svt_enc->tile_rows;

+param->logical_processors = svt_enc->logical_processors;
+
 return 0;
 }

@@ -533,6 +537,9 @@ static const AVOption options[] = {
 { "tile_columns", "Log2 of number of tile columns to use", 
OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
 { "tile_rows", "Log2 of number of tile rows to use", 
OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},


+{ "logical_processors", "Number of logical processors to run the 
encoder on, used to limit the size of memory buffers and threads 
used", OFFSET(logical_processors),

+  AV_OPT_TYPE_INT, { .i64 = 0 }, 0,  INT_MAX, VE },
+
 {NULL},
 };

--
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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v3] libsvtav1: Add logical_processors option

2021-02-26 Thread Christopher Degawa
From: Christopher Degawa 

Used for limiting the size of memory buffers and threads for a target
logical processor count, but does not set thread affinity or limit the
amount of threads used, although thread affinities can be controlled
with an additional parameters, it is prefered to add them until
a svtav1-params option or similar is added

Signed-off-by: Christopher Degawa 
---
 doc/encoders.texi  | 5 +
 libavcodec/libsvtav1.c | 7 +++
 2 files changed, 12 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index c9c8785afb..e3b5ae8bab 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1795,6 +1795,11 @@ Set log2 of the number of rows of tiles to use (0-6).
 @item tile_columns
 Set log2 of the number of columns of tiles to use (0-4).
 
+@item logical_processors
+Number of logical processors to run the encoder on, threads are managed by the 
OS scheduler.
+Used for limiting the size of memory buffers and threads for a target logical 
processor count.
+Does not set thread affinity or limit threads.
+
 @end table
 
 @section libkvazaar
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index eb6043bcac..087b14099f 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -71,6 +71,8 @@ typedef struct SvtContext {
 
 int tile_columns;
 int tile_rows;
+
+unsigned logical_processors;
 } SvtContext;
 
 static const struct {
@@ -218,6 +220,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 param->tile_columns = svt_enc->tile_columns;
 param->tile_rows= svt_enc->tile_rows;
 
+param->logical_processors = svt_enc->logical_processors;
+
 return 0;
 }
 
@@ -533,6 +537,9 @@ static const AVOption options[] = {
 { "tile_columns", "Log2 of number of tile columns to use", 
OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
 { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
 
+{ "logical_processors", "Number of logical processors to run the encoder 
on, used to limit the size of memory buffers and threads used", 
OFFSET(logical_processors),
+  AV_OPT_TYPE_INT, { .i64 = 0 }, 0,  INT_MAX, VE },
+
 {NULL},
 };
 
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH] avdevice: use av_gettime_relative() for elapsed time calculations

2021-02-26 Thread Marton Balint



On Fri, 19 Feb 2021, Marton Balint wrote:


av_gettime_relative() is using the monotonic clock therefore more suitable for
elapsed time calculations. Packet timestamps are still kept absolute, although
that should be configurable in the future.

Signed-off-by: Marton Balint 
---
libavdevice/bktr.c  | 4 ++--
libavdevice/fbdev_dec.c | 6 +++---
libavdevice/gdigrab.c   | 6 +++---
libavdevice/kmsgrab.c   | 5 +++--
libavdevice/xcbgrab.c   | 7 ---
5 files changed, 15 insertions(+), 13 deletions(-)


Will apply soon. BKTR is untested.

Regards,
Marton



diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 2601adbba8..0688028f90 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -225,14 +225,14 @@ static void bktr_getframe(uint64_t per_frame)
{
uint64_t curtime;

-curtime = av_gettime();
+curtime = av_gettime_relative();
if (!last_frame_time
|| ((last_frame_time + per_frame) > curtime)) {
if (!usleep(last_frame_time + per_frame + per_frame / 8 - curtime)) {
if (!nsignals)
av_log(NULL, AV_LOG_INFO,
   "SLEPT NO signals - %d microseconds late\n",
-   (int)(av_gettime() - last_frame_time - per_frame));
+   (int)(av_gettime_relative() - last_frame_time - 
per_frame));
}
}
nsignals = 0;
diff --git a/libavdevice/fbdev_dec.c b/libavdevice/fbdev_dec.c
index 6a51816868..586caeef88 100644
--- a/libavdevice/fbdev_dec.c
+++ b/libavdevice/fbdev_dec.c
@@ -157,11 +157,11 @@ static int fbdev_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
uint8_t *pin, *pout;

if (fbdev->time_frame == AV_NOPTS_VALUE)
-fbdev->time_frame = av_gettime();
+fbdev->time_frame = av_gettime_relative();

/* wait based on the frame rate */
while (1) {
-curtime = av_gettime();
+curtime = av_gettime_relative();
delay = fbdev->time_frame - curtime;
av_log(avctx, AV_LOG_TRACE,
"time_frame:%"PRId64" curtime:%"PRId64" delay:%"PRId64"\n",
@@ -186,7 +186,7 @@ static int fbdev_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
   "Error refreshing variable info: %s\n", 
av_err2str(AVERROR(errno)));
}

-pkt->pts = curtime;
+pkt->pts = av_gettime();

/* compute visible data offset */
pin = fbdev->data + fbdev->bytes_per_pixel * fbdev->varinfo.xoffset +
diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index f406fa..9b2c55fe90 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -394,7 +394,7 @@ gdigrab_read_header(AVFormatContext *s1)
gdigrab->header_size = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) +
   (bpp <= 8 ? (1 << bpp) : 0) * sizeof(RGBQUAD) /* 
palette size */;
gdigrab->time_base   = av_inv_q(gdigrab->framerate);
-gdigrab->time_frame  = av_gettime() / av_q2d(gdigrab->time_base);
+gdigrab->time_frame  = av_gettime_relative() / av_q2d(gdigrab->time_base);

gdigrab->hwnd   = hwnd;
gdigrab->source_hdc = source_hdc;
@@ -551,7 +551,7 @@ static int gdigrab_read_packet(AVFormatContext *s1, 
AVPacket *pkt)

/* wait based on the frame rate */
for (;;) {
-curtime = av_gettime();
+curtime = av_gettime_relative();
delay = time_frame * av_q2d(time_base) - curtime;
if (delay <= 0) {
if (delay < INT64_C(-100) * av_q2d(time_base)) {
@@ -568,7 +568,7 @@ static int gdigrab_read_packet(AVFormatContext *s1, 
AVPacket *pkt)

if (av_new_packet(pkt, file_size) < 0)
return AVERROR(ENOMEM);
-pkt->pts = curtime;
+pkt->pts = av_gettime();

/* Blit screen grab */
if (!BitBlt(dest_hdc, 0, 0,
diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
index 94e32b9cae..6cc305b16f 100644
--- a/libavdevice/kmsgrab.c
+++ b/libavdevice/kmsgrab.c
@@ -268,7 +268,7 @@ static int kmsgrab_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
int64_t now;
int err;

-now = av_gettime();
+now = av_gettime_relative();
if (ctx->frame_last) {
int64_t delay;
while (1) {
@@ -276,10 +276,11 @@ static int kmsgrab_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
if (delay <= 0)
break;
av_usleep(delay);
-now = av_gettime();
+now = av_gettime_relative();
}
}
ctx->frame_last = now;
+now = av_gettime();

plane = drmModeGetPlane(ctx->hwctx->fd, ctx->plane_id);
if (!plane) {
diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index be5d5ea2cf..9604a5aaf2 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -206,7 +206,7 @@ static int64_t wait_frame(AVFormatContext *s, AVPacket *pkt)
c->time_frame += c->frame_duration;

for (;;) {
-curtime = av_gettime();
+curtime = av_gettime_relative();
delay   = c->time_frame - curtime;
if (delay <= 0)
break;
@@ -422,7 +422,8 @@ static int 

Re: [FFmpeg-devel] [PATCH] avcodec/options: deprecate avcodec_get_frame_class()

2021-02-26 Thread James Almer

On 2/25/2021 5:37 PM, James Almer wrote:

AVFrame hasn't been a struct defined in libavcodec for a decade now, when
it was moved to libavutil.


Will apply.



Found-by: mkver
Signed-off-by: James Almer 
---
  libavcodec/avcodec.h | 8 
  libavcodec/options.c | 2 ++
  libavcodec/version.h | 3 +++
  3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ddca770cc4..f1380e0c4c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2770,13 +2770,13 @@ int avcodec_get_context_defaults3(AVCodecContext *s, 
const AVCodec *codec);
   */
  const AVClass *avcodec_get_class(void);
  
+#if FF_API_GET_FRAME_CLASS

  /**
- * Get the AVClass for AVFrame. It can be used in combination with
- * AV_OPT_SEARCH_FAKE_OBJ for examining options.
- *
- * @see av_opt_find().
+ * @deprecated This function should not be used.
   */
+attribute_deprecated
  const AVClass *avcodec_get_frame_class(void);
+#endif
  
  /**

   * Get the AVClass for AVSubtitleRect. It can be used in combination with
diff --git a/libavcodec/options.c b/libavcodec/options.c
index ff16e2cbfd..6e904b61d8 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -312,6 +312,7 @@ const AVClass *avcodec_get_class(void)
  return _codec_context_class;
  }
  
+#if FF_API_GET_FRAME_CLASS

  #define FOFFSET(x) offsetof(AVFrame,x)
  
  static const AVOption frame_options[]={

@@ -338,6 +339,7 @@ const AVClass *avcodec_get_frame_class(void)
  {
  return _frame_class;
  }
+#endif
  
  #define SROFFSET(x) offsetof(AVSubtitleRect,x)
  
diff --git a/libavcodec/version.h b/libavcodec/version.h

index e5a5ec8abc..2962d94df2 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -150,5 +150,8 @@
  #ifndef FF_API_DEBUG_MV
  #define FF_API_DEBUG_MV  (LIBAVCODEC_VERSION_MAJOR < 60)
  #endif
+#ifndef FF_API_GET_FRAME_CLASS
+#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60)
+#endif
  
  #endif /* AVCODEC_VERSION_H */




___
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] libavformat: add librist protocol

2021-02-26 Thread Marton Balint



On Fri, 26 Feb 2021, Paul B Mahol wrote:


This work is sponsored by Open Broadcast Systems.

Signed-off-by: Paul B Mahol 
---
configure   |   5 +
doc/protocols.texi  |  29 +
libavformat/Makefile|   1 +
libavformat/librist.c   | 248 
libavformat/protocols.c |   1 +
5 files changed, 284 insertions(+)
create mode 100644 libavformat/librist.c




+#define D AV_OPT_FLAG_DECODING_PARAM
+#define E AV_OPT_FLAG_ENCODING_PARAM
+#define OFFSET(x) offsetof(RISTContext, x)
+static const AVOption librist_options[] = {
+{ "rist_profile","set profile", OFFSET(profile), AV_OPT_TYPE_INT,   
{.i64=RIST_PROFILE_MAIN}, 0, 2, .flags = D|E, "profile" },
+{ "simple",  NULL,  0,   AV_OPT_TYPE_CONST, 
{.i64=RIST_PROFILE_SIMPLE},   0, 0, .flags = D|E, "profile" },
+{ "main",NULL,  0,   AV_OPT_TYPE_CONST, 
{.i64=RIST_PROFILE_MAIN}, 0, 0, .flags = D|E, "profile" },
+{ "advanced",NULL,  0,   AV_OPT_TYPE_CONST, 
{.i64=RIST_PROFILE_ADVANCED}, 0, 0, .flags = D|E, "profile" },
+{ "buffer_size", "set buffer_size", OFFSET(buffer_size), AV_OPT_TYPE_INT,  
 {.i64=0}, 0, INT_MAX, .flags = D|E },
+{ "log_level",   "set loglevel",OFFSET(log_level),   AV_OPT_TYPE_INT,  
 {.i64=-1},   -1, INT_MAX, .flags = D|E },
+{ "secret", "set encryption secret",OFFSET(secret),  
AV_OPT_TYPE_STRING,{.str=NULL},  0, 0,   .flags = D|E },
+{ "encryption","set encryption type",OFFSET(encryption), AV_OPT_TYPE_INT   
,{.i64=0}, 0, INT_MAX, .flags = D|E },


Why have you removed pkt_size? For writing, it is surely useful to be 
configurable, please put it back with -1 as default, so different default 
can be used for read and write. And for writing, the default of 1316 
should be used, as we typically want to pump mpegts into it, split on 
packet boundaries and want no fragmentation.



+static int librist_open(URLContext *h, const char *uri, int flags)
+{
+RISTContext *s = h->priv_data;
+struct rist_logging_settings *logging_settings = >logging_settings;
+struct rist_peer_config *peer_config = >peer_config;
+int ret;
+
+if ((flags & (AVIO_FLAG_WRITE | AVIO_FLAG_READ)) == (AVIO_FLAG_WRITE | 
AVIO_FLAG_READ))
+return AVERROR(EINVAL);


AVIO_FLAG_READ_WRITE


+
+return risterr2ret(ret);
+}
+
+static int librist_read(URLContext *h, uint8_t *buf, int size)
+{
+RISTContext *s = h->priv_data;
+int available_size = size;
+int queue_size = 0;
+int offset = 0;
+
+do {
+const struct rist_data_block *data_block;
+int ret;
+
+ret = rist_receiver_data_read(s->ctx, _block, offset == 0 ? 
POLLING_TIME : 0);
+if (ret < 0)
+return risterr2ret(ret);
+
+if (ret == 0 || data_block->payload_len <= 0)
+break;
+
+queue_size = ret;
+av_assert0(data_block->payload_len <= available_size);
+
+size = FFMIN(available_size, data_block->payload_len);
+memcpy(buf + offset, data_block->payload, size);
+offset += size;
+available_size -= size;
+rist_receiver_data_block_free((struct rist_data_block**)_block);
+queue_size--;


No, read one packet in one read call, do not merge packets. Protocols 
don't merge packets. UDP does not merge packets. If this is some 
workaround for librist dropping packets then figure out the bug causing 
that. If UDP works, librist should work too, even without merging packets.


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

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

[FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-26 Thread Paul B Mahol
This work is sponsored by Open Broadcast Systems.

Signed-off-by: Paul B Mahol 
---
 configure   |   5 +
 doc/protocols.texi  |  29 +
 libavformat/Makefile|   1 +
 libavformat/librist.c   | 248 
 libavformat/protocols.c |   1 +
 5 files changed, 284 insertions(+)
 create mode 100644 libavformat/librist.c

diff --git a/configure b/configure
index d11942fced..378b1e0cc2 100755
--- a/configure
+++ b/configure
@@ -259,6 +259,7 @@ External library support:
   --enable-libpulseenable Pulseaudio input via libpulse [no]
   --enable-librabbitmq enable RabbitMQ library [no]
   --enable-librav1eenable AV1 encoding via rav1e [no]
+  --enable-librist enable RIST via librist [no]
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
   --enable-librtmp enable RTMP[E] support via librtmp [no]
@@ -1797,6 +1798,7 @@ EXTERNAL_LIBRARY_LIST="
 libpulse
 librabbitmq
 librav1e
+librist
 librsvg
 librtmp
 libshine
@@ -3490,6 +3492,8 @@ unix_protocol_select="network"
 # external library protocols
 libamqp_protocol_deps="librabbitmq"
 libamqp_protocol_select="network"
+librist_protocol_deps="librist"
+librist_protocol_select="network"
 librtmp_protocol_deps="librtmp"
 librtmpe_protocol_deps="librtmp"
 librtmps_protocol_deps="librtmp"
@@ -6409,6 +6413,7 @@ enabled libopus   && {
 enabled libpulse  && require_pkg_config libpulse libpulse 
pulse/pulseaudio.h pa_context_new
 enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq >= 
0.7.1" amqp.h amqp_new_connection
 enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.4.0" 
rav1e.h rav1e_context_new
+enabled librist   && require_pkg_config librist "librist >= 0.2" 
librist/librist.h rist_receiver_create
 enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp   && require_pkg_config librtmp librtmp librtmp/rtmp.h 
RTMP_Socket
 enabled librubberband && require_pkg_config librubberband "rubberband >= 
1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
librubberband_extralibs "-lstdc++"
diff --git a/doc/protocols.texi b/doc/protocols.texi
index c0b511b7a4..11fb351bf6 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -690,6 +690,35 @@ Example usage:
 -f rtp_mpegts -fec prompeg=l=8:d=4 rtp://@var{hostname}:@var{port}
 @end example
 
+@section rist
+
+Reliable Internet Streaming Transport protocol
+
+The accepted options are:
+@table @option
+@item rist_profile
+Supported values:
+@table @samp
+@item simple
+@item main
+This one is default.
+@item advanced
+@end table
+
+@item buffer_size
+Set internal RIST buffer size for retransmission of data.
+
+@item log_level
+Set loglevel for RIST logging messages.
+
+@item secret
+Set override of encryption secret, by default is unset.
+
+@item encryption
+Set encryption type, by default is disabled.
+Acceptable values are 128 and 256.
+@end table
+
 @section rtmp
 
 Real-Time Messaging Protocol.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 56fa96ea7f..95ed25e866 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -654,6 +654,7 @@ OBJS-$(CONFIG_UNIX_PROTOCOL) += unix.o
 
 # external library protocols
 OBJS-$(CONFIG_LIBAMQP_PROTOCOL)  += libamqp.o
+OBJS-$(CONFIG_LIBRIST_PROTOCOL)  += librist.o
 OBJS-$(CONFIG_LIBRTMP_PROTOCOL)  += librtmp.o
 OBJS-$(CONFIG_LIBRTMPE_PROTOCOL) += librtmp.o
 OBJS-$(CONFIG_LIBRTMPS_PROTOCOL) += librtmp.o
diff --git a/libavformat/librist.c b/libavformat/librist.c
new file mode 100644
index 00..f2b17b946b
--- /dev/null
+++ b/libavformat/librist.c
@@ -0,0 +1,248 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Reliable Internet Streaming Transport protocol
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/time.h"
+
+#include "avformat.h"
+#include "internal.h"
+#include "network.h"
+#include "os_support.h"
+#include "url.h"
+

Re: [FFmpeg-devel] [PATCH v5 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-26 Thread Jan Ekström
On Fri, Feb 26, 2021 at 9:00 PM Jan Ekström  wrote:
>
> On Fri, Feb 26, 2021 at 7:54 PM Michael Niedermayer
>  wrote:
> >
> > On Mon, Feb 22, 2021 at 03:19:11PM +0200, Jan Ekström wrote:
> > > From: Stefano Sabatini 
> > >
> > > Base escaping only escapes values required for base character data
> > > according to part 2.4 of XML, and if additional flags are added
> > > single and double quotes can additionally be escaped in order
> > > to handle single and double quoted attributes.
> > > ---
> > >  libavutil/avstring.h | 14 ++
> > >  libavutil/bprint.c   | 29 +
> > >  libavutil/version.h  |  2 +-
> > >  tools/ffescape.c |  7 +--
> > >  4 files changed, 49 insertions(+), 3 deletions(-)
> >
> > breaks: tools/ffescape.o
> >
> > CC  tools/ffescape.o
> > tools/ffescape.c: In function ‘main’:
> > tools/ffescape.c:83:59: error: expected ‘)’ before ‘escape_flags’
> >  else if (!strcmp(optarg, "xml_single_quotes") escape_flags |= 
> > AV_ESCAPE_FLAG_XML_SINGLE_QUOTES);
> >^~~~
> > tools/ffescape.c:84:59: error: expected ‘)’ before ‘escape_flags’
> >  else if (!strcmp(optarg, "xml_double_quotes") escape_flags |= 
> > AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
> >^~~~
> > ffbuild/common.mak:67: recipe for target 'tools/ffescape.o' failed
> > make: *** [tools/ffescape.o] Error 1
>
> OK, sorry. That is a clear mistake yet I somehow thought that was
> built by default and thus it was OK :/
>
> Will fix.
>

Is now fixed as:

diff --git a/tools/ffescape.c b/tools/ffescape.c
index 0530d28c6d..1ed8daa801 100644
--- a/tools/ffescape.c
+++ b/tools/ffescape.c
@@ -78,8 +78,10 @@ int main(int argc, char **argv)
 infilename = optarg;
 break;
 case 'f':
-if  (!strcmp(optarg, "whitespace")) escape_flags |=
AV_ESCAPE_FLAG_WHITESPACE;
-else if (!strcmp(optarg, "strict")) escape_flags |=
AV_ESCAPE_FLAG_STRICT;
+if  (!strcmp(optarg, "whitespace"))
escape_flags |= AV_ESCAPE_FLAG_WHITESPACE;
+else if (!strcmp(optarg, "strict"))
escape_flags |= AV_ESCAPE_FLAG_STRICT;
+else if (!strcmp(optarg, "xml_single_quotes"))
escape_flags |= AV_ESCAPE_FLAG_XML_SINGLE_QUOTES;
+else if (!strcmp(optarg, "xml_double_quotes"))
escape_flags |= AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES;
 else {
 av_log(NULL, AV_LOG_ERROR,
"Invalid value '%s' for option -f, "
@@ -104,6 +106,7 @@ int main(int argc, char **argv)
 if  (!strcmp(optarg, "auto"))  escape_mode =
AV_ESCAPE_MODE_AUTO;
 else if (!strcmp(optarg, "backslash")) escape_mode =
AV_ESCAPE_MODE_BACKSLASH;
 else if (!strcmp(optarg, "quote")) escape_mode =
AV_ESCAPE_MODE_QUOTE;
+else if (!strcmp(optarg, "xml"))   escape_mode =
AV_ESCAPE_MODE_XML;
 else {
 av_log(NULL, AV_LOG_ERROR,
"Invalid value '%s' for option -m, "
___
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 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-26 Thread Jan Ekström
On Fri, Feb 26, 2021 at 7:54 PM Michael Niedermayer
 wrote:
>
> On Mon, Feb 22, 2021 at 03:19:11PM +0200, Jan Ekström wrote:
> > From: Stefano Sabatini 
> >
> > Base escaping only escapes values required for base character data
> > according to part 2.4 of XML, and if additional flags are added
> > single and double quotes can additionally be escaped in order
> > to handle single and double quoted attributes.
> > ---
> >  libavutil/avstring.h | 14 ++
> >  libavutil/bprint.c   | 29 +
> >  libavutil/version.h  |  2 +-
> >  tools/ffescape.c |  7 +--
> >  4 files changed, 49 insertions(+), 3 deletions(-)
>
> breaks: tools/ffescape.o
>
> CC  tools/ffescape.o
> tools/ffescape.c: In function ‘main’:
> tools/ffescape.c:83:59: error: expected ‘)’ before ‘escape_flags’
>  else if (!strcmp(optarg, "xml_single_quotes") escape_flags |= 
> AV_ESCAPE_FLAG_XML_SINGLE_QUOTES);
>^~~~
> tools/ffescape.c:84:59: error: expected ‘)’ before ‘escape_flags’
>  else if (!strcmp(optarg, "xml_double_quotes") escape_flags |= 
> AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
>^~~~
> ffbuild/common.mak:67: recipe for target 'tools/ffescape.o' failed
> make: *** [tools/ffescape.o] Error 1

OK, sorry. That is a clear mistake yet I somehow thought that was
built by default and thus it was OK :/

Will fix.

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 3/5] tests/api-flac-test: convert to new encoding/decoding API

2021-02-26 Thread James Almer

On 2/24/2021 7:04 AM, Anton Khirnov wrote:

---
  tests/api/api-flac-test.c | 40 +--
  1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 7c96a4d99e..3d83c56987 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -113,7 +113,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
  uint8_t *raw_in = NULL, *raw_out = NULL;
  int in_offset = 0, out_offset = 0;
  int result = 0;
-int got_output = 0;
  int i = 0;
  int in_frame_bytes, out_frame_bytes;
  
@@ -167,25 +166,40 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,

  }
  memcpy(raw_in + in_offset, in_frame->data[0], in_frame_bytes);
  in_offset += in_frame_bytes;
-result = avcodec_encode_audio2(enc_ctx, _pkt, in_frame, 
_output);
+result = avcodec_send_frame(enc_ctx, in_frame);
  if (result < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
+av_log(NULL, AV_LOG_ERROR, "Error submitting a frame for 
encoding\n");
  return result;
  }
  
-/* if we get an encoded packet, feed it straight to the decoder */

-if (got_output) {
-result = avcodec_decode_audio4(dec_ctx, out_frame, _output, 
_pkt);
+while (result >= 0) {
+result = avcodec_receive_packet(enc_ctx, _pkt);
+if (result == AVERROR(EAGAIN))
+break;
+else if (result < 0 && result != AVERROR_EOF) {
+av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
+return result;
+}
+
+/* if we get an encoded packet, feed it straight to the decoder */
+result = avcodec_send_packet(dec_ctx, _pkt);
+av_packet_unref(_pkt);
  if (result < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n");
+av_log(NULL, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
  return result;
  }
  
-if (got_output) {

-if (result != enc_pkt.size) {
-av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a 
packet, it is allowed to do so -- need to update this test\n");
-return AVERROR_UNKNOWN;
-}
+result = avcodec_receive_frame(dec_ctx, out_frame);
+if (result == AVERROR(EAGAIN)) {
+result = 0;
+continue;
+} else if (result == AVERROR(EOF)) {
+result = 0;
+break;
+} else if (result < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n");
+return result;
+}
  
  if (in_frame->nb_samples != out_frame->nb_samples) {

  av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different number of samples\n");
@@ -208,9 +222,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
  }
  memcpy(raw_out + out_offset, out_frame->data[0], 
out_frame_bytes);
  out_offset += out_frame_bytes;
-}
  }
-av_packet_unref(_pkt);
  }
  
  if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_AUDIO_FRAMES) != 0) {


LGTM.

Also, FWIW, this is not flushing the encoder (It wasn't before this 
patch either). For being an API test it's not exactly using it right, 
but it doesn't really matter here since for FLAC, flushing the encoder 
will return a side data only packet with an updated stream header info 
and not any delayed/buffered packet, and this test only cares about 
comparing the raw pcm audio pre encoding and post decoding.

___
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] tests/api-flac-test: reindent

2021-02-26 Thread James Almer

On 2/24/2021 7:04 AM, Anton Khirnov wrote:

---
  tests/api/api-flac-test.c | 42 +++
  1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 3d83c56987..b67c3d7363 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -201,27 +201,27 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
  return result;
  }
  
-if (in_frame->nb_samples != out_frame->nb_samples) {

-av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different number of samples\n");
-return AVERROR_UNKNOWN;
-}
-
-if (in_frame->channel_layout != out_frame->channel_layout) {
-av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different channel layout\n");
-return AVERROR_UNKNOWN;
-}
-
-if (in_frame->format != out_frame->format) {
-av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different sample format\n");
-return AVERROR_UNKNOWN;
-}
-out_frame_bytes = out_frame->nb_samples * out_frame->channels 
* sizeof(uint16_t);
-if (out_frame_bytes > out_frame->linesize[0]) {
-av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame 
linesize\n");
-return 1;
-}
-memcpy(raw_out + out_offset, out_frame->data[0], 
out_frame_bytes);
-out_offset += out_frame_bytes;
+if (in_frame->nb_samples != out_frame->nb_samples) {
+av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding 
has different number of samples\n");
+return AVERROR_UNKNOWN;
+}
+
+if (in_frame->channel_layout != out_frame->channel_layout) {
+av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding 
has different channel layout\n");
+return AVERROR_UNKNOWN;
+}
+
+if (in_frame->format != out_frame->format) {
+av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding 
has different sample format\n");
+return AVERROR_UNKNOWN;
+}
+out_frame_bytes = out_frame->nb_samples * out_frame->channels * 
sizeof(uint16_t);
+if (out_frame_bytes > out_frame->linesize[0]) {
+av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame 
linesize\n");
+return 1;
+}
+memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes);
+out_offset += out_frame_bytes;
  }
  }


Trivial, so LGTM.
___
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 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-26 Thread Michael Niedermayer
On Mon, Feb 22, 2021 at 03:19:11PM +0200, Jan Ekström wrote:
> From: Stefano Sabatini 
> 
> Base escaping only escapes values required for base character data
> according to part 2.4 of XML, and if additional flags are added
> single and double quotes can additionally be escaped in order
> to handle single and double quoted attributes.
> ---
>  libavutil/avstring.h | 14 ++
>  libavutil/bprint.c   | 29 +
>  libavutil/version.h  |  2 +-
>  tools/ffescape.c |  7 +--
>  4 files changed, 49 insertions(+), 3 deletions(-)

breaks: tools/ffescape.o

CC  tools/ffescape.o
tools/ffescape.c: In function ‘main’:
tools/ffescape.c:83:59: error: expected ‘)’ before ‘escape_flags’
 else if (!strcmp(optarg, "xml_single_quotes") escape_flags |= 
AV_ESCAPE_FLAG_XML_SINGLE_QUOTES);
   ^~~~
tools/ffescape.c:84:59: error: expected ‘)’ before ‘escape_flags’
 else if (!strcmp(optarg, "xml_double_quotes") escape_flags |= 
AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
   ^~~~
ffbuild/common.mak:67: recipe for target 'tools/ffescape.o' failed
make: *** [tools/ffescape.o] Error 1


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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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 6/6] avformat: Deprecate AVFMT_FLAG_PRIV_OPT, remove av_demuxer_open on bump

2021-02-26 Thread Andreas Rheinhardt
This flag was added in 492026209b9b58eaf6d2ea56423f6b1e1a8a76a5
in conjunction with av_demuxer_open() to allow to pass private
options to demuxers. It worked as follows: av_open_input_stream()
(the predecessor of avformat_open_input()) would not call the
read_header function if this flag is set. Instead the user could set
private options of the demuxer via the format's private class after
avformat_open_input() and then call av_demuxer_open() which called
the format's read_header function.

This approach was abandoned in e37f161e66e042d6c2c7470c4d9881df9427fc4a
and av_demuxer_open() deprecated; instead the AVDictionary based way of
passing private options to the demuxer was choosen. Yet
AVFMT_FLAG_PRIV_OPT has never been deprecated and av_demuxer_open()
never removed. This commit implements the deprecation of the flag and
schedules av_demuxer_open for removal on the next major bump.
Given that av_demuxer_open() has been deprecated in 2012 and that this
flag is useless without it, the flag will be ignored after the next
major version bump.

Signed-off-by: Andreas Rheinhardt 
---
 doc/APIchanges |  4 
 libavformat/avformat.h |  9 -
 libavformat/utils.c| 12 ++--
 libavformat/version.h  |  8 +++-
 4 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 33be750af2..baa2b24daf 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2021-02-26 - xx - lavf 58.69.100 - avformat.h
+  Deprecate AVFMT_FLAG_PRIV_OPT. It will do nothing
+  as soon as av_demuxer_open() is removed.
+
 2021-02-21 - xx - lavu 56.66.100 - tx.h
   Add enum AVTXFlags and AVTXFlags.AV_TX_INPLACE
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 41482328f6..7da2f3d98e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1379,7 +1379,9 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_MP4A_LATM0x8000 ///< Deprecated, does nothing.
 #endif
 #define AVFMT_FLAG_SORT_DTS0x1 ///< try to interleave outputted 
packets by dts (using this flag can slow demuxing down)
-#define AVFMT_FLAG_PRIV_OPT0x2 ///< Enable use of private options by 
delaying codec open (this could be made default once all code is converted)
+#if FF_API_LAVF_PRIV_OPT
+#define AVFMT_FLAG_PRIV_OPT0x2 ///< Enable use of private options by 
delaying codec open (deprecated, will do nothing once av_demuxer_open() is 
removed)
+#endif
 #if FF_API_LAVF_KEEPSIDE_FLAG
 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x4 ///< Deprecated, does nothing.
 #endif
@@ -2210,8 +2212,13 @@ int av_probe_input_buffer(AVIOContext *pb, ff_const59 
AVInputFormat **fmt,
  */
 int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 
AVInputFormat *fmt, AVDictionary **options);
 
+#if FF_API_DEMUXER_OPEN
+/**
+ * @deprecated Use an AVDictionary to pass options to a demuxer.
+ */
 attribute_deprecated
 int av_demuxer_open(AVFormatContext *ic);
+#endif
 
 /**
  * Read packets of a media file to get stream information. This
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6e92bd777a..36164e0f0d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -392,6 +392,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 //
 /* input media file */
 
+#if FF_API_DEMUXER_OPEN
 int av_demuxer_open(AVFormatContext *ic) {
 int err;
 
@@ -411,7 +412,7 @@ int av_demuxer_open(AVFormatContext *ic) {
 
 return 0;
 }
-
+#endif
 /* Open input file and probe the format if necessary. */
 static int init_input(AVFormatContext *s, const char *filename,
   AVDictionary **options)
@@ -594,8 +595,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (s->pb)
 ff_id3v2_read_dict(s->pb, >internal->id3v2_meta, 
ID3v2_DEFAULT_MAGIC, _extra_meta);
 
-
+#if FF_API_DEMUXER_OPEN
 if (!(s->flags_FLAG_PRIV_OPT) && s->iformat->read_header)
+#else
+if (s->iformat->read_header)
+#endif
 if ((ret = s->iformat->read_header(s)) < 0)
 goto fail;
 
@@ -624,7 +628,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if ((ret = avformat_queue_attached_pictures(s)) < 0)
 goto close;
 
+#if FF_API_DEMUXER_OPEN
 if (!(s->flags_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
+#else
+if (s->pb && !s->internal->data_offset)
+#endif
 s->internal->data_offset = avio_tell(s->pb);
 
 s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
diff --git a/libavformat/version.h b/libavformat/version.h
index c11d885b83..7d16c4d6a5 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  68
+#define LIBAVFORMAT_VERSION_MINOR  

Re: [FFmpeg-devel] [PATCH 5/5] lavc: remove tests/options

2021-02-26 Thread Andreas Rheinhardt
Anton Khirnov:
> It tests deprecated avcodec_copy_context().
> ---
>  libavcodec/Makefile|   1 -
>  libavcodec/tests/options.c | 194 -
>  tests/fate/libavcodec.mak  |   4 -
>  3 files changed, 199 deletions(-)
>  delete mode 100644 libavcodec/tests/options.c
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index b46c1688cc..097e7ecd5a 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1220,7 +1220,6 @@ TESTPROGS = avpacket
> \
>  imgconvert  \
>  jpeg2000dwt \
>  mathops\
> -options \
>  mjpegenc_huffman\
>  utils   \
>  
> diff --git a/libavcodec/tests/options.c b/libavcodec/tests/options.c
> deleted file mode 100644
> index 010e3c0145..00
> --- a/libavcodec/tests/options.c
> +++ /dev/null
> @@ -1,194 +0,0 @@
> -/*
> - * Copyright (c) 2001 Fabrice Bellard
> - * Copyright (c) 2002-2004 Michael Niedermayer 
> - *
> - * This file is part of FFmpeg.
> - *
> - * FFmpeg is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2.1 of the License, or (at your option) any later version.
> - *
> - * FFmpeg is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with FFmpeg; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> - */
> -
> -#include "libavcodec/options.c"
> -
> -static int dummy_init(AVCodecContext *ctx)
> -{
> -//TODO: this code should set every possible pointer that could be set by 
> codec and is not an option;
> -ctx->extradata_size = 8;
> -ctx->extradata = av_malloc(ctx->extradata_size);
> -return 0;
> -}
> -
> -static int dummy_close(AVCodecContext *ctx)
> -{
> -av_freep(>extradata);
> -ctx->extradata_size = 0;
> -return 0;
> -}
> -
> -static int dummy_encode(AVCodecContext *ctx, AVPacket *pkt, const AVFrame 
> *frame, int *got_packet)
> -{
> -return AVERROR(ENOSYS);
> -}
> -
> -typedef struct Dummy12Context {
> -AVClass  *av_class;
> -int  num;
> -char*str;
> -} Dummy12Context;
> -
> -typedef struct Dummy3Context {
> -void *fake_av_class;
> -int  num;
> -char*str;
> -} Dummy3Context;
> -
> -#define OFFSET(x) offsetof(Dummy12Context, x)
> -#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> -static const AVOption dummy_options[] = {
> -{ "str", "set str", OFFSET(str), AV_OPT_TYPE_STRING, { .str = "i'm src 
> default value" }, 0, 0, VE},
> -{ "num", "set num", OFFSET(num), AV_OPT_TYPE_INT,{ .i64 = 1500100900 
> },0, INT_MAX, VE},
> -{ NULL },
> -};
> -
> -static const AVClass dummy_v1_class = {
> -.class_name = "dummy_v1_class",
> -.item_name  = av_default_item_name,
> -.option = dummy_options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> -
> -static const AVClass dummy_v2_class = {
> -.class_name = "dummy_v2_class",
> -.item_name  = av_default_item_name,
> -.option = dummy_options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> -
> -/* codec with options */
> -static AVCodec dummy_v1_encoder = {
> -.name = "dummy_v1_codec",
> -.type = AVMEDIA_TYPE_VIDEO,
> -.id   = AV_CODEC_ID_NONE - 1,
> -.encode2  = dummy_encode,
> -.init = dummy_init,
> -.close= dummy_close,
> -.priv_class   = _v1_class,
> -.priv_data_size   = sizeof(Dummy12Context),
> -};
> -
> -/* codec with options, different class */
> -static AVCodec dummy_v2_encoder = {
> -.name = "dummy_v2_codec",
> -.type = AVMEDIA_TYPE_VIDEO,
> -.id   = AV_CODEC_ID_NONE - 2,
> -.encode2  = dummy_encode,
> -.init = dummy_init,
> -.close= dummy_close,
> -.priv_class   = _v2_class,
> -.priv_data_size   = sizeof(Dummy12Context),
> -};
> -
> -/* codec with priv data, but no class */
> -static AVCodec dummy_v3_encoder = {
> -.name = "dummy_v3_codec",
> -.type = AVMEDIA_TYPE_VIDEO,
> -.id   = AV_CODEC_ID_NONE - 3,
> -.encode2  = dummy_encode,
> -.init  

Re: [FFmpeg-devel] [PATCH 2/5] avcodec: Add missing FF_API define for libavcodec pix fmt API

2021-02-26 Thread James Almer

On 2/26/2021 10:18 AM, Andreas Rheinhardt wrote:

avcodec_find_best_pix_fmt2 has been deprecated and replaced by
avcodec_find_best_pix_fmt_of_2 in 2a54ae9df8cbc1717b3929222ac75f384e2ff240.
avcodec_find_best_pix_fmt_of_2 and avcodec_get_pix_fmt_loss meanwhile
were deprecated in 617e866e25b72fa5d9f9d6bbcbd7e4bd69e63a54 when these
functions were de facto moved to libavutil; this has been mentioned in
APIchanges in f7a1c5e4d2294a8970ede7f6deb2fe0a64e202a5. Yet the
attribute_deprecated was never set for the latter two functions and they
were not wrapped in an FF_API define. This commit does this.

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/avcodec.h| 15 +--
  libavcodec/imgconvert.c |  6 --
  libavcodec/version.h|  3 +++
  3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3d77d2f6fd..3178c163b9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3786,12 +3786,6 @@ void avcodec_get_chroma_sub_sample(enum AVPixelFormat 
pix_fmt, int *h_shift, int
   */
  unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
  
-/**

- * @deprecated see av_get_pix_fmt_loss()
- */
-int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum 
AVPixelFormat src_pix_fmt,
- int has_alpha);
-
  /**
   * Find the best pixel format to convert to given a certain source pixel
   * format.  When converting from one pixel format to another, information loss
@@ -3813,15 +3807,24 @@ enum AVPixelFormat 
avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p
  enum AVPixelFormat src_pix_fmt,
  int has_alpha, int *loss_ptr);
  
+#if FF_API_AVCODEC_PIX_FMT

+/**
+ * @deprecated see av_get_pix_fmt_loss()
+ */
+attribute_deprecated
+int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum 
AVPixelFormat src_pix_fmt,
+ int has_alpha);
  /**
   * @deprecated see av_find_best_pix_fmt_of_2()
   */
+attribute_deprecated
  enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat 
dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  enum AVPixelFormat src_pix_fmt, 
int has_alpha, int *loss_ptr);
  
  attribute_deprecated

  enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat 
dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  enum AVPixelFormat src_pix_fmt, 
int has_alpha, int *loss_ptr);
+#endif
  
  enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
  
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c

index 1fd636c83d..8de1563404 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -44,6 +44,7 @@ void avcodec_get_chroma_sub_sample(enum AVPixelFormat 
pix_fmt, int *h_shift, int
  }
  #endif
  
+#if FF_API_AVCODEC_PIX_FMT

  int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
   enum AVPixelFormat src_pix_fmt,
   int has_alpha)
@@ -60,9 +61,10 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum 
AVPixelFormat dst_pix_fmt
  enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat 
dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  enum AVPixelFormat src_pix_fmt, 
int has_alpha, int *loss_ptr)
  {
-return avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, 
src_pix_fmt, has_alpha, loss_ptr);
+return av_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, 
has_alpha, loss_ptr);
  }
  
+#endif

  enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat 
*pix_fmt_list,
  enum AVPixelFormat src_pix_fmt,
  int has_alpha, int *loss_ptr){
@@ -73,7 +75,7 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const 
enum AVPixelFormat *p
  
  for (i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++) {

  loss = loss_ptr ? *loss_ptr : 0;
-best = avcodec_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, 
has_alpha, );
+best = av_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, 
has_alpha, );
  }
  
  if (loss_ptr)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index e5a5ec8abc..516411b4b2 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -144,6 +144,9 @@
  #ifndef FF_API_OLD_ENCDEC
  #define FF_API_OLD_ENCDEC  (LIBAVCODEC_VERSION_MAJOR < 59)
  #endif
+#ifndef FF_API_AVCODEC_PIX_FMT
+#define FF_API_AVCODEC_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 59)


Ok, since this was mentioned in APIChanges, i guess < 59 is ok despite 
the missing function prototype attribute. But if i were to guess, most 
API users will pay more attention to compiler warnings rather than 

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/mpegvideo: Schedule unused, deprecated rc_strategy for removal

2021-02-26 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/5] avcodec: Add missing FF_API define for libavcodec pix fmt API

2021-02-26 Thread Paul B Mahol
lgtm
___
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/5] fftools/ffmpeg_filter: Don't use deprecated function

2021-02-26 Thread Paul B Mahol
lgtm
___
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/5] avcodec/mpegvideo: Schedule unused, deprecated rc_strategy for removal

2021-02-26 Thread Andreas Rheinhardt
Deprecated in d05c3b9ceeb9d00d4500c376448230e45f6ab108.

Signed-off-by: Andreas Rheinhardt 
---
Here is my current WIP branch for the bump for anyone who is interested:
https://github.com/mkver/FFmpeg/commits/bump

 libavcodec/mpegvideo.h | 14 +++---
 libavcodec/version.h   |  3 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 5f6e1da133..5a99c19656 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -369,7 +369,9 @@ typedef struct MpegEncContext {
 uint8_t *mb_info_ptr;
 int mb_info_size;
 int ehc_mode;
+#if FF_API_MPV_RC_STRATEGY
 int rc_strategy;///< deprecated
+#endif
 
 /* H.263+ specific */
 int umvplus;///< == H.263+ && unrestricted_mv
@@ -615,6 +617,14 @@ typedef struct MpegEncContext {
 #ifndef FF_MPV_OFFSET
 #define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
 #endif
+#if FF_API_MPV_RC_STRATEGY
+#define FF_MPV_RC_STRATEGY_OPTS \
+{"rc_strategy", "ratecontrol method",   
FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, 
FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" },   \
+{ "ffmpeg", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 
}, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
+{ "xvid",   "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 
}, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" },
+#else
+#define FF_MPV_RC_STRATEGY_OPTS
+#endif
 #define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 #define FF_MPV_COMMON_OPTS \
 FF_MPV_OPT_CMP_FUNC, \
@@ -648,9 +658,6 @@ FF_MPV_OPT_CMP_FUNC, \
 {"lmax", "maximum Lagrange factor (VBR)",   
FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, 
FF_MPV_OPT_FLAGS },\
 {"ibias", "intra quant bias",   
FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS 
}, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
 {"pbias", "inter quant bias",   
FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS 
}, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
-{"rc_strategy", "ratecontrol method",   
FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, 
FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" },   \
-{ "ffmpeg", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 
}, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
-{ "xvid",   "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 
}, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
 {"motion_est", "motion estimation algorithm",   
FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, 
FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" },   \
 { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
 { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
@@ -671,6 +678,7 @@ FF_MPV_OPT_CMP_FUNC, \
 {"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, 
{.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"intra_penalty", "Penalty for intra blocks in block decision", 
FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, 
FF_MPV_OPT_FLAGS }, \
 {"a53cc", "Use A53 Closed Captions (if available)", FF_MPV_OFFSET(a53_cc), 
AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FF_MPV_OPT_FLAGS }, \
+FF_MPV_RC_STRATEGY_OPTS
 
 extern const AVOption ff_mpv_generic_options[];
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 516411b4b2..488def4c23 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -147,6 +147,9 @@
 #ifndef FF_API_AVCODEC_PIX_FMT
 #define FF_API_AVCODEC_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_MPV_RC_STRATEGY
+#define FF_API_MPV_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 #ifndef FF_API_THREAD_SAFE_CALLBACKS
 #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
 #endif
-- 
2.27.0

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

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

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/parser: Schedule av_parser_change for removal

2021-02-26 Thread James Almer

On 2/26/2021 10:18 AM, Andreas Rheinhardt wrote:

Originally deprecated in 748c2fca7e4d99357c234936aa71212a6282be36,
publically deprecated in 9a07c1332cfe092b57b5758f22b686ca58806c60
(merged into FFmpeg in 1885ffb03d0af28e6bac2bcc8725fa15b93f6ac9).

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/avcodec.h | 6 +-
  libavcodec/parser.c  | 3 ++-
  libavcodec/version.h | 3 +++
  3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3178c163b9..a8741df04b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3576,14 +3576,18 @@ int av_parser_parse2(AVCodecParserContext *s,
   int64_t pts, int64_t dts,
   int64_t pos);
  
+#if FF_API_PARSER_CHANGE

  /**
   * @return 0 if the output buffer is a subset of the input, 1 if it is 
allocated and must be freed
- * @deprecated use AVBitStreamFilter
+ * @deprecated Use dump_extradata, remove_extra or extract_extradata
+ * bitstream filters instead.
   */
+attribute_deprecated
  int av_parser_change(AVCodecParserContext *s,
   AVCodecContext *avctx,
   uint8_t **poutbuf, int *poutbuf_size,
   const uint8_t *buf, int buf_size, int keyframe);
+#endif
  void av_parser_close(AVCodecParserContext *s);
  
  /**

diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index a63f532c48..f4bc00da7d 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -186,6 +186,7 @@ int av_parser_parse2(AVCodecParserContext *s, 
AVCodecContext *avctx,
  return index;
  }
  
+#if FF_API_PARSER_CHANGE

  int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx,
   uint8_t **poutbuf, int *poutbuf_size,
   const uint8_t *buf, int buf_size, int keyframe)
@@ -220,7 +221,7 @@ int av_parser_change(AVCodecParserContext *s, 
AVCodecContext *avctx,
  
  return 0;

  }
-
+#endif
  void av_parser_close(AVCodecParserContext *s)
  {
  if (s) {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 488def4c23..815df15628 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -150,6 +150,9 @@
  #ifndef FF_API_MPV_RC_STRATEGY
  #define FF_API_MPV_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59)
  #endif
+#ifndef FF_API_PARSER_CHANGE
+#define FF_API_PARSER_CHANGE   (LIBAVCODEC_VERSION_MAJOR < 59)


A doxygen deprecation notice is not enough to consider the function 
deprecated. There was no APIChanges entry and no attribute added to the 
function prototype.

So this needs the APIChanges entry, and therefore be scheduled as < 60.

LGTM otherwise.


+#endif
  #ifndef FF_API_THREAD_SAFE_CALLBACKS
  #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
  #endif



___
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/5] doc/codecs.texi: Remove removed or ineffective options

2021-02-26 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
Is it possible that Libav didn't use codecs.texi and that the committers
forgot to update it when Libav merges removed some of these options?

 doc/codecs.texi | 122 +---
 1 file changed, 1 insertion(+), 121 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 073fb4ece2..9add7629cf 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -50,8 +50,6 @@ Use internal 2pass ratecontrol in first pass mode.
 Use internal 2pass ratecontrol in second pass mode.
 @item gray
 Only decode/encode grayscale.
-@item emu_edge
-Do not draw edges.
 @item psnr
 Set error[?] variables during encoding.
 @item truncated
@@ -72,10 +70,6 @@ This ensures that file and data checksums are reproducible 
and match between
 platforms. Its primary use is for regression testing.
 @item aic
 Apply H263 advanced intra coding / mpeg4 ac prediction.
-@item cbp
-Deprecated, use mpegvideo private options instead.
-@item qprd
-Deprecated, use mpegvideo private options instead.
 @item ilme
 Apply interlaced motion estimation.
 @item cgop
@@ -84,40 +78,6 @@ Use closed gop.
 Output even potentially corrupted frames.
 @end table
 
-@item me_method @var{integer} (@emph{encoding,video})
-Set motion estimation method.
-
-Possible values:
-@table @samp
-@item zero
-zero motion estimation (fastest)
-@item full
-full motion estimation (slowest)
-@item epzs
-EPZS motion estimation (default)
-@item esa
-esa motion estimation (alias for full)
-@item tesa
-tesa motion estimation
-@item dia
-dia motion estimation (alias for epzs)
-@item log
-log motion estimation
-@item phods
-phods motion estimation
-@item x1
-X1 motion estimation
-@item hex
-hex motion estimation
-@item umh
-umh motion estimation
-@item iter
-iter motion estimation
-@end table
-
-@item extradata_size @var{integer}
-Set extradata size.
-
 @item time_base @var{rational number}
 Set codec time base.
 
@@ -184,9 +144,6 @@ Default value is 0.
 @item b_qfactor @var{float} (@emph{encoding,video})
 Set qp factor between P and B frames.
 
-@item rc_strategy @var{integer} (@emph{encoding,video})
-Set ratecontrol method.
-
 @item b_strategy @var{integer} (@emph{encoding,video})
 Set strategy to choose between I/P/B-frames.
 
@@ -210,8 +167,6 @@ Possible values:
 @table @samp
 @item autodetect
 
-@item old_msmpeg4
-some old lavc generated msmpeg4v3 files (no autodetection)
 @item xvid_ilace
 Xvid interlacing bug (autodetected if fourcc==XVIX)
 @item ump4
@@ -220,8 +175,6 @@ Xvid interlacing bug (autodetected if fourcc==XVIX)
 padding bug (autodetected)
 @item amv
 
-@item ac_vlc
-illegal vlc bug (autodetected per fourcc)
 @item qpel_chroma
 
 @item std_qpel
@@ -242,14 +195,6 @@ Workaround various bugs in microsoft broken decoders.
 trancated frames
 @end table
 
-@item lelim @var{integer} (@emph{encoding,video})
-Set single coefficient elimination threshold for luminance (negative
-values also consider DC coefficient).
-
-@item celim @var{integer} (@emph{encoding,video})
-Set single coefficient elimination threshold for chrominance (negative
-values also consider dc coefficient)
-
 @item strict @var{integer} (@emph{decoding/encoding,audio,video})
 Specify how strictly to follow the standards.
 
@@ -306,26 +251,8 @@ consider things that a sane encoder should not do as an 
error
 @item mpeg_quant @var{integer} (@emph{encoding,video})
 Use MPEG quantizers instead of H.263.
 
-@item qsquish @var{float} (@emph{encoding,video})
-How to keep quantizer between qmin and qmax (0 = clip, 1 = use
-differentiable function).
-
-@item rc_qmod_amp @var{float} (@emph{encoding,video})
-Set experimental quantizer modulation.
-
-@item rc_qmod_freq @var{integer} (@emph{encoding,video})
-Set experimental quantizer modulation.
-
 @item rc_override_count @var{integer}
 
-@item rc_eq @var{string} (@emph{encoding,video})
-Set rate control equation. When computing the expression, besides the
-standard functions defined in the section 'Expression Evaluation', the
-following functions are available: bits2qp(bits), qp2bits(qp). Also
-the following constants are available: iTex pTex tex mv fCode iCount
-mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex
-avgTex.
-
 @item maxrate @var{integer} (@emph{encoding,audio,video})
 Set max bitrate tolerance (in bits/s). Requires bufsize to be set.
 
@@ -336,18 +263,12 @@ encode. It is of little use elsewise.
 @item bufsize @var{integer} (@emph{encoding,audio,video})
 Set ratecontrol buffer size (in bits).
 
-@item rc_buf_aggressivity @var{float} (@emph{encoding,video})
-Currently useless.
-
 @item i_qfactor @var{float} (@emph{encoding,video})
 Set QP factor between P and I frames.
 
 @item i_qoffset @var{float} (@emph{encoding,video})
 Set QP offset between P and I frames.
 
-@item rc_init_cplx @var{float} (@emph{encoding,video})
-Set initial complexity for 1-pass encoding.
-
 @item dct @var{integer} (@emph{encoding,video})
 Set DCT algorithm.
 
@@ -412,11 +333,7 @@ 

[FFmpeg-devel] [PATCH 4/5] avcodec/parser: Schedule av_parser_change for removal

2021-02-26 Thread Andreas Rheinhardt
Originally deprecated in 748c2fca7e4d99357c234936aa71212a6282be36,
publically deprecated in 9a07c1332cfe092b57b5758f22b686ca58806c60
(merged into FFmpeg in 1885ffb03d0af28e6bac2bcc8725fa15b93f6ac9).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/avcodec.h | 6 +-
 libavcodec/parser.c  | 3 ++-
 libavcodec/version.h | 3 +++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3178c163b9..a8741df04b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3576,14 +3576,18 @@ int av_parser_parse2(AVCodecParserContext *s,
  int64_t pts, int64_t dts,
  int64_t pos);
 
+#if FF_API_PARSER_CHANGE
 /**
  * @return 0 if the output buffer is a subset of the input, 1 if it is 
allocated and must be freed
- * @deprecated use AVBitStreamFilter
+ * @deprecated Use dump_extradata, remove_extra or extract_extradata
+ * bitstream filters instead.
  */
+attribute_deprecated
 int av_parser_change(AVCodecParserContext *s,
  AVCodecContext *avctx,
  uint8_t **poutbuf, int *poutbuf_size,
  const uint8_t *buf, int buf_size, int keyframe);
+#endif
 void av_parser_close(AVCodecParserContext *s);
 
 /**
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index a63f532c48..f4bc00da7d 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -186,6 +186,7 @@ int av_parser_parse2(AVCodecParserContext *s, 
AVCodecContext *avctx,
 return index;
 }
 
+#if FF_API_PARSER_CHANGE
 int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx,
  uint8_t **poutbuf, int *poutbuf_size,
  const uint8_t *buf, int buf_size, int keyframe)
@@ -220,7 +221,7 @@ int av_parser_change(AVCodecParserContext *s, 
AVCodecContext *avctx,
 
 return 0;
 }
-
+#endif
 void av_parser_close(AVCodecParserContext *s)
 {
 if (s) {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 488def4c23..815df15628 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -150,6 +150,9 @@
 #ifndef FF_API_MPV_RC_STRATEGY
 #define FF_API_MPV_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_PARSER_CHANGE
+#define FF_API_PARSER_CHANGE   (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 #ifndef FF_API_THREAD_SAFE_CALLBACKS
 #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
 #endif
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 2/5] avcodec: Add missing FF_API define for libavcodec pix fmt API

2021-02-26 Thread Andreas Rheinhardt
avcodec_find_best_pix_fmt2 has been deprecated and replaced by
avcodec_find_best_pix_fmt_of_2 in 2a54ae9df8cbc1717b3929222ac75f384e2ff240.
avcodec_find_best_pix_fmt_of_2 and avcodec_get_pix_fmt_loss meanwhile
were deprecated in 617e866e25b72fa5d9f9d6bbcbd7e4bd69e63a54 when these
functions were de facto moved to libavutil; this has been mentioned in
APIchanges in f7a1c5e4d2294a8970ede7f6deb2fe0a64e202a5. Yet the
attribute_deprecated was never set for the latter two functions and they
were not wrapped in an FF_API define. This commit does this.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/avcodec.h| 15 +--
 libavcodec/imgconvert.c |  6 --
 libavcodec/version.h|  3 +++
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3d77d2f6fd..3178c163b9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3786,12 +3786,6 @@ void avcodec_get_chroma_sub_sample(enum AVPixelFormat 
pix_fmt, int *h_shift, int
  */
 unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
 
-/**
- * @deprecated see av_get_pix_fmt_loss()
- */
-int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum 
AVPixelFormat src_pix_fmt,
- int has_alpha);
-
 /**
  * Find the best pixel format to convert to given a certain source pixel
  * format.  When converting from one pixel format to another, information loss
@@ -3813,15 +3807,24 @@ enum AVPixelFormat 
avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p
 enum AVPixelFormat src_pix_fmt,
 int has_alpha, int *loss_ptr);
 
+#if FF_API_AVCODEC_PIX_FMT
+/**
+ * @deprecated see av_get_pix_fmt_loss()
+ */
+attribute_deprecated
+int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum 
AVPixelFormat src_pix_fmt,
+ int has_alpha);
 /**
  * @deprecated see av_find_best_pix_fmt_of_2()
  */
+attribute_deprecated
 enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat 
dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
 enum AVPixelFormat src_pix_fmt, 
int has_alpha, int *loss_ptr);
 
 attribute_deprecated
 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, 
enum AVPixelFormat dst_pix_fmt2,
 enum AVPixelFormat src_pix_fmt, 
int has_alpha, int *loss_ptr);
+#endif
 
 enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const 
enum AVPixelFormat * fmt);
 
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 1fd636c83d..8de1563404 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -44,6 +44,7 @@ void avcodec_get_chroma_sub_sample(enum AVPixelFormat 
pix_fmt, int *h_shift, int
 }
 #endif
 
+#if FF_API_AVCODEC_PIX_FMT
 int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
  enum AVPixelFormat src_pix_fmt,
  int has_alpha)
@@ -60,9 +61,10 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum 
AVPixelFormat dst_pix_fmt
 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, 
enum AVPixelFormat dst_pix_fmt2,
 enum AVPixelFormat src_pix_fmt, 
int has_alpha, int *loss_ptr)
 {
-return avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, 
src_pix_fmt, has_alpha, loss_ptr);
+return av_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, 
has_alpha, loss_ptr);
 }
 
+#endif
 enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat 
*pix_fmt_list,
 enum AVPixelFormat src_pix_fmt,
 int has_alpha, int *loss_ptr){
@@ -73,7 +75,7 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const 
enum AVPixelFormat *p
 
 for (i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++) {
 loss = loss_ptr ? *loss_ptr : 0;
-best = avcodec_find_best_pix_fmt_of_2(best, pix_fmt_list[i], 
src_pix_fmt, has_alpha, );
+best = av_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, 
has_alpha, );
 }
 
 if (loss_ptr)
diff --git a/libavcodec/version.h b/libavcodec/version.h
index e5a5ec8abc..516411b4b2 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -144,6 +144,9 @@
 #ifndef FF_API_OLD_ENCDEC
 #define FF_API_OLD_ENCDEC  (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_AVCODEC_PIX_FMT
+#define FF_API_AVCODEC_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 #ifndef FF_API_THREAD_SAFE_CALLBACKS
 #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
 #endif
-- 
2.27.0

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

To unsubscribe, visit link above, or 

[FFmpeg-devel] [PATCH 1/5] fftools/ffmpeg_filter: Don't use deprecated function

2021-02-26 Thread Andreas Rheinhardt
avcodec_find_best_pix_fmt_of_2 has been moved to libavutil in
617e866e25b72fa5d9f9d6bbcbd7e4bd69e63a54.

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

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 9218394f4a..4ab769c07b 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -74,7 +74,7 @@ static enum AVPixelFormat choose_pixel_fmt(AVStream *st, 
AVCodecContext *enc_ctx
 p = get_compliance_unofficial_pix_fmts(enc_ctx->codec_id, p);
 }
 for (; *p != AV_PIX_FMT_NONE; p++) {
-best= avcodec_find_best_pix_fmt_of_2(best, *p, target, has_alpha, 
NULL);
+best = av_find_best_pix_fmt_of_2(best, *p, target, has_alpha, 
NULL);
 if (*p == target)
 break;
 }
-- 
2.27.0

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

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

Re: [FFmpeg-devel] Feature request

2021-02-26 Thread Tomas Härdin
ons 2021-02-24 klockan 23:45 + skrev Jimmy Jaffe:
> Hi people. Now it is very common videos recorded with bad rotations.
> With ffmpeg it is possible to rotate without re-encoding the video
> using the 'rotate' instruction. But if the video has more than one
> rotation it is not possible. Will it be possible to add rotation
> instructions with time? For example, if a video starts vertically and
> after a minute it needs to be rotated horizontally, an instruction
> such as 'rotate = 90 60sec', which would mean that from second 60
> rotate 90 degrees. This is possible?, I repeat without re-encoding.

Any format that supports EDLs can do this, but very few players have
full EDL support. MOV and MXF come to mind. FFmpeg certainly doesn't
support this.

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avformat/mxfdec: change toolkit_version metadata field to toolkit_version_num

2021-02-26 Thread Tomas Härdin
lör 2021-02-20 klockan 00:17 +0100 skrev Marton Balint:
> It only got added recently, and the new name makes it consistent with
> product_version_num in the next patch.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mxfdec.c | 2 +-
>  tests/ref/fate/mxf-d10-user-comments | 2 +-
>  tests/ref/fate/mxf-probe-applehdr10  | 2 +-
>  tests/ref/fate/mxf-probe-dnxhd   | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 9f22c386f0..3ce83dde54 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -2798,7 +2798,7 @@ static int mxf_read_identification_metadata(void *arg, 
> AVIOContext *pb, int tag,
>  SET_TS_METADATA(pb, "modification_date", ts, str);
>  break;
>  case 0x3C07:
> -SET_VERSION_METADATA(pb, "toolkit_version", major, minor, tertiary, 
> patch, release, str);
> +SET_VERSION_METADATA(pb, "toolkit_version_num", major, minor, 
> tertiary, patch, release, str);

Should be fine assuming there hasn't been a new version released yet.

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH] avformat/gopher: Add support for Gopher over TLS.

2021-02-26 Thread Ivan J.
As for the test cases, curl has implemented their local test units[0]
that test gophers.

After applying the patch and compiling, the ffmpeg implementation can
be tested with the following:

1) No encryption:

$ ./ffplay gopher://parazyd.org/9/pub/dev/random/1593154977112.webm
$ ./ffplay gopher://adamsgaard.dk/9/npub/alien-love.mkv
$ ./ffplay gopher://codemadness.org/9/paste/warmelul.mkv

2) TLS with trusted certificate:

$ ./ffplay gophers://parazyd.org/9/pub/dev/random/1593154977112.webm
$ ./ffplay gophers://adamsgaard.dk/9/npub/alien-love.mkv
$ ./ffplay gophers://codemadness.org/9/paste/warmelul.mkv

[0] https://github.com/curl/curl/commit/48b85c46f16f04e803e00b0bad42a4fa0295f517

Best regards,
Ivan
___
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/3] avcodec: add SGA PCM decoder

2021-02-26 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile | 1 +
 libavcodec/allcodecs.c  | 1 +
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 libavcodec/pcm.c| 9 +
 libavcodec/utils.c  | 1 +
 6 files changed, 20 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index eb90841dfe..fe7026c1db 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -830,6 +830,7 @@ OBJS-$(CONFIG_PCM_S64BE_DECODER)  += pcm.o
 OBJS-$(CONFIG_PCM_S64BE_ENCODER)  += pcm.o
 OBJS-$(CONFIG_PCM_S64LE_DECODER)  += pcm.o
 OBJS-$(CONFIG_PCM_S64LE_ENCODER)  += pcm.o
+OBJS-$(CONFIG_PCM_SGA_DECODER)+= pcm.o
 OBJS-$(CONFIG_PCM_U8_DECODER) += pcm.o
 OBJS-$(CONFIG_PCM_U8_ENCODER) += pcm.o
 OBJS-$(CONFIG_PCM_U16BE_DECODER)  += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 354d146379..990998b64b 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -568,6 +568,7 @@ extern AVCodec ff_pcm_s64be_encoder;
 extern AVCodec ff_pcm_s64be_decoder;
 extern AVCodec ff_pcm_s64le_encoder;
 extern AVCodec ff_pcm_s64le_decoder;
+extern AVCodec ff_pcm_sga_decoder;
 extern AVCodec ff_pcm_u8_encoder;
 extern AVCodec ff_pcm_u8_decoder;
 extern AVCodec ff_pcm_u16be_encoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 8e695b11d2..f64ba488f2 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2096,6 +2096,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PCM Archimedes VIDC"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_PCM_SGA,
+.type  = AVMEDIA_TYPE_AUDIO,
+.name  = "pcm_sga",
+.long_name = NULL_IF_CONFIG_SMALL("PCM SGA"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various ADPCM codecs */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 56a69cf1c2..7dd316afd2 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -346,6 +346,7 @@ enum AVCodecID {
 AV_CODEC_ID_PCM_F16LE,
 AV_CODEC_ID_PCM_F24LE,
 AV_CODEC_ID_PCM_VIDC,
+AV_CODEC_ID_PCM_SGA,
 
 /* various ADPCM codecs */
 AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 7f0af8564f..19d04e9181 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -419,6 +419,14 @@ static int pcm_decode_frame(AVCodecContext *avctx, void 
*data,
 for (; n > 0; n--)
 *samples++ = *src++ + 128;
 break;
+case AV_CODEC_ID_PCM_SGA:
+for (; n > 0; n--) {
+int sign = *src >> 7;
+int magn = *src & 0x7f;
+*samples++ = sign ? 128 - magn : 128 + magn;
+src++;
+}
+break;
 case AV_CODEC_ID_PCM_S8_PLANAR:
 n /= avctx->channels;
 for (c = 0; c < avctx->channels; c++) {
@@ -622,3 +630,4 @@ PCM_CODEC  (PCM_U32LE,AV_SAMPLE_FMT_S32, pcm_u32le, 
   "PCM unsigned
 PCM_CODEC  (PCM_S64BE,AV_SAMPLE_FMT_S64, pcm_s64be,"PCM signed 
64-bit big-endian");
 PCM_CODEC  (PCM_S64LE,AV_SAMPLE_FMT_S64, pcm_s64le,"PCM signed 
64-bit little-endian");
 PCM_CODEC  (PCM_VIDC, AV_SAMPLE_FMT_S16, pcm_vidc, "PCM 
Archimedes VIDC");
+PCM_DECODER(PCM_SGA,  AV_SAMPLE_FMT_U8,  pcm_sga,  "PCM SGA");
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4d1909b581..db6cd0cde8 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1547,6 +1547,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
 case AV_CODEC_ID_PCM_VIDC:
 case AV_CODEC_ID_PCM_S8:
 case AV_CODEC_ID_PCM_S8_PLANAR:
+case AV_CODEC_ID_PCM_SGA:
 case AV_CODEC_ID_PCM_U8:
 case AV_CODEC_ID_SDX2_DPCM:
 case AV_CODEC_ID_DERF_DPCM:
-- 
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/3] avcodec: add SGA Video decoder

2021-02-26 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/codec_id.h   |   1 +
 libavcodec/sga.c| 534 
 5 files changed, 544 insertions(+)
 create mode 100644 libavcodec/sga.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fe7026c1db..850657ae3c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -609,6 +609,7 @@ OBJS-$(CONFIG_SANM_DECODER)+= sanm.o
 OBJS-$(CONFIG_SCPR_DECODER)+= scpr.o
 OBJS-$(CONFIG_SCREENPRESSO_DECODER)+= screenpresso.o
 OBJS-$(CONFIG_SDX2_DPCM_DECODER)   += dpcm.o
+OBJS-$(CONFIG_SGA_DECODER) += sga.o
 OBJS-$(CONFIG_SGI_DECODER) += sgidec.o
 OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o
 OBJS-$(CONFIG_SGIRLE_DECODER)  += sgirledec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 990998b64b..a04faead16 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -289,6 +289,7 @@ extern AVCodec ff_s302m_decoder;
 extern AVCodec ff_sanm_decoder;
 extern AVCodec ff_scpr_decoder;
 extern AVCodec ff_screenpresso_decoder;
+extern AVCodec ff_sga_decoder;
 extern AVCodec ff_sgi_encoder;
 extern AVCodec ff_sgi_decoder;
 extern AVCodec ff_sgirle_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index f64ba488f2..17f8a14044 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1849,6 +1849,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_SGA_VIDEO,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "sga",
+.long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 7dd316afd2..ab7bc68ee2 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -306,6 +306,7 @@ enum AVCodecID {
 AV_CODEC_ID_ARGO,
 AV_CODEC_ID_CRI,
 AV_CODEC_ID_SIMBIOSIS_IMX,
+AV_CODEC_ID_SGA_VIDEO,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/sga.c b/libavcodec/sga.c
new file mode 100644
index 00..00752a5843
--- /dev/null
+++ b/libavcodec/sga.c
@@ -0,0 +1,534 @@
+/*
+ * Copyright (c) 2021 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/common.h"
+#include "avcodec.h"
+#include "get_bits.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define PALDATA_FOLLOWS_TILEDATA 4
+#define HAVE_COMPRESSED_TILEMAP 32
+#define HAVE_TILEMAP 128
+
+typedef struct SGAVideoContext {
+GetByteContext gb;
+
+int metadata_size;
+int tiledata_size;
+int tiledata_offset;
+int tilemapdata_size;
+int tilemapdata_offset;
+int paldata_size;
+int paldata_offset;
+int palmapdata_offset;
+int palmapdata_size;
+
+int flags;
+int nb_pal;
+int nb_tiles;
+int tiles_w, tiles_h;
+int shift;
+int plus;
+int swap;
+
+uint32_t pal[256];
+uint8_t *tileindex_data;
+unsigned tileindex_size;
+uint8_t *palmapindex_data;
+unsigned palmapindex_size;
+uint8_t uncompressed[65536];
+} SGAVideoContext;
+
+static av_cold int sga_decode_init(AVCodecContext *avctx)
+{
+avctx->pix_fmt = AV_PIX_FMT_PAL8;
+return 0;
+}
+
+static int decode_palette(GetByteContext *gb, uint32_t *pal)
+{
+GetBitContext gbit;
+
+if (bytestream2_get_bytes_left(gb) < 18)
+return AVERROR_INVALIDDATA;
+
+memset(pal, 0, 16 * sizeof(*pal));
+init_get_bits8(, gb->buffer, 18);
+
+for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
+for (int index = 0; index < 16; index++) {
+unsigned color = get_bits1() << RGBIndex;
+pal[15 - index] |= color << (5 + 16);
+}
+}
+
+for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
+for (int index = 0; index < 16; 

Re: [FFmpeg-devel] [PATCH V3 3/5] libavformat/protocols.c: fix build warning for [-Wdiscarded-qualifiers]

2021-02-26 Thread Paul B Mahol
look at same/similar patches like yours that have been already rejected.

On Fri, Feb 26, 2021 at 9:48 AM Guo, Yejun  wrote:

> src/libavformat/protocols.c: In function ‘avio_enum_protocols’:
> src/libavformat/protocols.c:116:7: warning: assignment discards ‘const’
> qualifier from pointer target type [-Wdiscarded-qualifiers]
>  p = p ? p + 1 : url_protocols;
>^
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavformat/protocols.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/protocols.c b/libavformat/protocols.c
> index 7df18fbb3b..86cde84a31 100644
> --- a/libavformat/protocols.c
> +++ b/libavformat/protocols.c
> @@ -113,7 +113,7 @@ const char *avio_enum_protocols(void **opaque, int
> output)
>  {
>  const URLProtocol **p = *opaque;
>
> -p = p ? p + 1 : url_protocols;
> +p = p ? p + 1 : (const URLProtocol **)url_protocols;
>  *opaque = p;
>  if (!*p) {
>  *opaque = NULL;
> --
> 2.17.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 3/3] avformat: add Digital Pictures SGA game demuxer

2021-02-26 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/sga.c| 473 +++
 3 files changed, 475 insertions(+)
 create mode 100644 libavformat/sga.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 95ed25e866..4b03e9fa92 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -502,6 +502,7 @@ OBJS-$(CONFIG_SEGAFILM_DEMUXER)  += segafilm.o
 OBJS-$(CONFIG_SEGAFILM_MUXER)+= segafilmenc.o
 OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o
 OBJS-$(CONFIG_SER_DEMUXER)   += serdec.o
+OBJS-$(CONFIG_SGA_DEMUXER)   += sga.o
 OBJS-$(CONFIG_SHORTEN_DEMUXER)   += shortendec.o rawdec.o
 OBJS-$(CONFIG_SIFF_DEMUXER)  += siff.o
 OBJS-$(CONFIG_SIMBIOSIS_IMX_DEMUXER) += imx.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3b69423508..ade247640c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -401,6 +401,7 @@ extern AVOutputFormat ff_segafilm_muxer;
 extern AVOutputFormat ff_segment_muxer;
 extern AVOutputFormat ff_stream_segment_muxer;
 extern AVInputFormat  ff_ser_demuxer;
+extern AVInputFormat  ff_sga_demuxer;
 extern AVInputFormat  ff_shorten_demuxer;
 extern AVInputFormat  ff_siff_demuxer;
 extern AVInputFormat  ff_simbiosis_imx_demuxer;
diff --git a/libavformat/sga.c b/libavformat/sga.c
new file mode 100644
index 00..3dfce4e11e
--- /dev/null
+++ b/libavformat/sga.c
@@ -0,0 +1,473 @@
+/*
+ * Digital Pictures SGA game demuxer
+ *
+ * Copyright (C) 2021 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/avassert.h"
+#include "libavutil/internal.h"
+#include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
+
+#define SEGA_CD_PCM_NUM 1250
+#define SEGA_CD_PCM_DEN 786432
+
+typedef struct SGADemuxContext {
+int video_stream_index;
+int audio_stream_index;
+
+uint8_t sector[65536 * 2];
+int sector_headers;
+int sample_rate;
+int first_audio_size;
+int payload_size;
+int packet_type;
+int flags;
+int idx;
+int left;
+int64_t pkt_pos;
+} SGADemuxContext;
+
+static int sga_probe(const AVProbeData *p)
+{
+const uint8_t *src = p->buf;
+int score = 0, sectors = 1;
+int last_left = 0;
+int sample_rate = -1;;
+
+if (p->buf_size < 2048)
+return 0;
+
+for (int i = 0; i + 2 < p->buf_size; i += 2048) {
+int header = AV_RB16(src + i);
+
+if ((header > 0x07FE && header < 0x8100) ||
+(header > 0x8200 && header < 0xA100) ||
+(header > 0xA200 && header < 0xC100)) {
+sectors = 0;
+break;
+}
+}
+
+for (int i = 0; i + 4 < p->buf_size;) {
+int header = AV_RB16(src + i);
+int left   = AV_RB16(src + i + 2);
+int offset, type, size;
+
+if (sectors && header && last_left <= 0) {
+if (left <= 8)
+return 0;
+last_left = left;
+} else if (sectors && header) {
+left = header;
+last_left -= left;
+if (header != 0x7FE && left <= 8)
+return 0;
+} else if (sectors) {
+if (left <= 8)
+return 0;
+i += sectors ? 2048 : left + 4;
+last_left = 0;
+continue;
+}
+
+if (sectors && (i > 0 && left < 0x7fe) &&
+(i + left + 14 < p->buf_size)) {
+offset = i + left + 2;
+} else if (sectors && i > 0) {
+i += 2048;
+continue;
+} else {
+offset = 0;
+last_left = left;
+}
+
+header = AV_RB16(src + offset);
+size   = AV_RB16(src + offset + 2) + 4;
+
+while ((header & 0xFF00) == 0) {
+offset++;
+if (offset + 4 >= p->buf_size)
+break;
+header = AV_RB16(src + offset);
+size   = AV_RB16(src + offset + 2) + 4;
+}
+
+if (offset + 12 >= p->buf_size)
+break;
+if ((header & 0xFF) > 1)
+return 0;
+type = header >> 8;
+
+

Re: [FFmpeg-devel] [PATCH v5 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-02-26 Thread Nicolas George
Jan Ekström (12021-02-22):
> From: Stefano Sabatini 
> 
> Base escaping only escapes values required for base character data
> according to part 2.4 of XML, and if additional flags are added
> single and double quotes can additionally be escaped in order
> to handle single and double quoted attributes.
> ---
>  libavutil/avstring.h | 14 ++
>  libavutil/bprint.c   | 29 +
>  libavutil/version.h  |  2 +-
>  tools/ffescape.c |  7 +--
>  4 files changed, 49 insertions(+), 3 deletions(-)

I am happy with this version. Thank you very much.

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 V3 1/5] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-26 Thread Nicolas George
Guo, Yejun (12021-02-26):
> Here is the warning message:
> src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
> src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be 
> truncated writing up to 255 bytes into a region of size 251 
> [-Wformat-truncation=]
>  snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
>   ^~
> src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261 
> bytes into a destination of size 256
>  snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
>  ^~~~
> 
> Signed-off-by: Guo, Yejun 
> ---
>  libavdevice/v4l2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index 365bacd771..cb426cf2d5 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, 
> AVDeviceInfoList *device_l
>  return ret;
>  }
>  while ((entry = readdir(dir))) {
> -char device_name[256];

> +char device_name[sizeof(entry->d_name) + 5];

Unfortunately, that is not guaranteed to work: entry->d_name can be
declared as char d_name[0] and the space dynamically allocated at the
end of the structure.

I think a better course of action would be to acknowledge that this
warning is a waste of time and disable it.

That does not mean we should not fix the cases where the buffer can be
too small. We should, and we will find them without this warning, by
making use of common sense. This instance is not one, because even with
a billion webcams, /dev/video9 fits in 256 chars.

>  
>  if (!v4l2_is_v4l_dev(entry->d_name))
>  continue;

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 V2 1/7] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-26 Thread Reimar Döffinger

> On 25 Feb 2021, at 18:52, Chad Fraleigh  wrote:
> 
> On 2/24/2021 10:38 PM, Guo, Yejun wrote:
>>  libavdevice/v4l2.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
>> index 365bacd771..e11d10d20e 100644
>> --- a/libavdevice/v4l2.c
>> +++ b/libavdevice/v4l2.c
>> @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, 
>> AVDeviceInfoList *device_l
>>  return ret;
>>  }
>>  while ((entry = readdir(dir))) {
>> -char device_name[256];
>> +char device_name[512];
> 
> Is there a portable path max constant that would be better for cases like 
> this, rather than just picking another arbitrary buffer size?

There is PATH_MAX/MAX_PATH, however the problems are:
1) They are not necessarily a strict limit on path length, so no guarantee all 
file names fit
2) Even if there is such a guarantee, that only applies to VALID file names, 
however the files here are user input ans not necessarily valid, so using those 
defines does not fix things anyway

Speaking generally I have doubts that these patches actually IMPROVE security 
and don’t make it actually worse.
On the plus side I see:
- they fix truncations in those specific cases
On the minus side I see:
- file names can clearly be longer, so there is still a truncation issue even 
after these patches, truncation just happens elsewhere and at larger lengths
- the warning is removed, so now there is nothing that reminds developers of 
this issue existing
- it relies on “magic constants” that can easily become outdated and 
re-introduce the issue again at any time
- there is as far as I can tell no evidence that any of these truncations cause 
actual issues, or if so in which circumstances, so there is no evidence of 
benefit. However as with all changes there is a risk of introducing new bugs
- size of on-stack variables are increased which may decrease effectiveness of 
stack protection

As a result personally I am mostly worried about these patches if they are 
applied without a deep security review of each and ensuring the issues are 
understood and thoroughly fixed.
I before suggested using av_asprintf, which does at least permanently solve the 
truncation issue without magic constants and eliminates on-stack arrays, 
however I should also add that it might create a allocation failure issue, 
which then opens up the whole “how to handle allocation failure without 
introducing a even more tricky security issue”.
So I am afraid that these issues will be annoyingly costly to fix, and I am not 
sure how big the desire is to do so...

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

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

[FFmpeg-devel] [PATCH V3 5/5] libavutil/opt.c: fix build warning for [-Wdiscarded-qualifiers]

2021-02-26 Thread Guo, Yejun
src/libavutil/opt.c: In function ‘av_opt_child_class_iterate’:
src/libavutil/opt.c:1738:15: warning: assignment discards ‘const’ qualifier 
from pointer target type [-Wdiscarded-qualifiers]
 *iter = parent->child_class_next(*iter);
   ^

Signed-off-by: Guo, Yejun 
---
 libavutil/opt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 590146b5fb..c47146c47f 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1735,7 +1735,7 @@ const AVClass *av_opt_child_class_iterate(const AVClass 
*parent, void **iter)
 #if FF_API_CHILD_CLASS_NEXT
 FF_DISABLE_DEPRECATION_WARNINGS
 if (parent->child_class_next) {
-*iter = parent->child_class_next(*iter);
+*iter = (void *)parent->child_class_next(*iter);
 return *iter;
 }
 FF_ENABLE_DEPRECATION_WARNINGS
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH V3 4/5] libavformat/smoothstreamingenc.c: fix build warning for [-Wformat-truncation=]

2021-02-26 Thread Guo, Yejun
Part of the build message:
src/libavformat/smoothstreamingenc.c: In function ‘ism_flush’:
src/libavformat/smoothstreamingenc.c:510:49: warning: ‘/temp’ directive output 
may be truncated writing 5 bytes into a region of size between 1 and 1024 
[-Wformat-truncation=]
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^
src/libavformat/smoothstreamingenc.c:510:9: note: ‘snprintf’ output between 6 
and 1029 bytes into a destination of size 1024
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^~~~
src/libavformat/smoothstreamingenc.c:538:53: warning: ‘/temp’ directive output 
may be truncated writing 5 bytes into a region of size between 1 and 1024 
[-Wformat-truncation=]
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^
src/libavformat/smoothstreamingenc.c:538:13: note: ‘snprintf’ output between 6 
and 1029 bytes into a destination of size 1024
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^~~~
src/libavformat/smoothstreamingenc.c:545:63: warning: ‘/FragmentInfo(’ 
directive output may be truncated writing 14 bytes into a region of size 
between 1 and 1024 [-Wformat-truncation=]
 snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
   ^~
src/libavformat/smoothstreamingenc.c:545:60: note: using the range [0, 
18446744073709551615] for directive argument
 snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);

^~
src/libavformat/smoothstreamingenc.c:545:9: note: ‘snprintf’ output 18 or more 
bytes (assuming 1041) into a destination of size 1024
 snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
 
^~~

Signed-off-by: Guo, Yejun 
---
 libavformat/smoothstreamingenc.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index ba5cc27ca0..dc48bc7aa4 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -501,7 +501,8 @@ static int ism_flush(AVFormatContext *s, int final)
 
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
-char filename[1024], target_filename[1024], header_filename[1024], 
curr_dirname[1024];
+char filename[sizeof(os->dirname) + 5], curr_dirname[1024];
+char *target_filename, *header_filename;
 int64_t size;
 int64_t start_ts, duration, moof_size;
 if (!os->packets_written)
@@ -542,14 +543,24 @@ static int ism_flush(AVFormatContext *s, int final)
 return ret;
 }
 
-snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
-snprintf(target_filename, sizeof(target_filename), 
"%s/Fragments(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
+header_filename = av_asprintf("%s/FragmentInfo(%s=%"PRIu64")", 
os->dirname, os->stream_type_tag, start_ts);
+target_filename = av_asprintf("%s/Fragments(%s=%"PRIu64")", 
os->dirname, os->stream_type_tag, start_ts);
+if (!header_filename || !target_filename) {
+av_freep(_filename);
+av_freep(_filename);
+return AVERROR(ENOMEM);
+}
 copy_moof(s, filename, header_filename, moof_size);
 ret = ff_rename(filename, target_filename, s);
-if (ret < 0)
+if (ret < 0) {
+av_freep(_filename);
+av_freep(_filename);
 break;
+}
 add_fragment(os, target_filename, header_filename, start_ts, duration,
  os->cur_start_pos, size);
+av_freep(_filename);
+av_freep(_filename);
 }
 
 if (c->window_size || (final && c->remove_at_exit)) {
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH V3 3/5] libavformat/protocols.c: fix build warning for [-Wdiscarded-qualifiers]

2021-02-26 Thread Guo, Yejun
src/libavformat/protocols.c: In function ‘avio_enum_protocols’:
src/libavformat/protocols.c:116:7: warning: assignment discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
 p = p ? p + 1 : url_protocols;
   ^

Signed-off-by: Guo, Yejun 
---
 libavformat/protocols.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 7df18fbb3b..86cde84a31 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -113,7 +113,7 @@ const char *avio_enum_protocols(void **opaque, int output)
 {
 const URLProtocol **p = *opaque;
 
-p = p ? p + 1 : url_protocols;
+p = p ? p + 1 : (const URLProtocol **)url_protocols;
 *opaque = p;
 if (!*p) {
 *opaque = NULL;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH V3 2/5] libavformat/dashenc.c: fix build warning for [-Wformat-truncation=]

2021-02-26 Thread Guo, Yejun
Part of warning message:
src/libavformat/dashenc.c: In function ‘flush_init_segment’:
src/libavformat/dashenc.c:608:49: warning: ‘%s’ directive output may be 
truncated writing up to 1023 bytes into a region of size between 1 and 1024 
[-Wformat-truncation=]
 snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
 ^~
src/libavformat/dashenc.c:608:9: note: ‘snprintf’ output between 1 and 2047 
bytes into a destination of size 1024
 snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
 ^~

Signed-off-by: Guo, Yejun 
---
 libavformat/dashenc.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 2d757b3a87..625be010be 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -126,7 +126,7 @@ typedef struct OutputStream {
 char codec_str[100];
 int written_len;
 char filename[1024];
-char full_path[1024];
+char full_path[2048];
 char temp_path[1024];
 double availability_time_offset;
 AVProducerReferenceTime producer_reference_time;
@@ -604,9 +604,11 @@ static int flush_init_segment(AVFormatContext *s, 
OutputStream *os)
 
 os->pos = os->init_range_length = range_length;
 if (!c->single_file) {
-char filename[1024];
-snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
+char *filename = av_asprintf("%s%s", c->dirname, os->initfile);
+if (!filename)
+return AVERROR(ENOMEM);
 dashenc_io_close(s, >out, filename);
+av_freep();
 }
 return 0;
 }
@@ -1480,7 +1482,7 @@ static int dash_init(AVFormatContext *s)
 AVFormatContext *ctx;
 AVStream *st;
 AVDictionary *opts = NULL;
-char filename[1024];
+char *filename;
 
 os->bit_rate = s->streams[i]->codecpar->bit_rate;
 if (!os->bit_rate) {
@@ -1569,16 +1571,21 @@ static int dash_init(AVFormatContext *s)
 } else {
 ff_dash_fill_tmpl_params(os->initfile, sizeof(os->initfile), 
os->init_seg_name, i, 0, os->bit_rate, 0);
 }
-snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
+filename = av_asprintf("%s%s", c->dirname, os->initfile);
+if (!filename)
+return AVERROR(ENOMEM);
 set_http_options(, c);
 if (!c->single_file) {
-if ((ret = avio_open_dyn_buf(>pb)) < 0)
+if ((ret = avio_open_dyn_buf(>pb)) < 0) {
+av_freep();
 return ret;
+}
 ret = s->io_open(s, >out, filename, AVIO_FLAG_WRITE, );
 } else {
 ctx->url = av_strdup(filename);
 ret = avio_open2(>pb, filename, AVIO_FLAG_WRITE, NULL, );
 }
+av_freep();
 av_dict_free();
 if (ret < 0)
 return ret;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH V3 1/5] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-26 Thread Guo, Yejun
Here is the warning message:
src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be truncated 
writing up to 255 bytes into a region of size 251 [-Wformat-truncation=]
 snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
  ^~
src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261 bytes 
into a destination of size 256
 snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
 ^~~~

Signed-off-by: Guo, Yejun 
---
 libavdevice/v4l2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 365bacd771..cb426cf2d5 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, 
AVDeviceInfoList *device_l
 return ret;
 }
 while ((entry = readdir(dir))) {
-char device_name[256];
+char device_name[sizeof(entry->d_name) + 5];
 
 if (!v4l2_is_v4l_dev(entry->d_name))
 continue;
-- 
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".