[FFmpeg-devel] [PATCH v3] avcodec: add Actimagine VX video decoder

2021-03-18 Thread Florian Nouwt
Signed-off-by: Florian Nouwt 
---
 Changelog   |1 +
 configure   |1 +
 doc/general_contents.texi   |2 +
 libavcodec/Makefile |3 +-
 libavcodec/actimagine_vx.c  | 1150 +++
 libavcodec/actimagine_vx_data.c |   45 ++
 libavcodec/actimagine_vx_data.h |   28 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/codec_desc.c |7 +
 libavcodec/codec_id.h   |1 +
 libavcodec/h264_cavlc.c |  205 +-
 libavcodec/h264_cavlc_data.c|  220 ++
 libavcodec/h264_cavlc_data.h|   50 ++
 libavcodec/version.h|2 +-
 libavformat/riff.c  |2 +
 15 files changed, 1524 insertions(+), 194 deletions(-)
 create mode 100644 libavcodec/actimagine_vx.c
 create mode 100644 libavcodec/actimagine_vx_data.c
 create mode 100644 libavcodec/actimagine_vx_data.h
 create mode 100644 libavcodec/h264_cavlc_data.c
 create mode 100644 libavcodec/h264_cavlc_data.h

diff --git a/Changelog b/Changelog
index a96e350e09..8807f3dcb3 100644
--- a/Changelog
+++ b/Changelog
@@ -83,6 +83,7 @@ version :
 - msad video filter
 - gophers protocol
 - RIST protocol via librist
+- Actimagine VX video decoder
 
 
 version 4.3:
diff --git a/configure b/configure
index f0ac719d2d..c38066bc1c 100755
--- a/configure
+++ b/configure
@@ -2662,6 +2662,7 @@ ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct"
 ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
 ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
 acelp_kelvin_decoder_select="audiodsp"
+actimagine_vx_decoder_select="bswapdsp golomb h264dsp h264pred"
 adpcm_g722_decoder_select="g722dsp"
 adpcm_g722_encoder_select="g722dsp"
 aic_decoder_select="golomb idctdsp"
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 33ece6e884..d4261386fc 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -807,6 +807,8 @@ following image formats are supported:
 @item 8088flex TMV   @tab @tab  X
 @item A64 multicolor @tab  X  @tab
 @tab Creates video suitable to be played on a commodore 64 (multicolor 
mode).
+@item Actimagine VX Video@tab @tab  X
+@tab fourcc: vxs1, VXS1
 @item Amazing Studio PAF Video @tab @tab  X
 @item American Laser Games MM  @tab@tab X
 @tab Used in games like Mad Dog McCree.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 81cc16471b..0bdeb9fc26 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -182,6 +182,7 @@ OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o 
ac3enc.o ac3tab.o \
 OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o ac3enc.o ac3tab.o 
ac3.o kbdwin.o
 OBJS-$(CONFIG_AC3_MF_ENCODER)  += mfenc.o mf_utils.o
 OBJS-$(CONFIG_ACELP_KELVIN_DECODER)+= g729dec.o lsp.o celp_math.o 
celp_filters.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o 
g729postfilter.o
+OBJS-$(CONFIG_ACTIMAGINE_VX_DECODER)   += actimagine_vx.o actimagine_vx_data.o 
h264_cavlc_data.o
 OBJS-$(CONFIG_AGM_DECODER) += agm.o
 OBJS-$(CONFIG_AIC_DECODER) += aic.o
 OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o alacdsp.o
@@ -367,7 +368,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o 
h264_cabac.o h264_cavlc.o \
   h264_direct.o h264_loopfilter.o  \
   h264_mb.o h264_picture.o \
   h264_refs.o h264_sei.o \
-  h264_slice.o h264data.o
+  h264_slice.o h264data.o 
h264_cavlc_data.o
 OBJS-$(CONFIG_H264_AMF_ENCODER)+= amfenc_h264.o
 OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuviddec.o
 OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o
diff --git a/libavcodec/actimagine_vx.c b/libavcodec/actimagine_vx.c
new file mode 100644
index 00..84871a1008
--- /dev/null
+++ b/libavcodec/actimagine_vx.c
@@ -0,0 +1,1150 @@
+/*
+ * Actimagine VX Video decoder
+ * Copyright (c) 2021 Florian Nouwt
+ *
+ * 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 
+
+#include "libavutil/avassert.h"
+#include "avcodec.h"
+#include "bytestream.h"
+#include "bswapd

[FFmpeg-devel] [PATCH] configure: select child muxers for rtp_mpegts

2021-03-18 Thread Gyan Doshi
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index f0ac719d2d..be9c5b4b1c 100755
--- a/configure
+++ b/configure
@@ -3363,6 +3363,7 @@ opus_muxer_select="ogg_muxer"
 psp_muxer_select="mov_muxer"
 rtp_demuxer_select="sdp_demuxer"
 rtp_muxer_select="golomb jpegtables"
+rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
 rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer 
rtp_protocol srtp"
 rtsp_demuxer_select="http_protocol rtpdec"
 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
-- 
2.30.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] avformat/rtp_mpegts: typedef MuxChain struct

2021-03-18 Thread Gyan Doshi
---
 libavformat/rtpenc_mpegts.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
index 50cebf68a3..28522f8913 100644
--- a/libavformat/rtpenc_mpegts.c
+++ b/libavformat/rtpenc_mpegts.c
@@ -23,15 +23,15 @@
 #include "avformat.h"
 #include "avio_internal.h"
 
-struct MuxChain {
+typedef struct MuxChain {
 AVFormatContext *mpegts_ctx;
 AVFormatContext *rtp_ctx;
 AVPacket *pkt;
-};
+} MuxChain;
 
 static int rtp_mpegts_write_close(AVFormatContext *s)
 {
-struct MuxChain *chain = s->priv_data;
+MuxChain *chain = s->priv_data;
 
 if (chain->mpegts_ctx) {
 av_write_trailer(chain->mpegts_ctx);
@@ -50,7 +50,7 @@ static int rtp_mpegts_write_close(AVFormatContext *s)
 
 static int rtp_mpegts_write_header(AVFormatContext *s)
 {
-struct MuxChain *chain = s->priv_data;
+MuxChain *chain = s->priv_data;
 AVFormatContext *mpegts_ctx = NULL, *rtp_ctx = NULL;
 ff_const59 AVOutputFormat *mpegts_format = av_guess_format("mpegts", NULL, 
NULL);
 ff_const59 AVOutputFormat *rtp_format= av_guess_format("rtp", NULL, 
NULL);
@@ -120,7 +120,7 @@ fail:
 
 static int rtp_mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-struct MuxChain *chain = s->priv_data;
+MuxChain *chain = s->priv_data;
 int ret = 0, size;
 uint8_t *buf;
 AVPacket *local_pkt = chain->pkt;
@@ -158,7 +158,7 @@ static int rtp_mpegts_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 AVOutputFormat ff_rtp_mpegts_muxer = {
 .name  = "rtp_mpegts",
 .long_name = NULL_IF_CONFIG_SMALL("RTP/mpegts output format"),
-.priv_data_size= sizeof(struct MuxChain),
+.priv_data_size= sizeof(MuxChain),
 .audio_codec   = AV_CODEC_ID_AAC,
 .video_codec   = AV_CODEC_ID_MPEG4,
 .write_header  = rtp_mpegts_write_header,
-- 
2.30.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] avcodec/dv_profile: PAL DV files with dsf flag 0 - detect via pal flag and buf_size

2021-03-18 Thread Mark Plomer
Okay cool, I added the check for the PAL flag - this still works fine 
for my test-videos.


I also looked at the old hack above with the codec_tag check - changed 
in 2013 for ticket #2177 (patch by Michael Niedermayer). I removed that 
more specific hack and the test-video attached to ticket #2177 also runs 
into the new hack now ... and still works fine. It also has a "dsf = 0" 
flag, though it is PAL.


So it was really a good idea to consolidate those hacks! Maybe the whole 
generic matching logic should be refactored, to match against the pal 
flag instead of the dsf flag? (The "buf_size" check may also be obsolete 
then). But this will be another task ;-)


I attached the updated patch.

Regards
Mark

Am 16.03.21 um 23:12 schrieb Marton Balint:


Then at least check the 50/60 flag as well in the VAUX source pack, 
e.g.:


pal   = !!(frame[80 * 5 + 48 + 3] & 0x20);


And as far as I see, the more specific hack checking for codec_tag and 
similar can be removed then, because your check covers that case as well.
>From 0a3665729ed441fcf73dc37fa1fde54267d974f9 Mon Sep 17 00:00:00 2001
From: Mark Plomer 
Date: Thu, 18 Mar 2021 13:19:16 +0100
Subject: [PATCH] avcodec/dv_profile: PAL DV files with dsf flag 0 - detect via
 pal flag and buf_size

Some old DV AVI files have the DSF-Flag of frames set to 0, although it
is PAL (maybe rendered with an old Ulead Media Studio Pro) ... this causes
ffmpeg/VLC-player to produce/play corrupted video (other players/editors
like VirtualDub work fine).

Fixes ticket #8333 and replaces/extends hack for ticket #2177
---
 libavcodec/dv_profile.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c
index 66505c886b..0fc227dd04 100644
--- a/libavcodec/dv_profile.c
+++ b/libavcodec/dv_profile.c
@@ -261,24 +261,22 @@ const AVDVProfile* ff_dv_frame_profile(AVCodecContext* codec, const AVDVProfile
const uint8_t *frame, unsigned buf_size)
 {
 #if CONFIG_DVPROFILE
-int i, dsf, stype;
+int i, dsf, stype, pal;
 
 if(buf_size < DV_PROFILE_BYTES)
 return NULL;
 
 dsf   = (frame[3] & 0x80) >> 7;
 stype = frame[80 * 5 + 48 + 3] & 0x1f;
+pal   = !!(frame[80 * 5 + 48 + 3] & 0x20);
 
 /* 576i50 25Mbps 4:1:1 is a special case */
 if ((dsf == 1 && stype == 0 && frame[4] & 0x07 /* the APT field */) ||
 (stype == 31 && codec && codec->codec_tag==AV_RL32("SL25") && codec->coded_width==720 && codec->coded_height==576))
 return &dv_profiles[2];
 
-if(   stype == 0
-   && codec
-   && (codec->codec_tag==AV_RL32("dvsd") || codec->codec_tag==AV_RL32("CDVC"))
-   && codec->coded_width ==720
-   && codec->coded_height==576)
+/* hack for trac issues #8333 and #2177, PAL DV files with dsf flag 0 - detect via pal flag and buf_size */
+if (dsf == 0 && pal == 1 && stype == dv_profiles[1].video_stype && buf_size == dv_profiles[1].frame_size)
 return &dv_profiles[1];
 
 for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++)
-- 
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 6/6] avutil/adler32: Switch av_adler32_update() to size_t on bump

2021-03-18 Thread James Almer

On 3/18/2021 12:43 AM, Andreas Rheinhardt wrote:

av_adler32_update() is used by av_hash_update() which will be switched
to size_t at the next bump. So it also has to be made to use size_t.
This is also necessary for framecrcenc.c, because the size of side data
will become a size_t, too.

Signed-off-by: Andreas Rheinhardt 
---
  doc/APIchanges  |  5 +
  libavutil/adler32.c |  4 
  libavutil/adler32.h | 16 ++--
  libavutil/version.h |  2 +-
  4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 849d95a7ed..1782ae83fe 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil: 2017-10-21
  
  API changes, most recent first:
  
+2021-03-18 - xx - lavu 56.69.100 - adler32.h

+  av_adler32_update() will be changed to use uint32_t
+  for the Adler-32 checksums and size_t for the length
+  if the input buffer at the next bump.
+
  2021-03-xx - xx - lavc 58.133.100 - codec.h
Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will
no longer be a part of the public ABI.
diff --git a/libavutil/adler32.c b/libavutil/adler32.c
index c87d5e261c..5ed5ff55a3 100644
--- a/libavutil/adler32.c
+++ b/libavutil/adler32.c
@@ -41,8 +41,12 @@
  #define DO4(buf)  DO1(buf); DO1(buf); DO1(buf); DO1(buf);
  #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf);
  
+#if FF_API_CRYPTO_SIZE_T

  unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf,
  unsigned int len)
+#else
+AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len)
+#endif
  {
  unsigned long s1 = adler & 0x;
  unsigned long s2 = adler >> 16;
diff --git a/libavutil/adler32.h b/libavutil/adler32.h
index a1f035b734..e7a8f83729 100644
--- a/libavutil/adler32.h
+++ b/libavutil/adler32.h
@@ -27,8 +27,10 @@
  #ifndef AVUTIL_ADLER32_H
  #define AVUTIL_ADLER32_H
  
+#include 

  #include 
  #include "attributes.h"
+#include "version.h"
  
  /**

   * @defgroup lavu_adler32 Adler-32
@@ -38,6 +40,12 @@
   * @{
   */
  
+#if FF_API_CRYPTO_SIZE_T

+typedef unsigned long AVAdler;
+#else
+typedef uint32_t AVAdler;


This typedef should be mentioned as added in the APIChanges entry.


+#endif
+
  /**
   * Calculate the Adler32 checksum of a buffer.
   *
@@ -50,8 +58,12 @@
   * @param len   size of input buffer
   * @return  updated checksum
   */
-unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
-unsigned int len) av_pure;
+AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf,
+#if FF_API_CRYPTO_SIZE_T
+  unsigned int len) av_pure;
+#else
+  size_t len) av_pure;
+#endif
  
  /**

   * @}
diff --git a/libavutil/version.h b/libavutil/version.h
index 9a290d57e7..f357f6165e 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
   */
  
  #define LIBAVUTIL_VERSION_MAJOR  56

-#define LIBAVUTIL_VERSION_MINOR  68
+#define LIBAVUTIL_VERSION_MINOR  69
  #define LIBAVUTIL_VERSION_MICRO 100
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \




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

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

Re: [FFmpeg-devel] [PATCH v3] avcodec: add Actimagine VX video decoder

2021-03-18 Thread Andreas Rheinhardt
Florian Nouwt:
> Signed-off-by: Florian Nouwt 
> ---
>  Changelog   |1 +
>  configure   |1 +
>  doc/general_contents.texi   |2 +
>  libavcodec/Makefile |3 +-
>  libavcodec/actimagine_vx.c  | 1150 +++
>  libavcodec/actimagine_vx_data.c |   45 ++
>  libavcodec/actimagine_vx_data.h |   28 +
>  libavcodec/allcodecs.c  |1 +
>  libavcodec/codec_desc.c |7 +
>  libavcodec/codec_id.h   |1 +
>  libavcodec/h264_cavlc.c |  205 +-
>  libavcodec/h264_cavlc_data.c|  220 ++
>  libavcodec/h264_cavlc_data.h|   50 ++
>  libavcodec/version.h|2 +-
>  libavformat/riff.c  |2 +
>  15 files changed, 1524 insertions(+), 194 deletions(-)
>  create mode 100644 libavcodec/actimagine_vx.c
>  create mode 100644 libavcodec/actimagine_vx_data.c
>  create mode 100644 libavcodec/actimagine_vx_data.h
>  create mode 100644 libavcodec/h264_cavlc_data.c
>  create mode 100644 libavcodec/h264_cavlc_data.h
> 
> diff --git a/Changelog b/Changelog
> index a96e350e09..8807f3dcb3 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -83,6 +83,7 @@ version :
>  - msad video filter
>  - gophers protocol
>  - RIST protocol via librist
> +- Actimagine VX video decoder
>  
>  
>  version 4.3:
> diff --git a/configure b/configure
> index f0ac719d2d..c38066bc1c 100755
> --- a/configure
> +++ b/configure
> @@ -2662,6 +2662,7 @@ ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp 
> mdct"
>  ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
>  ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
>  acelp_kelvin_decoder_select="audiodsp"
> +actimagine_vx_decoder_select="bswapdsp golomb h264dsp h264pred"
>  adpcm_g722_decoder_select="g722dsp"
>  adpcm_g722_encoder_select="g722dsp"
>  aic_decoder_select="golomb idctdsp"
> diff --git a/doc/general_contents.texi b/doc/general_contents.texi
> index 33ece6e884..d4261386fc 100644
> --- a/doc/general_contents.texi
> +++ b/doc/general_contents.texi
> @@ -807,6 +807,8 @@ following image formats are supported:
>  @item 8088flex TMV   @tab @tab  X
>  @item A64 multicolor @tab  X  @tab
>  @tab Creates video suitable to be played on a commodore 64 (multicolor 
> mode).
> +@item Actimagine VX Video@tab @tab  X
> +@tab fourcc: vxs1, VXS1
>  @item Amazing Studio PAF Video @tab @tab  X
>  @item American Laser Games MM  @tab@tab X
>  @tab Used in games like Mad Dog McCree.
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 81cc16471b..0bdeb9fc26 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -182,6 +182,7 @@ OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o 
> ac3enc.o ac3tab.o \
>  OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o ac3enc.o ac3tab.o 
> ac3.o kbdwin.o
>  OBJS-$(CONFIG_AC3_MF_ENCODER)  += mfenc.o mf_utils.o
>  OBJS-$(CONFIG_ACELP_KELVIN_DECODER)+= g729dec.o lsp.o celp_math.o 
> celp_filters.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o 
> g729postfilter.o
> +OBJS-$(CONFIG_ACTIMAGINE_VX_DECODER)   += actimagine_vx.o 
> actimagine_vx_data.o h264_cavlc_data.o
>  OBJS-$(CONFIG_AGM_DECODER) += agm.o
>  OBJS-$(CONFIG_AIC_DECODER) += aic.o
>  OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o alacdsp.o
> @@ -367,7 +368,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o 
> h264_cabac.o h264_cavlc.o \
>h264_direct.o h264_loopfilter.o  \
>h264_mb.o h264_picture.o \
>h264_refs.o h264_sei.o \
> -  h264_slice.o h264data.o
> +  h264_slice.o h264data.o 
> h264_cavlc_data.o
>  OBJS-$(CONFIG_H264_AMF_ENCODER)+= amfenc_h264.o
>  OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuviddec.o
>  OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o
> diff --git a/libavcodec/actimagine_vx.c b/libavcodec/actimagine_vx.c
> new file mode 100644
> index 00..84871a1008
> --- /dev/null
> +++ b/libavcodec/actimagine_vx.c
> @@ -0,0 +1,1150 @@
> +/*
> + * Actimagine VX Video decoder
> + * Copyright (c) 2021 Florian Nouwt
> + *
> + * 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 

Re: [FFmpeg-devel] [PATCH v3] avcodec: add Actimagine VX video decoder

2021-03-18 Thread Zane van Iperen



On 18/3/21 8:31 pm, Florian Nouwt wrote:

diff --git a/libavformat/riff.c b/libavformat/riff.c
index 270ff7c024..848b1d6cfd 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -496,6 +496,8 @@ const AVCodecTag ff_codec_bmp_tags[] = {
  { AV_CODEC_ID_MVHA, MKTAG('M', 'V', 'H', 'A') },
  { AV_CODEC_ID_MV30, MKTAG('M', 'V', '3', '0') },
  { AV_CODEC_ID_NOTCHLC,  MKTAG('n', 'l', 'c', '1') },
+{ AV_CODEC_ID_ACTIMAGINE_VX,MKTAG('V', 'X', 'S', '1') },
+{ AV_CODEC_ID_ACTIMAGINE_VX,MKTAG('v', 'x', 's', '1') },
  { AV_CODEC_ID_NONE, 0 }
  };
  



Minor nit: Since this touches libavformat as well, it should probably be in a 
separate commit.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] avcodec: add Actimagine VX video decoder

2021-03-18 Thread Florian Nouwt
Andreas Rheinhardt:

- Why are these tables not internal to actimagine_vx.c?

I separated the data because for parsing the vx container files I will
need a parser, which will be in a separate file from the decoder and
requires those tables.

- You wasted an opportunity to add a space before '=' (this code is
old and does not match the currently preferred style).

Just to have it clear, when it comes to the tables, is the preferred
style with the brace on the next line or on the same line? And am I
supposed to fix all style errors in that file?

- In case the actimagine_vx decoder is disabled and only the H.264
decoder is enabled (I expect this to happen for lots of slim builds),
one does not need to use an ff_thread_once() here at all, because
ff_h264_decode_init_vlc is already guarded this way. Can you add
compile-time checks for this?

It would remove some safety ofc. But I guess I can put a comment in
the header file that tells any potential future people that might use
it to not forget to change it.

Zane van Iperen:
Should I submit that as a separate patch then after the current one
minus that change has been accepted? Without that change it's
impossible to test the decoder.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3] avcodec: add Actimagine VX video decoder

2021-03-18 Thread Andreas Rheinhardt
Florian Nouwt:
> Andreas Rheinhardt:
> 
> - Why are these tables not internal to actimagine_vx.c?
> 
> I separated the data because for parsing the vx container files I will
> need a parser, which will be in a separate file from the decoder and
> requires those tables.
> 
> - You wasted an opportunity to add a space before '=' (this code is
> old and does not match the currently preferred style).
> 
> Just to have it clear, when it comes to the tables, is the preferred
> style with the brace on the next line or on the same line? And am I
> supposed to fix all style errors in that file?

I don't have a preference for next line vs same line, but I don't like
something like
}
};
as happens in ff_h264_cavlc_coeff_token_*.
When you change a line, you should fix style issues in said line at the
same time. You are not supposed to touch other lines just to fix style
issues. Such things should be in a separate commit, if at all (after
all, they make using git blame harder).

> 
> - In case the actimagine_vx decoder is disabled and only the H.264
> decoder is enabled (I expect this to happen for lots of slim builds),
> one does not need to use an ff_thread_once() here at all, because
> ff_h264_decode_init_vlc is already guarded this way. Can you add
> compile-time checks for this?
> 
> It would remove some safety ofc. But I guess I can put a comment in
> the header file that tells any potential future people that might use
> it to not forget to change it.
> 

Fine.

- 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] added parameter to dash encoder for start available time

2021-03-18 Thread Jan Ekström
On Thu, Mar 18, 2021 at 3:49 AM Jerome Berclaz  wrote:
>
> ---
>  libavformat/dashenc.c | 28 
>  1 file changed, 20 insertions(+), 8 deletions(-)

So right now we do have an option in ffmpeg.c called itsoffset. It
lets you configure the input offset in time (seconds - such as
"1337.123" or time format - such as "00:00:01.123"). The only problem
with it right now is that unless you set -copyts it will not get
applied for anything else than subtitles, as the offset gets applied
before and is not taken into account in the "start from PTS 0"
calculation for video/audio streams. I have been meaning to do some
git blaming and asking the people still around who added that logic,
if that was really meant - since as far as I can tell even people such
as Martin actually recommended me this option - probably expecting for
it to work.

If we just make itsoffset usable without copyts (just take it into
mention in the zero'ification process), I think all these options in
the output modules would effectively become unnecessary, since your
DTS/PTS will start from nonzero positive value depending on the
itsoffset.

Best regards,
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] added parameter to dash encoder for start available time

2021-03-18 Thread Gyan Doshi



On 2021-03-18 20:12, Jan Ekström wrote:

So right now we do have an option in ffmpeg.c called itsoffset. It
lets you configure the input offset in time (seconds - such as
"1337.123" or time format - such as "00:00:01.123"). The only problem
with it right now is that unless you set -copyts it will not get
applied for anything else than subtitles, as the offset gets applied
before and is not taken into account in the "start from PTS 0"
calculation for video/audio streams.


Not the case.

    ffmpeg -f lavfi -itsoffset 3 -i nullsrc=r=1:d=3 -vf showinfo -f null -

gives

[Parsed_showinfo_0 @ 019cc1b88540] n:   0 pts:  3 pts_time:3   ...
[Parsed_showinfo_0 @ 019cc1b88540] n:   1 pts:  4 pts_time:4   ...
[Parsed_showinfo_0 @ 019cc1b88540] n:   2 pts:  5 pts_time:5   ...

I've used it many times to adjust sync among streams.

Regards,
Gyan
___
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] added parameter to dash encoder for start available time

2021-03-18 Thread Jan Ekström
On Thu, Mar 18, 2021, 17:01 Gyan Doshi  wrote:

>
>
> On 2021-03-18 20:12, Jan Ekström wrote:
> > So right now we do have an option in ffmpeg.c called itsoffset. It
> > lets you configure the input offset in time (seconds - such as
> > "1337.123" or time format - such as "00:00:01.123"). The only problem
> > with it right now is that unless you set -copyts it will not get
> > applied for anything else than subtitles, as the offset gets applied
> > before and is not taken into account in the "start from PTS 0"
> > calculation for video/audio streams.
>
> Not the case.
>
>  ffmpeg -f lavfi -itsoffset 3 -i nullsrc=r=1:d=3 -vf showinfo -f null -
>
> gives
>
> [Parsed_showinfo_0 @ 019cc1b88540] n:   0 pts:  3 pts_time:3   ...
> [Parsed_showinfo_0 @ 019cc1b88540] n:   1 pts:  4 pts_time:4   ...
> [Parsed_showinfo_0 @ 019cc1b88540] n:   2 pts:  5 pts_time:5   ...
>
> I've used it many times to adjust sync among streams.
>
> Regards,
> Gyan
>

Very interesting!

I will have to retest, I just recall that the last time I tried it got
applied when there were multiple streams in an input when the start_time
based adjustment was done.

Jan

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

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

[FFmpeg-devel] [PATCH 1/2] avformat/mov: Fix extended atom size buffer length check

2021-03-18 Thread Derek Buitenhuis
When extended atom size support was added to probing in
fec4a2d232d7ebf6d1084fb568d4d84844f25abc, the buffer
size check was backwards, but probing continued to work
because there was no minimum size check yet, so despite
size being 1 on these atoms, and failing to read the 64-bit
size, the tag was still correctly read.

When 0b78016b2d7c36b32d07669c0c86bc4b4225ec98 introduced a
minimum size check, this exposed the bug, and broke probing
any files with extended atom sizes, such as entirely valid
large files that start whith mdat atoms.

Signed-off-by: Derek Buitenhuis 
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 97857789f4..33cfb42228 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7114,7 +7114,7 @@ static int mov_probe(const AVProbeData *p)
 if ((offset + 8) > (unsigned int)p->buf_size)
 break;
 size = AV_RB32(p->buf + offset);
-if (size == 1 && offset + 16 > (unsigned int)p->buf_size) {
+if (size == 1 && offset + 16 <= (unsigned int)p->buf_size) {
 size = AV_RB64(p->buf+offset + 8);
 minsize = 16;
 } else if (size == 0) {
-- 
2.30.0

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

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

[FFmpeg-devel] [PATCH 2/2] FATE: Add test for probing MOV/MP4 files with extended box sizes

2021-03-18 Thread Derek Buitenhuis
The test sample has to have no file extension, otherwise probing
happens to work, based off file extension alone, and we want to
test the actual proobing function.

Signed-off-by: Derek Buitenhuis 
---
I will reply to this email with the sample file in question.
---
 tests/fate/mov.mak   | 3 +++
 tests/ref/fate/mov-mp4-extended-atom | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 tests/ref/fate/mov-mp4-extended-atom

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 0fd20fef96..e2dbd6ab10 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -29,6 +29,7 @@ FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
fate-mov-guess-delay-2 \
fate-mov-guess-delay-3 \
fate-mov-mp4-with-mov-in24-ver \
+   fate-mov-mp4-extended-atom
 
 FATE_MOV_FASTSTART = fate-mov-faststart-4gb-overflow \
 
@@ -124,3 +125,5 @@ fate-mov-faststart-4gb-overflow: CMP = oneline
 fate-mov-faststart-4gb-overflow: REF = bc875921f151871e787c4b4023269b29
 
 fate-mov-mp4-with-mov-in24-ver: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
-show_entries stream=codec_name -select_streams 1 
$(TARGET_SAMPLES)/mov/mp4-with-mov-in24-ver.mp4
+
+fate-mov-mp4-extended-atom: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
-show_packets -print_format compact -select_streams v 
$(TARGET_SAMPLES)/mov/extended_atom_size_probe
diff --git a/tests/ref/fate/mov-mp4-extended-atom 
b/tests/ref/fate/mov-mp4-extended-atom
new file mode 100644
index 00..9d01abb2f5
--- /dev/null
+++ b/tests/ref/fate/mov-mp4-extended-atom
@@ -0,0 +1 @@
+packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=0|dts_time=0.00|duration=1001|duration_time=0.033367|size=14798|pos=16|flags=K_
-- 
2.30.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 2/2] FATE: Add test for probing MOV/MP4 files with extended box sizes

2021-03-18 Thread Derek Buitenhuis
On 18/03/2021 16:14, Derek Buitenhuis wrote:
> The test sample has to have no file extension, otherwise probing
> happens to work, based off file extension alone, and we want to
> test the actual proobing function.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
> I will reply to this email with the sample file in question.
> ---

I've attached the sample file to this email, as it's quite small.

Could someone add it to the FATE rsync server? In theory I have
access to do this, but I have no idea how to, and there are no
docs AFAIK.

- Derek


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

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

Re: [FFmpeg-devel] [PATCH 2/2] FATE: Add test for probing MOV/MP4 files with extended box sizes

2021-03-18 Thread Andreas Rheinhardt
Derek Buitenhuis:
> The test sample has to have no file extension, otherwise probing
> happens to work, based off file extension alone, and we want to
> test the actual proobing function.
 ^
> 
> Signed-off-by: Derek Buitenhuis 
> ---
> I will reply to this email with the sample file in question.
> ---
>  tests/fate/mov.mak   | 3 +++
>  tests/ref/fate/mov-mp4-extended-atom | 1 +
>  2 files changed, 4 insertions(+)
>  create mode 100644 tests/ref/fate/mov-mp4-extended-atom
> 
> diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
> index 0fd20fef96..e2dbd6ab10 100644
> --- a/tests/fate/mov.mak
> +++ b/tests/fate/mov.mak
> @@ -29,6 +29,7 @@ FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
> fate-mov-guess-delay-2 \
> fate-mov-guess-delay-3 \
> fate-mov-mp4-with-mov-in24-ver \
> +   fate-mov-mp4-extended-atom

If you don't add the line continuation here, the next one will have to
modify the line you just added.

>  
>  FATE_MOV_FASTSTART = fate-mov-faststart-4gb-overflow \
>  
> @@ -124,3 +125,5 @@ fate-mov-faststart-4gb-overflow: CMP = oneline
>  fate-mov-faststart-4gb-overflow: REF = bc875921f151871e787c4b4023269b29
>  
>  fate-mov-mp4-with-mov-in24-ver: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
> -show_entries stream=codec_name -select_streams 1 
> $(TARGET_SAMPLES)/mov/mp4-with-mov-in24-ver.mp4
> +
> +fate-mov-mp4-extended-atom: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
> -show_packets -print_format compact -select_streams v 
> $(TARGET_SAMPLES)/mov/extended_atom_size_probe
> diff --git a/tests/ref/fate/mov-mp4-extended-atom 
> b/tests/ref/fate/mov-mp4-extended-atom
> new file mode 100644
> index 00..9d01abb2f5
> --- /dev/null
> +++ b/tests/ref/fate/mov-mp4-extended-atom
> @@ -0,0 +1 @@
> +packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=0|dts_time=0.00|duration=1001|duration_time=0.033367|size=14798|pos=16|flags=K_
> 

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

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

Re: [FFmpeg-devel] [PATCH 2/2] FATE: Add test for probing MOV/MP4 files with extended box sizes

2021-03-18 Thread Derek Buitenhuis
On 18/03/2021 16:14, Derek Buitenhuis wrote:
> The test sample has to have no file extension, otherwise probing
> happens to work, based off file extension alone, and we want to
> test the actual proobing function.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
> I will reply to this email with the sample file in question.
> ---

I've attached the sample file to this email, as it's quite small.

Could someone add it to the FATE rsync server? In theory I have
access to do this, but I have no idea how to, and there are no
docs AFAIK.

- Derek


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

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

[FFmpeg-devel] [PATCH 2/2 v2] FATE: Add test for probing MOV/MP4 files with extended box sizes

2021-03-18 Thread Derek Buitenhuis
The test sample has to have no file extension, otherwise probing
happens to work, based off file extension alone, and we want to
test the actual probing function.

Signed-off-by: Derek Buitenhuis 
---
New features:
* Less typos
* A backslash
---
 tests/fate/mov.mak   | 3 +++
 tests/ref/fate/mov-mp4-extended-atom | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 tests/ref/fate/mov-mp4-extended-atom

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 0fd20fef96..957bd5ca4e 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -29,6 +29,7 @@ FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
fate-mov-guess-delay-2 \
fate-mov-guess-delay-3 \
fate-mov-mp4-with-mov-in24-ver \
+   fate-mov-mp4-extended-atom \
 
 FATE_MOV_FASTSTART = fate-mov-faststart-4gb-overflow \
 
@@ -124,3 +125,5 @@ fate-mov-faststart-4gb-overflow: CMP = oneline
 fate-mov-faststart-4gb-overflow: REF = bc875921f151871e787c4b4023269b29
 
 fate-mov-mp4-with-mov-in24-ver: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
-show_entries stream=codec_name -select_streams 1 
$(TARGET_SAMPLES)/mov/mp4-with-mov-in24-ver.mp4
+
+fate-mov-mp4-extended-atom: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
-show_packets -print_format compact -select_streams v 
$(TARGET_SAMPLES)/mov/extended_atom_size_probe
diff --git a/tests/ref/fate/mov-mp4-extended-atom 
b/tests/ref/fate/mov-mp4-extended-atom
new file mode 100644
index 00..9d01abb2f5
--- /dev/null
+++ b/tests/ref/fate/mov-mp4-extended-atom
@@ -0,0 +1 @@
+packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=0|dts_time=0.00|duration=1001|duration_time=0.033367|size=14798|pos=16|flags=K_
-- 
2.30.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 2/2] FATE: Add test for probing MOV/MP4 files with extended box sizes

2021-03-18 Thread Derek Buitenhuis
On 18/03/2021 16:50, Andreas Rheinhardt wrote:
>> The test sample has to have no file extension, otherwise probing
>> happens to work, based off file extension alone, and we want to
>> test the actual proobing function.
>  ^

[...]

>> fate-mov-mp4-with-mov-in24-ver \
>> +   fate-mov-mp4-extended-atom
> 
> If you don't add the line continuation here, the next one will have to
> modify the line you just added.

Both fixed, and v2 sent.

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

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

[FFmpeg-devel] Patch for ticket #9151

2021-03-18 Thread Dominic Mayers
Hello,

Ticket #9151
Applies to:

ffmpeg version N-101612-gda12d600ea Copyright (c) 2000-2021 the FFmpeg 
developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)

Compiled ffmpeg to include libtesseract by adding --enable-libtesseract
to the configuration

Issue:
The current version of libavfilter/vf_ocr.c does not have white space in
the default white list.
But it is recommanded to include white space:
https://github.com/tesseract-ocr/tesseract/issues/2923

I attached a patch.

Dominic


>From d71df8748556269e14ce7fa2bb5a2f639ac05d4b Mon Sep 17 00:00:00 2001
From: Dominic Mayers 
Date: Thu, 18 Mar 2021 15:52:53 -0400
Subject: [PATCH] Added white space to white list of libtesseract.

---
 libavfilter/vf_ocr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_ocr.c b/libavfilter/vf_ocr.c
index d5f76059b7..c7ccb4a84f 100644
--- a/libavfilter/vf_ocr.c
+++ b/libavfilter/vf_ocr.c
@@ -43,7 +43,7 @@ typedef struct OCRContext {
 static const AVOption ocr_options[] = {
 { "datapath",  "set datapath",OFFSET(datapath),  AV_OPT_TYPE_STRING, {.str=NULL},  0, 0, FLAGS },
 { "language",  "set language",OFFSET(language),  AV_OPT_TYPE_STRING, {.str="eng"}, 0, 0, FLAGS },
-{ "whitelist", "set character whitelist", OFFSET(whitelist), AV_OPT_TYPE_STRING, {.str="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.:;,-+_!?\"'[]{}()<>|/\\=*&%$#@!~"}, 0, 0, FLAGS },
+{ "whitelist", "set character whitelist", OFFSET(whitelist), AV_OPT_TYPE_STRING, {.str="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.:;,-+_!?\"'[]{}()<>|/\\=*&%$#@!~ "}, 0, 0, FLAGS },
 { "blacklist", "set character blacklist", OFFSET(blacklist), AV_OPT_TYPE_STRING, {.str=""},0, 0, FLAGS },
 { 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] [PATCH] Make font shaping a shared subtitle filter option

2021-03-18 Thread yorwba
Commit 4b58349bc8ff2ff5dfbc9eef1e5856fd16e1f517 introduced a new option
for selecting the font shaping engine used for rendering ASS subtitles.
However, the shaping value was used in code shared with the ordinary
subtitles filter (config_input in vf_subtitles.c), where it is left
uninitialized, as opposed to defaulting to -1. This means that the
subtitles filter is forced to use the "simple" shaping engine instead of
automatically selecting the best available option. As a result, Indic
scripts requiring "complex" shaping are not rendered correctly. This was
reported as bug #8738. (Aside: Thanks to cehoyos for pointing to the
responsible commit on the bug tracker.)

Because I don't see a reason why font shaping should be an ASS-only
option (especially considering the implementation was already shared),
I moved it into the common options.

Signed-off-by: Yorwba 
---
 doc/filters.texi   | 35 +++
 libavfilter/vf_subtitles.c |  8 
 2 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 30dee5531d..36a9e7613a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7099,26 +7099,6 @@ Same as the @ref{subtitles} filter, except that it 
doesn't require libavcodec
 and libavformat to work. On the other hand, it is limited to ASS (Advanced
 Substation Alpha) subtitles files.
 
-This filter accepts the following option in addition to the common options from
-the @ref{subtitles} filter:
-
-@table @option
-@item shaping
-Set the shaping engine
-
-Available values are:
-@table @samp
-@item auto
-The default libass shaping engine, which is the best available.
-@item simple
-Fast, font-agnostic shaper that can do only substitutions
-@item complex
-Slower shaper using OpenType for substitutions and positioning
-@end table
-
-The default is @code{auto}.
-@end table
-
 @section atadenoise
 Apply an Adaptive Temporal Averaging Denoiser to the video input.
 
@@ -19227,6 +19207,21 @@ These fonts will be used in addition to whatever the 
font provider uses.
 @item alpha
 Process alpha channel, by default alpha channel is untouched.
 
+@item shaping
+Set the shaping engine
+
+Available values are:
+@table @samp
+@item auto
+The default libass shaping engine, which is the best available.
+@item simple
+Fast, font-agnostic shaper that can do only substitutions
+@item complex
+Slower shaper using OpenType for substitutions and positioning
+@end table
+
+The default is @code{auto}.
+
 @item charenc
 Set subtitles input character encoding. @code{subtitles} filter only. Only
 useful if not UTF-8.
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index de74afa2b7..1c10bd6aad 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -71,6 +71,10 @@ typedef struct AssContext {
 {"original_size",  "set the size of the original video (used to scale 
fonts)", OFFSET(original_w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL},  0, 0, 
FLAGS }, \
 {"fontsdir",   "set the directory containing the fonts to read",   
OFFSET(fontsdir),   AV_OPT_TYPE_STRING, {.str = NULL},  0, 0, FLAGS }, \
 {"alpha",  "enable processing of alpha channel",   
OFFSET(alpha),  AV_OPT_TYPE_BOOL,   {.i64 = 0   }, 0,   
 1, FLAGS }, \
+{"shaping","set shaping engine",   
OFFSET(shaping),AV_OPT_TYPE_INT,{.i64 = -1  }, -1, 1, FLAGS, 
"shaping_mode"}, \
+{"auto",NULL,  0, AV_OPT_TYPE_CONST, {.i64 = -1},  
INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, \
+{"simple",  "simple shaping",  0, AV_OPT_TYPE_CONST, {.i64 = 
ASS_SHAPING_SIMPLE},  INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, \
+{"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = 
ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, \
 
 /* libass supports a log level ranging from 0 to 7 */
 static const int ass_libavfilter_log_level_map[] = {
@@ -216,10 +220,6 @@ static const AVFilterPad ass_outputs[] = {
 
 static const AVOption ass_options[] = {
 COMMON_OPTIONS
-{"shaping", "set shaping engine", OFFSET(shaping), AV_OPT_TYPE_INT, { .i64 
= -1 }, -1, 1, FLAGS, "shaping_mode"},
-{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1},  
INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
-{"simple",  "simple shaping",  0, AV_OPT_TYPE_CONST, {.i64 = 
ASS_SHAPING_SIMPLE},  INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
-{"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = 
ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
 {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] [PATCH 1/4] avformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb

2021-03-18 Thread Michael Niedermayer
Fixes: null pointer dereference
Fixes: 
31588/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6165716135968768

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

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index fa0599501a..48370fe5ce 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1288,7 +1288,7 @@ start_sync:
 AVStream *st1   = s->streams[1];
 AVIStream *ast1 = st1->priv_data;
 // workaround for broken small-file-bug402.avi
-if (   d[2] == 'w' && d[3] == 'b'
+if (ast1 && d[2] == 'w' && d[3] == 'b'
&& n == 0
&& st ->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
&& st1->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 3/4] avformat/movenc: Avoid loosing cluster array on failure

2021-03-18 Thread Michael Niedermayer
Fixes: crash
Fixes: check_pkt.mp4

Found-by: Rafael Dutra 
Signed-off-by: Michael Niedermayer 
---
 libavformat/movenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6790fe6c45..bade57dcea 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5746,11 +5746,12 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (trk->entry >= trk->cluster_capacity) {
 unsigned new_capacity = trk->entry + MOV_INDEX_CLUSTER_SIZE;
-if (av_reallocp_array(&trk->cluster, new_capacity,
-  sizeof(*trk->cluster))) {
+void *cluster = av_realloc_array(trk->cluster, new_capacity, 
sizeof(*trk->cluster));
+if (!cluster) {
 ret = AVERROR(ENOMEM);
 goto err;
 }
+trk->cluster  = cluster;
 trk->cluster_capacity = new_capacity;
 }
 
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 2/4] tools/target_dec_fuzzer: Adjust VP4 threshold

2021-03-18 Thread Michael Niedermayer
Fixes: Timeout (>10sec -> <100ms)
Fixes: 
31515/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP4_fuzzer-5247114134290432

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

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index f5a969b603..544f354421 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -192,6 +192,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 case AV_CODEC_ID_TRUEMOTION2: maxpixels  /= 1024;  break;
 case AV_CODEC_ID_VC1IMAGE:maxpixels  /= 8192;  break;
 case AV_CODEC_ID_VMNC:maxpixels  /= 8192;  break;
+case AV_CODEC_ID_VP4: maxpixels  /= 4096;  break;
 case AV_CODEC_ID_VP7: maxpixels  /= 256;   break;
 case AV_CODEC_ID_VP9: maxpixels  /= 4096;  break;
 case AV_CODEC_ID_WAVPACK: maxsamples /= 1024;  break;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 4/4] avcodec/mpegpicture: Keep ff_mpeg_framesize_alloc() failure state consistent

2021-03-18 Thread Michael Niedermayer
Fixes: null pointer dereference
Fixes: ff_put_pixels16_sse2.mp4

Found-by: Rafael Dutra 
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mpegpicture.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index e3f648895d..0652b7c879 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -79,8 +79,11 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, 
MotionEstContext *me,
 // linesize * interlaced * MBsize
 // we also use this buffer for encoding in encode_mb_internal() needig an 
additional 32 lines
 if (!FF_ALLOCZ_TYPED_ARRAY(sc->edge_emu_buffer, alloc_size * 
EMU_EDGE_HEIGHT) ||
-!FF_ALLOCZ_TYPED_ARRAY(me->scratchpad,  alloc_size * 4 * 16 * 2))
+!FF_ALLOCZ_TYPED_ARRAY(me->scratchpad,  alloc_size * 4 * 16 * 2)) {
+av_freep(&sc->edge_emu_buffer);
 return AVERROR(ENOMEM);
+}
+
 me->temp= me->scratchpad;
 sc->rd_scratchpad   = me->scratchpad;
 sc->b_scratchpad= me->scratchpad;
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] avformat/utils: Preserve AV_PKT_FLAG_CORRUPT

2021-03-18 Thread Marton Balint



On Wed, 17 Mar 2021, Pavel Koshevoy wrote:


Preserve AV_PKT_FLAG_CORRUPT so the caller can decide whether to drop
the packet.


LGTM, but Michael was against it last time:

https://patchwork.ffmpeg.org/project/ffmpeg/patch/20181009233214.8785-2-...@passwd.hu/

Regards,
Marton


---
libavformat/utils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index a73f944e6e..0dc978e3d2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1494,7 +1494,8 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
out_pkt->pts  = st->parser->pts;
out_pkt->dts  = st->parser->dts;
out_pkt->pos  = st->parser->pos;
-out_pkt->flags   |= pkt->flags & AV_PKT_FLAG_DISCARD;
+out_pkt->flags   |= pkt->flags & (AV_PKT_FLAG_CORRUPT |
+  AV_PKT_FLAG_DISCARD);

if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
out_pkt->pos = st->parser->frame_offset;
--
2.26.2

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

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

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/dv_profile: PAL DV files with dsf flag 0 - detect via pal flag and buf_size

2021-03-18 Thread Marton Balint



On Thu, 18 Mar 2021, Mark Plomer wrote:

Okay cool, I added the check for the PAL flag - this still works fine for my 
test-videos.


I also looked at the old hack above with the codec_tag check - changed in 
2013 for ticket #2177 (patch by Michael Niedermayer). I removed that more 
specific hack and the test-video attached to ticket #2177 also runs into the 
new hack now ... and still works fine. It also has a "dsf = 0" flag, though 
it is PAL.


So it was really a good idea to consolidate those hacks! Maybe the whole 
generic matching logic should be refactored, to match against the pal flag 
instead of the dsf flag? (The "buf_size" check may also be obsolete then). 
But this will be another task ;-)


I attached the updated patch.


It looks good to me, I will apply in a couple of days if nobody comments 
until then. Also Cc'd Dave, as he got probably the most experience with 
dv.


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

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

Re: [FFmpeg-devel] [PATCH 4/4] avcodec/mpegpicture: Keep ff_mpeg_framesize_alloc() failure state consistent

2021-03-18 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: null pointer dereference
> Fixes: ff_put_pixels16_sse2.mp4
> 
> Found-by: Rafael Dutra 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/mpegpicture.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
> index e3f648895d..0652b7c879 100644
> --- a/libavcodec/mpegpicture.c
> +++ b/libavcodec/mpegpicture.c
> @@ -79,8 +79,11 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, 
> MotionEstContext *me,
>  // linesize * interlaced * MBsize
>  // we also use this buffer for encoding in encode_mb_internal() needig 
> an additional 32 lines
>  if (!FF_ALLOCZ_TYPED_ARRAY(sc->edge_emu_buffer, alloc_size * 
> EMU_EDGE_HEIGHT) ||
> -!FF_ALLOCZ_TYPED_ARRAY(me->scratchpad,  alloc_size * 4 * 16 * 2))
> +!FF_ALLOCZ_TYPED_ARRAY(me->scratchpad,  alloc_size * 4 * 16 * 
> 2)) {
> +av_freep(&sc->edge_emu_buffer);
>  return AVERROR(ENOMEM);
> +}
> +
>  me->temp= me->scratchpad;
>  sc->rd_scratchpad   = me->scratchpad;
>  sc->b_scratchpad= me->scratchpad;
> 
This is a regression since 4b2863ff01b1fe93d9a518523c9098d17a9d8c6f, see
http://ffmpeg.org/pipermail/ffmpeg-devel/2020-December/274026.html.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/utils: Preserve AV_PKT_FLAG_CORRUPT

2021-03-18 Thread Pavel Koshevoy
On Thu, Mar 18, 2021 at 2:51 PM Marton Balint  wrote:

>
>
> On Wed, 17 Mar 2021, Pavel Koshevoy wrote:
>
> > Preserve AV_PKT_FLAG_CORRUPT so the caller can decide whether to drop
> > the packet.
>
> LGTM, but Michael was against it last time:
>
>
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20181009233214.8785-2-...@passwd.hu/
>
>
>

I have a source where a corrupt packet is able to poison the video decoder
so that the subsequent video is decoded with severe visual artifacts.  My
workaround is to detect corrupt packets, drop them and  re-create the video
decoder on the next non-corrupt packet.  This workaround is working well so
far.

Pavel.




> > ---
> > libavformat/utils.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index a73f944e6e..0dc978e3d2 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -1494,7 +1494,8 @@ static int parse_packet(AVFormatContext *s,
> AVPacket *pkt,
> > out_pkt->pts  = st->parser->pts;
> > out_pkt->dts  = st->parser->dts;
> > out_pkt->pos  = st->parser->pos;
> > -out_pkt->flags   |= pkt->flags & AV_PKT_FLAG_DISCARD;
> > +out_pkt->flags   |= pkt->flags & (AV_PKT_FLAG_CORRUPT |
> > +  AV_PKT_FLAG_DISCARD);
> >
> > if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
> > out_pkt->pos = st->parser->frame_offset;
> > --
> > 2.26.2
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/utils: Preserve AV_PKT_FLAG_CORRUPT

2021-03-18 Thread Pavel Koshevoy
On Thu, Mar 18, 2021 at 2:57 PM Pavel Koshevoy  wrote:

>
>
> On Thu, Mar 18, 2021 at 2:51 PM Marton Balint  wrote:
>
>>
>>
>> On Wed, 17 Mar 2021, Pavel Koshevoy wrote:
>>
>> > Preserve AV_PKT_FLAG_CORRUPT so the caller can decide whether to drop
>> > the packet.
>>
>> LGTM, but Michael was against it last time:
>>
>>
>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20181009233214.8785-2-...@passwd.hu/
>>
>>
>>
>
> I have a source where a corrupt packet is able to poison the video decoder
> so that the subsequent video is decoded with severe visual artifacts.  My
> workaround is to detect corrupt packets, drop them and  re-create the video
> decoder on the next non-corrupt packet.  This workaround is working well so
> far.
>
> Pavel.
>


Although, the video decoder being poisoned seems to be a regression in
ffmpeg ... the problem doesn't occur with ffmpeg git snapshot from
20190318, 15d016be30bd24cdba514c7c888e9da0286b5647

Pavel.
___
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] added parameter to dash encoder for start available time

2021-03-18 Thread Jan Ekström
On Thu, Mar 18, 2021 at 5:07 PM Jan Ekström  wrote:
>
> On Thu, Mar 18, 2021, 17:01 Gyan Doshi  wrote:
>>
>>
>>
>> On 2021-03-18 20:12, Jan Ekström wrote:
>> > So right now we do have an option in ffmpeg.c called itsoffset. It
>> > lets you configure the input offset in time (seconds - such as
>> > "1337.123" or time format - such as "00:00:01.123"). The only problem
>> > with it right now is that unless you set -copyts it will not get
>> > applied for anything else than subtitles, as the offset gets applied
>> > before and is not taken into account in the "start from PTS 0"
>> > calculation for video/audio streams.
>>
>> Not the case.
>>
>>  ffmpeg -f lavfi -itsoffset 3 -i nullsrc=r=1:d=3 -vf showinfo -f null -
>>
>> gives
>>
>> [Parsed_showinfo_0 @ 019cc1b88540] n:   0 pts:  3 pts_time:3   ...
>> [Parsed_showinfo_0 @ 019cc1b88540] n:   1 pts:  4 pts_time:4   ...
>> [Parsed_showinfo_0 @ 019cc1b88540] n:   2 pts:  5 pts_time:5   ...
>>
>> I've used it many times to adjust sync among streams.
>>
>> Regards,
>> Gyan
>
>
> Very interesting!
>
> I will have to retest, I just recall that the last time I tried it got 
> applied when there were multiple streams in an input when the start_time 
> based adjustment was done.

Right, so taking in a Matroska file it works fine, but when taking in
an MPEG-TS file with a start_time it not only transforms (start_time +
input_ts_offset) to (input_ts_offset), but just to 0 :) .

Example:
ffmpeg -v verbose -debug_ts -itsoffset "1616090389" -i
'https://megumin.fushizen.eu/samples/switchingaudio.ts' -c copy -bsf:a
aac_adtstoasc -movflags dash+frag_discont+delay_moov -vframes 5 -f mp4
- > test.mp4

Probed start_time:
  Duration: 00:00:15.25, start: 19516.478644, bitrate: 23823 kb/s

And how ffmpeg.c then adjusted it:
demuxer -> ist_index:2 type:audio next_dts:NOPTS next_dts_time:NOPTS
next_pts:NOPTS next_pts_time:NOPTS pkt_pts:1756483078
pkt_pts_time:19516.5 pkt_dts:1756483078 pkt_dts_time:19516.5
off:1616070872521356 off_time:1.61607e+09
demuxer+ffmpeg -> ist_index:2 type:audio pkt_pts:0 pkt_pts_time:0
pkt_dts:0 pkt_dts_time:0 off:-19516478644 off_time:-19516.5

Thus, ffmpeg.c is not only adjusting the timestamp to start at zero
with the start_time, but also takes the itsoffset off as well.

Best regards,
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 6/6] avutil/adler32: Switch av_adler32_update() to size_t on bump

2021-03-18 Thread Andreas Rheinhardt
James Almer:
> On 3/18/2021 12:43 AM, Andreas Rheinhardt wrote:
>> av_adler32_update() is used by av_hash_update() which will be switched
>> to size_t at the next bump. So it also has to be made to use size_t.
>> This is also necessary for framecrcenc.c, because the size of side data
>> will become a size_t, too.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>   doc/APIchanges  |  5 +
>>   libavutil/adler32.c |  4 
>>   libavutil/adler32.h | 16 ++--
>>   libavutil/version.h |  2 +-
>>   4 files changed, 24 insertions(+), 3 deletions(-)
>>
>> diff --git a/doc/APIchanges b/doc/APIchanges
>> index 849d95a7ed..1782ae83fe 100644
>> --- a/doc/APIchanges
>> +++ b/doc/APIchanges
>> @@ -15,6 +15,11 @@ libavutil: 2017-10-21
>>     API changes, most recent first:
>>   +2021-03-18 - xx - lavu 56.69.100 - adler32.h
>> +  av_adler32_update() will be changed to use uint32_t
>> +  for the Adler-32 checksums and size_t for the length
>> +  if the input buffer at the next bump.
>> +
>>   2021-03-xx - xx - lavc 58.133.100 - codec.h
>>     Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will
>>     no longer be a part of the public ABI.
>> diff --git a/libavutil/adler32.c b/libavutil/adler32.c
>> index c87d5e261c..5ed5ff55a3 100644
>> --- a/libavutil/adler32.c
>> +++ b/libavutil/adler32.c
>> @@ -41,8 +41,12 @@
>>   #define DO4(buf)  DO1(buf); DO1(buf); DO1(buf); DO1(buf);
>>   #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf);
>>   +#if FF_API_CRYPTO_SIZE_T
>>   unsigned long av_adler32_update(unsigned long adler, const uint8_t *
>> buf,
>>   unsigned int len)
>> +#else
>> +AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len)
>> +#endif
>>   {
>>   unsigned long s1 = adler & 0x;
>>   unsigned long s2 = adler >> 16;
>> diff --git a/libavutil/adler32.h b/libavutil/adler32.h
>> index a1f035b734..e7a8f83729 100644
>> --- a/libavutil/adler32.h
>> +++ b/libavutil/adler32.h
>> @@ -27,8 +27,10 @@
>>   #ifndef AVUTIL_ADLER32_H
>>   #define AVUTIL_ADLER32_H
>>   +#include 
>>   #include 
>>   #include "attributes.h"
>> +#include "version.h"
>>     /**
>>    * @defgroup lavu_adler32 Adler-32
>> @@ -38,6 +40,12 @@
>>    * @{
>>    */
>>   +#if FF_API_CRYPTO_SIZE_T
>> +typedef unsigned long AVAdler;
>> +#else
>> +typedef uint32_t AVAdler;
> 
> This typedef should be mentioned as added in the APIChanges entry.
> 

Will do and apply patches 1-2 and 6.

>> +#endif
>> +
>>   /**
>>    * Calculate the Adler32 checksum of a buffer.
>>    *
>> @@ -50,8 +58,12 @@
>>    * @param len   size of input buffer
>>    * @return  updated checksum
>>    */
>> -unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
>> -    unsigned int len) av_pure;
>> +AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf,
>> +#if FF_API_CRYPTO_SIZE_T
>> +  unsigned int len) av_pure;
>> +#else
>> +  size_t len) av_pure;
>> +#endif
>>     /**
>>    * @}
>> diff --git a/libavutil/version.h b/libavutil/version.h
>> index 9a290d57e7..f357f6165e 100644
>> --- a/libavutil/version.h
>> +++ b/libavutil/version.h
>> @@ -79,7 +79,7 @@
>>    */
>>     #define LIBAVUTIL_VERSION_MAJOR  56
>> -#define LIBAVUTIL_VERSION_MINOR  68
>> +#define LIBAVUTIL_VERSION_MINOR  69
>>   #define LIBAVUTIL_VERSION_MICRO 100
>>     #define LIBAVUTIL_VERSION_INT  
>> AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
>>
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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

Re: [FFmpeg-devel] [PATCH 1/4] avformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb

2021-03-18 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: null pointer dereference
> Fixes: 
> 31588/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6165716135968768
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/avidec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> index fa0599501a..48370fe5ce 100644
> --- a/libavformat/avidec.c
> +++ b/libavformat/avidec.c
> @@ -1288,7 +1288,7 @@ start_sync:
>  AVStream *st1   = s->streams[1];
>  AVIStream *ast1 = st1->priv_data;
>  // workaround for broken small-file-bug402.avi
> -if (   d[2] == 'w' && d[3] == 'b'
> +if (ast1 && d[2] == 'w' && d[3] == 'b'
> && n == 0
> && st ->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
> && st1->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
> 
How is this possible? After all, dv streams also have an AVIStream as
priv_data; and only the very first stream can ever be a dv stream due to
the check in line 605.

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

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

Re: [FFmpeg-devel] [PATCH 1/4] avformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb

2021-03-18 Thread Michael Niedermayer
On Fri, Mar 19, 2021 at 12:20:23AM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: null pointer dereference
> > Fixes: 
> > 31588/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6165716135968768
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/avidec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> > index fa0599501a..48370fe5ce 100644
> > --- a/libavformat/avidec.c
> > +++ b/libavformat/avidec.c
> > @@ -1288,7 +1288,7 @@ start_sync:
> >  AVStream *st1   = s->streams[1];
> >  AVIStream *ast1 = st1->priv_data;
> >  // workaround for broken small-file-bug402.avi
> > -if (   d[2] == 'w' && d[3] == 'b'
> > +if (ast1 && d[2] == 'w' && d[3] == 'b'
> > && n == 0
> > && st ->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
> > && st1->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
> > 
> How is this possible? After all, dv streams also have an AVIStream as

The DV demuxer creates streams in dv_extract_audio_info() without a AVIStream


> priv_data; and only the very first stream can ever be a dv stream due to
> the check in line 605.

I assume they are created after that check



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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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

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

Re: [FFmpeg-devel] [PATCH 1/4] avformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb

2021-03-18 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Fri, Mar 19, 2021 at 12:20:23AM +0100, Andreas Rheinhardt wrote:
>> Michael Niedermayer:
>>> Fixes: null pointer dereference
>>> Fixes: 
>>> 31588/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6165716135968768
>>>
>>> Found-by: continuous fuzzing process 
>>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>>> Signed-off-by: Michael Niedermayer 
>>> ---
>>>  libavformat/avidec.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
>>> index fa0599501a..48370fe5ce 100644
>>> --- a/libavformat/avidec.c
>>> +++ b/libavformat/avidec.c
>>> @@ -1288,7 +1288,7 @@ start_sync:
>>>  AVStream *st1   = s->streams[1];
>>>  AVIStream *ast1 = st1->priv_data;
>>>  // workaround for broken small-file-bug402.avi
>>> -if (   d[2] == 'w' && d[3] == 'b'
>>> +if (ast1 && d[2] == 'w' && d[3] == 'b'
>>> && n == 0
>>> && st ->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
>>> && st1->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
>>>
>> How is this possible? After all, dv streams also have an AVIStream as
> 
> The DV demuxer creates streams in dv_extract_audio_info() without a AVIStream
> 

That explains it. Thanks. Patch is fine by me, but I haven't looked at
it in detail. But neither dv nor avi set the AVFMTCTX_NOHEADER flag, so
adding streams later is an API violation.

> 
>> priv_data; and only the very first stream can ever be a dv stream due to
>> the check in line 605.
> 
> I assume they are created after that check
> 
> 

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

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

[FFmpeg-devel] [PATCH 1/4] avformat/tests/fifo_muxer: Fix leak of AVPacket on error

2021-03-18 Thread Andreas Rheinhardt
Also factor allocating and freeing the packet out.
Fixes Coverity issues #1473722 and #1473723; it is a regression
since 4b386b2059806ca7ee7f991d2c8b735410693e8c.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tests/fifo_muxer.c | 37 ++
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
index 3458c3eefd..e8970259c4 100644
--- a/libavformat/tests/fifo_muxer.c
+++ b/libavformat/tests/fifo_muxer.c
@@ -55,7 +55,7 @@ static int prepare_packet(AVPacket *pkt, const 
FailingMuxerPacketData *pkt_data,
 return ret;
 }
 
-static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc)
+static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc, AVPacket 
**pkt)
 {
 int ret = 0;
 AVStream *s;
@@ -71,22 +71,20 @@ static int initialize_fifo_tst_muxer_chain(AVFormatContext 
**oc)
 if (!s) {
 fprintf(stderr, "Failed to create stream: %s\n",
 av_err2str(ret));
-ret = AVERROR(ENOMEM);
+return AVERROR(ENOMEM);
 }
 
-return ret;
+*pkt = av_packet_alloc();
+if (!*pkt)
+return AVERROR(ENOMEM);
+
+return 0;
 }
 
 static int fifo_basic_test(AVFormatContext *oc, AVDictionary **opts,
- const FailingMuxerPacketData *pkt_data)
+   AVPacket *pkt, const FailingMuxerPacketData 
*pkt_data)
 {
 int ret = 0, i;
-AVPacket *pkt;
-
-pkt = av_packet_alloc();
-if (!pkt)
-return AVERROR(ENOMEM);
-
 
 ret = avformat_write_header(oc, opts);
 if (ret) {
@@ -107,11 +105,9 @@ static int fifo_basic_test(AVFormatContext *oc, 
AVDictionary **opts,
 if (ret < 0) {
 fprintf(stderr, "Unexpected write_frame error: %s\n",
 av_err2str(ret));
-av_packet_free(&pkt);
 goto write_trailer_and_fail;
 }
 }
-av_packet_free(&pkt);
 
 ret = av_write_frame(oc, NULL);
 if (ret < 0) {
@@ -135,15 +131,10 @@ fail:
 }
 
 static int fifo_overflow_drop_test(AVFormatContext *oc, AVDictionary **opts,
-   const FailingMuxerPacketData *data)
+   AVPacket *pkt, const FailingMuxerPacketData 
*data)
 {
 int ret = 0, i;
 int64_t write_pkt_start, write_pkt_end, duration;
-AVPacket *pkt;
-
-pkt = av_packet_alloc();
-if (!pkt)
-return AVERROR(ENOMEM);
 
 ret = avformat_write_header(oc, opts);
 if (ret) {
@@ -166,7 +157,6 @@ static int fifo_overflow_drop_test(AVFormatContext *oc, 
AVDictionary **opts,
 break;
 }
 }
-av_packet_free(&pkt);
 
 write_pkt_end = av_gettime_relative();
 duration = write_pkt_end - write_pkt_start;
@@ -193,7 +183,8 @@ fail:
 }
 
 typedef struct TestCase {
-int (*test_func)(AVFormatContext *, AVDictionary **,const 
FailingMuxerPacketData *pkt_data);
+int (*test_func)(AVFormatContext *, AVDictionary **,
+ AVPacket *, const FailingMuxerPacketData *pkt_data);
 const char *test_name;
 const char *options;
 
@@ -211,10 +202,11 @@ static int run_test(const TestCase *test)
 {
 AVDictionary *opts = NULL;
 AVFormatContext *oc = NULL;
+AVPacket *pkt = NULL;
 char buffer[BUFFER_SIZE];
 int ret, ret1;
 
-ret = initialize_fifo_tst_muxer_chain(&oc);
+ret = initialize_fifo_tst_muxer_chain(&oc, &pkt);
 if (ret < 0) {
 fprintf(stderr, "Muxer initialization failed: %s\n", av_err2str(ret));
 goto end;
@@ -240,11 +232,12 @@ static int run_test(const TestCase *test)
 goto end;
 }
 
-ret = test->test_func(oc, &opts, &test->pkt_data);
+ret = test->test_func(oc, &opts, pkt, &test->pkt_data);
 
 end:
 printf("%s: %s\n", test->test_name, ret < 0 ? "fail" : "ok");
 avformat_free_context(oc);
+av_packet_free(&pkt);
 av_dict_free(&opts);
 return ret;
 }
-- 
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/4] avformat/tests/fifo_muxer: Fix memleak on error, fix API violation

2021-03-18 Thread Andreas Rheinhardt
The test program for the FIFO muxer allocates a buffer without padding
and wraps it into a packet via av_packet_from_data(). This is an API
violation. Furthermore, said buffer leaks in case av_packet_from_data()
fails. Fix both of these issues by using av_new_packet() instead.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tests/fifo_muxer.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
index e8970259c4..227c3d0210 100644
--- a/libavformat/tests/fifo_muxer.c
+++ b/libavformat/tests/fifo_muxer.c
@@ -41,18 +41,15 @@ typedef struct FailingMuxerPacketData {
 
 static int prepare_packet(AVPacket *pkt, const FailingMuxerPacketData 
*pkt_data, int64_t pts)
 {
-int ret;
-FailingMuxerPacketData *data = av_malloc(sizeof(*data));
-if (!data) {
-return AVERROR(ENOMEM);
-}
-memcpy(data, pkt_data, sizeof(FailingMuxerPacketData));
-ret = av_packet_from_data(pkt, (uint8_t*) data, sizeof(*data));
+int ret = av_new_packet(pkt, sizeof(*pkt_data));
+if (ret < 0)
+return ret;
+memcpy(pkt->data, pkt_data, sizeof(*pkt_data));
 
 pkt->pts = pkt->dts = pts;
 pkt->duration = 1;
 
-return ret;
+return 0;
 }
 
 static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc, AVPacket 
**pkt)
-- 
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 3/4] avcodec/libxvid: Fix leak of AVPacket on error

2021-03-18 Thread Andreas Rheinhardt
Regression since 2101b99777860c853ca2321031eb3f4047dc5894.
Fixes Coverity issue #1473721.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/libxvid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 7dc6859571..25b0025d5f 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -692,8 +692,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return AVERROR(ENOMEM);
 
 picture = av_frame_alloc();
-if (!picture)
+if (!picture) {
+av_packet_free(&packet);
 return AVERROR(ENOMEM);
+}
 
 xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
 if( xerr ) {
-- 
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 4/4] avcodec/libxvid: Remove set-but-unused variable

2021-03-18 Thread Andreas Rheinhardt
Set-but-unused since 2101b99777860c853ca2321031eb3f4047dc5894.

Signed-off-by: Andreas Rheinhardt 
---
Before 2101b99777 the packet was only unreferenced on success
so that said commit seems to have fixed a potential memleak.

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

diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 25b0025d5f..50601807a7 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -685,7 +685,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (x->quicktime_format) {
 AVFrame *picture;
 AVPacket *packet;
-int size, got_packet, ret;
+int size, got_packet;
 
 packet = av_packet_alloc();
 if (!packet)
@@ -716,7 +716,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 picture->data[2] = picture->data[1] + size / 4;
 memset(picture->data[0], 0, size);
 memset(picture->data[1], 128, size / 2);
-ret = xvid_encode_frame(avctx, packet, picture, &got_packet);
+xvid_encode_frame(avctx, packet, picture, &got_packet);
 av_packet_free(&packet);
 av_free(picture->data[0]);
 av_frame_free(&picture);
-- 
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 3/4] avcodec/libxvid: Fix leak of AVPacket on error

2021-03-18 Thread James Almer

On 3/18/2021 9:52 PM, Andreas Rheinhardt wrote:

Regression since 2101b99777860c853ca2321031eb3f4047dc5894.
Fixes Coverity issue #1473721.

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/libxvid.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 7dc6859571..25b0025d5f 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -692,8 +692,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
  return AVERROR(ENOMEM);
  
  picture = av_frame_alloc();

-if (!picture)
+if (!picture) {
+av_packet_free(&packet);
  return AVERROR(ENOMEM);
+}
  
  xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);

  if( xerr ) {


You could also combine both checks, like so:


diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 7dc6859571..22c6025377 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -688,12 +688,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
 int size, got_packet, ret;

 packet = av_packet_alloc();
-if (!packet)
-return AVERROR(ENOMEM);
-
 picture = av_frame_alloc();
-if (!picture)
+if (!picture || !packet) {
+av_packet_free(&packet);
+av_frame_free(&picture);
 return AVERROR(ENOMEM);
+}

 xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
 if( xerr ) {


But it LGTM either way.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/4] avformat/tests/fifo_muxer: Fix leak of AVPacket on error

2021-03-18 Thread James Almer

On 3/18/2021 9:52 PM, Andreas Rheinhardt wrote:

Also factor allocating and freeing the packet out.
Fixes Coverity issues #1473722 and #1473723; it is a regression
since 4b386b2059806ca7ee7f991d2c8b735410693e8c.

Signed-off-by: Andreas Rheinhardt 
---
  libavformat/tests/fifo_muxer.c | 37 ++
  1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
index 3458c3eefd..e8970259c4 100644
--- a/libavformat/tests/fifo_muxer.c
+++ b/libavformat/tests/fifo_muxer.c
@@ -55,7 +55,7 @@ static int prepare_packet(AVPacket *pkt, const 
FailingMuxerPacketData *pkt_data,
  return ret;
  }
  
-static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc)

+static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc, AVPacket 
**pkt)
  {
  int ret = 0;
  AVStream *s;
@@ -71,22 +71,20 @@ static int initialize_fifo_tst_muxer_chain(AVFormatContext 
**oc)
  if (!s) {
  fprintf(stderr, "Failed to create stream: %s\n",
  av_err2str(ret));
-ret = AVERROR(ENOMEM);
+return AVERROR(ENOMEM);
  }
  
-return ret;

+*pkt = av_packet_alloc();
+if (!*pkt)
+return AVERROR(ENOMEM);
+
+return 0;
  }
  
  static int fifo_basic_test(AVFormatContext *oc, AVDictionary **opts,

- const FailingMuxerPacketData *pkt_data)
+   AVPacket *pkt, const FailingMuxerPacketData 
*pkt_data)
  {
  int ret = 0, i;
-AVPacket *pkt;
-
-pkt = av_packet_alloc();
-if (!pkt)
-return AVERROR(ENOMEM);
-
  
  ret = avformat_write_header(oc, opts);

  if (ret) {
@@ -107,11 +105,9 @@ static int fifo_basic_test(AVFormatContext *oc, 
AVDictionary **opts,
  if (ret < 0) {
  fprintf(stderr, "Unexpected write_frame error: %s\n",
  av_err2str(ret));
-av_packet_free(&pkt);
  goto write_trailer_and_fail;
  }
  }
-av_packet_free(&pkt);
  
  ret = av_write_frame(oc, NULL);

  if (ret < 0) {
@@ -135,15 +131,10 @@ fail:
  }
  
  static int fifo_overflow_drop_test(AVFormatContext *oc, AVDictionary **opts,

-   const FailingMuxerPacketData *data)
+   AVPacket *pkt, const FailingMuxerPacketData 
*data)
  {
  int ret = 0, i;
  int64_t write_pkt_start, write_pkt_end, duration;
-AVPacket *pkt;
-
-pkt = av_packet_alloc();
-if (!pkt)
-return AVERROR(ENOMEM);
  
  ret = avformat_write_header(oc, opts);

  if (ret) {
@@ -166,7 +157,6 @@ static int fifo_overflow_drop_test(AVFormatContext *oc, 
AVDictionary **opts,
  break;
  }
  }
-av_packet_free(&pkt);
  
  write_pkt_end = av_gettime_relative();

  duration = write_pkt_end - write_pkt_start;
@@ -193,7 +183,8 @@ fail:
  }
  
  typedef struct TestCase {

-int (*test_func)(AVFormatContext *, AVDictionary **,const 
FailingMuxerPacketData *pkt_data);
+int (*test_func)(AVFormatContext *, AVDictionary **,
+ AVPacket *, const FailingMuxerPacketData *pkt_data);
  const char *test_name;
  const char *options;
  
@@ -211,10 +202,11 @@ static int run_test(const TestCase *test)

  {
  AVDictionary *opts = NULL;
  AVFormatContext *oc = NULL;
+AVPacket *pkt = NULL;
  char buffer[BUFFER_SIZE];
  int ret, ret1;
  
-ret = initialize_fifo_tst_muxer_chain(&oc);

+ret = initialize_fifo_tst_muxer_chain(&oc, &pkt);
  if (ret < 0) {
  fprintf(stderr, "Muxer initialization failed: %s\n", av_err2str(ret));
  goto end;
@@ -240,11 +232,12 @@ static int run_test(const TestCase *test)
  goto end;
  }
  
-ret = test->test_func(oc, &opts, &test->pkt_data);

+ret = test->test_func(oc, &opts, pkt, &test->pkt_data);
  
  end:

  printf("%s: %s\n", test->test_name, ret < 0 ? "fail" : "ok");
  avformat_free_context(oc);
+av_packet_free(&pkt);
  av_dict_free(&opts);
  return ret;
  }


Should be ok if tested.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/6] avcodec/utils: Check earlier for codec id/type mismatch

2021-03-18 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> These fields can't be set via AVOptions, ergo one can check them before
> having allocated anything.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/utils.c | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 71dbcb19d8..2bc556c1d9 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -564,6 +564,18 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
> *avctx, const AVCodec *code
>  if (!codec)
>  codec = avctx->codec;
>  
> +if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == 
> codec->type) &&
> +avctx->codec_id == AV_CODEC_ID_NONE) {
> +avctx->codec_type = codec->type;
> +avctx->codec_id   = codec->id;
> +}
> +if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type &&
> + avctx->codec_type != 
> AVMEDIA_TYPE_ATTACHMENT)) {
> +av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
> +return AVERROR(EINVAL);
> +}
> +avctx->codec = codec;
> +
>  if (avctx->extradata_size < 0 || avctx->extradata_size >= 
> FF_MAX_EXTRADATA_SIZE)
>  return AVERROR(EINVAL);
>  
> @@ -682,18 +694,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
> *avctx, const AVCodec *code
>  goto free_and_end;
>  }
>  
> -avctx->codec = codec;
> -if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == 
> codec->type) &&
> -avctx->codec_id == AV_CODEC_ID_NONE) {
> -avctx->codec_type = codec->type;
> -avctx->codec_id   = codec->id;
> -}
> -if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
> - && avctx->codec_type != 
> AVMEDIA_TYPE_ATTACHMENT)) {
> -av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
> -ret = AVERROR(EINVAL);
> -goto free_and_end;
> -}
>  avctx->frame_number = 0;
>  avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id);
>  
> 
Will apply tonight 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".

[FFmpeg-devel] [PATCH] avcodec/libxvid: remove unnecessary output packet data check

2021-03-18 Thread James Almer
The user buffers passed to avcodec_encode_video2() haven't been propagated to
AVCodec.encode2 implementations since 93016f5d1d280f9cb7856883af287fa66affc04c.
Also, the generic encode code already unrefs the packet if nothing was encoded.

Signed-off-by: James Almer 
---
 libavcodec/libxvid.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 50601807a7..cb9135436a 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -738,7 +738,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
  const AVFrame *picture, int *got_packet)
 {
-int xerr, i, ret, user_packet = !!pkt->data;
+int xerr, i, ret;
 struct xvid_context *x = avctx->priv_data;
 int mb_width  = (avctx->width  + 15) / 16;
 int mb_height = (avctx->height + 15) / 16;
@@ -866,8 +866,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 return 0;
 } else {
-if (!user_packet)
-av_packet_unref(pkt);
 if (!xerr)
 return 0;
 av_log(avctx, AV_LOG_ERROR,
-- 
2.30.2

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

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

Re: [FFmpeg-devel] [PATCH v2 5/6] Fix printf specifiers for variables that will be switched to size_t

2021-03-18 Thread James Almer

On 3/18/2021 12:43 AM, Andreas Rheinhardt wrote:

diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index 552bc38b65..342cba6dd8 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -72,8 +72,13 @@ static int webvtt_write_packet(AVFormatContext *ctx, 
AVPacket *pkt)
  id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,
   &id_size);
  
-if (id && id_size > 0)

-avio_printf(pb, "%.*s\n", id_size, id);
+if (id && id_size > 0) {
+#if !FF_API_BUFFER_SIZE_T
+if (id_size > INT_MAX)
+return AVERROR(ERANGE);
+#endif
+avio_printf(pb, "%.*s\n", (int)id_size, id);
+}
  
  webvtt_write_time(pb, pkt->pts);

  avio_printf(pb, " --> ");
@@ -82,8 +87,13 @@ static int webvtt_write_packet(AVFormatContext *ctx, 
AVPacket *pkt)
  settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS,
 &settings_size);
  
-if (settings && settings_size > 0)

-avio_printf(pb, " %.*s", settings_size, settings);
+if (settings && settings_size > 0) {
+#if !FF_API_BUFFER_SIZE_T
+if (id_size > INT_MAX)


Looks like it should be settings_size.


+return AVERROR(ERANGE);
+#endif
+avio_printf(pb, " %.*s", (int)settings_size, settings);
+}
  
  avio_printf(pb, "\n");
  


___
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] added parameter to dash encoder for start available time

2021-03-18 Thread Gyan Doshi



On 2021-03-19 03:22, Jan Ekström wrote:

On Thu, Mar 18, 2021 at 5:07 PM Jan Ekström  wrote:

On Thu, Mar 18, 2021, 17:01 Gyan Doshi  wrote:



On 2021-03-18 20:12, Jan Ekström wrote:

So right now we do have an option in ffmpeg.c called itsoffset. It
lets you configure the input offset in time (seconds - such as
"1337.123" or time format - such as "00:00:01.123"). The only problem
with it right now is that unless you set -copyts it will not get
applied for anything else than subtitles, as the offset gets applied
before and is not taken into account in the "start from PTS 0"
calculation for video/audio streams.

Not the case.

  ffmpeg -f lavfi -itsoffset 3 -i nullsrc=r=1:d=3 -vf showinfo -f null -

gives

[Parsed_showinfo_0 @ 019cc1b88540] n:   0 pts:  3 pts_time:3   ...
[Parsed_showinfo_0 @ 019cc1b88540] n:   1 pts:  4 pts_time:4   ...
[Parsed_showinfo_0 @ 019cc1b88540] n:   2 pts:  5 pts_time:5   ...

I've used it many times to adjust sync among streams.

Regards,
Gyan


Very interesting!

I will have to retest, I just recall that the last time I tried it got applied 
when there were multiple streams in an input when the start_time based 
adjustment was done.

Right, so taking in a Matroska file it works fine, but when taking in
an MPEG-TS file with a start_time it not only transforms (start_time +
input_ts_offset) to (input_ts_offset), but just to 0 :) .

Example:
ffmpeg -v verbose -debug_ts -itsoffset "1616090389" -i
'https://megumin.fushizen.eu/samples/switchingaudio.ts' -c copy -bsf:a
aac_adtstoasc -movflags dash+frag_discont+delay_moov -vframes 5 -f mp4
- > test.mp4

Probed start_time:
   Duration: 00:00:15.25, start: 19516.478644, bitrate: 23823 kb/s

And how ffmpeg.c then adjusted it:
demuxer -> ist_index:2 type:audio next_dts:NOPTS next_dts_time:NOPTS
next_pts:NOPTS next_pts_time:NOPTS pkt_pts:1756483078
pkt_pts_time:19516.5 pkt_dts:1756483078 pkt_dts_time:19516.5
off:1616070872521356 off_time:1.61607e+09
demuxer+ffmpeg -> ist_index:2 type:audio pkt_pts:0 pkt_pts_time:0
pkt_dts:0 pkt_dts_time:0 off:-19516478644 off_time:-19516.5

Thus, ffmpeg.c is not only adjusting the timestamp to start at zero
with the start_time, but also takes the itsoffset off as well.


This affects formats with AVFMT_TS_DISCONT flag, ffmpeg checks for a 
discontinuity and readjusts the file offset to make output timestamps 
smooth.


Add -dts_delta_threshold 1616090389 alongside itsoffset to prevent this 
readjustment. Perhaps, both the itsoffset and ts_scale adjustments 
should be moved to after the discontinuity checks.


Regards,
Gyan
___
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 01/18] libavformat/utils: Fix indentation

2021-03-18 Thread Andreas Rheinhardt
Originally added in 12f996edfab67b65af0ff1ee829f9eeabb025b0f
behind #if 0; aebb56e1844d61965c97e95534c3ae0da69df028 then
removed the #if and replaced it by using av_dlog. Then commit
1a3eb042c704dea190c644def5b32c9cee8832b8 replaced this with av_log
at trace level. Yet the code block always stayed within { }
at an increased level of indentation.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/utils.c | 30 +-
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 295e676c9c..d9a08c9ccd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2945,23 +2945,19 @@ static void estimate_timings(AVFormatContext *ic, 
int64_t old_offset)
 }
 update_stream_timings(ic);
 
-{
-int i;
-AVStream av_unused *st;
-for (i = 0; i < ic->nb_streams; i++) {
-st = ic->streams[i];
-if (st->time_base.den)
-av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %s duration: 
%s\n", i,
-   av_ts2timestr(st->start_time, &st->time_base),
-   av_ts2timestr(st->duration, &st->time_base));
-}
-av_log(ic, AV_LOG_TRACE,
-   "format: start_time: %s duration: %s (estimate from %s) 
bitrate=%"PRId64" kb/s\n",
-   av_ts2timestr(ic->start_time, &AV_TIME_BASE_Q),
-   av_ts2timestr(ic->duration, &AV_TIME_BASE_Q),
-   duration_estimate_name(ic->duration_estimation_method),
-   (int64_t)ic->bit_rate / 1000);
-}
+for (unsigned i = 0; i < ic->nb_streams; i++) {
+AVStream *st = ic->streams[i];
+if (st->time_base.den)
+av_log(ic, AV_LOG_TRACE, "stream %u: start_time: %s duration: 
%s\n", i,
+   av_ts2timestr(st->start_time, &st->time_base),
+   av_ts2timestr(st->duration, &st->time_base));
+}
+av_log(ic, AV_LOG_TRACE,
+   "format: start_time: %s duration: %s (estimate from %s) 
bitrate=%"PRId64" kb/s\n",
+   av_ts2timestr(ic->start_time, &AV_TIME_BASE_Q),
+   av_ts2timestr(ic->duration, &AV_TIME_BASE_Q),
+   duration_estimate_name(ic->duration_estimation_method),
+   (int64_t)ic->bit_rate / 1000);
 }
 
 static int has_codec_parameters(AVStream *st, const char **errmsg_ptr)
-- 
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 02/18] avformat/utils: Always leave parse_pkt in blank state, avoid resetting

2021-03-18 Thread Andreas Rheinhardt
Always leaving said packet in a blank state after having used it
allows to avoid having to reset it before one uses it; and it also
allows to use it in more places than just in parse_packets() here.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index d9a08c9ccd..0c167d0cb9 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1427,9 +1427,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
 int size  = pkt->size;
 int ret = 0, got_output = flush;
 
-if (size || flush) {
-av_packet_unref(out_pkt);
-} else if (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+if (!size && !flush && st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
 // preserve 0-size sync packets
 compute_pkt_fields(s, st, st->parser, pkt, AV_NOPTS_VALUE, 
AV_NOPTS_VALUE);
 }
@@ -1525,6 +1523,8 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
 }
 
 fail:
+out_pkt->data = NULL;
+out_pkt->size = 0;
 av_packet_unref(pkt);
 return ret;
 }
-- 
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 03/18] avformat/utils: Don't allocate separate packet for extract_extradata

2021-03-18 Thread Andreas Rheinhardt
One can simply reuse AVFormatInternal.parse_pkt instead.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/internal.h | 12 ++--
 libavformat/utils.c| 29 ++---
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 3c6b2921c1..a810d51bba 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -90,9 +90,18 @@ struct AVFormatInternal {
 /**
  * Packets split by the parser get queued here.
  */
-AVPacket *parse_pkt;
 struct PacketList *parse_queue;
 struct PacketList *parse_queue_end;
+/**
+ * The generic code uses this as a temporary packet
+ * to parse packets; it may also be used for other means
+ * for short periods that are guaranteed not to overlap
+ * with calls to av_read_frame() (or ff_read_packet())
+ * or with each other.
+ * Every user has to ensure that this packet is blank
+ * after using it.
+ */
+AVPacket *parse_pkt;
 
 /**
  * Used to hold temporary packets.
@@ -190,7 +199,6 @@ struct AVStreamInternal {
  * supported) */
 struct {
 AVBSFContext *bsf;
-AVPacket *pkt;
 int inited;
 } extract_extradata;
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 0c167d0cb9..3542e40afd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3498,13 +3498,9 @@ static int extract_extradata_init(AVStream *st)
 if (!ret)
 goto finish;
 
-sti->extract_extradata.pkt = av_packet_alloc();
-if (!sti->extract_extradata.pkt)
-return AVERROR(ENOMEM);
-
 ret = av_bsf_alloc(f, &sti->extract_extradata.bsf);
 if (ret < 0)
-goto fail;
+return ret;
 
 ret = avcodec_parameters_copy(sti->extract_extradata.bsf->par_in,
   st->codecpar);
@@ -3523,14 +3519,12 @@ finish:
 return 0;
 fail:
 av_bsf_free(&sti->extract_extradata.bsf);
-av_packet_free(&sti->extract_extradata.pkt);
 return ret;
 }
 
-static int extract_extradata(AVStream *st, const AVPacket *pkt)
+static int extract_extradata(AVStream *st, AVPacket *tmp, const AVPacket *pkt)
 {
 AVStreamInternal *sti = st->internal;
-AVPacket *pkt_ref;
 int ret;
 
 if (!sti->extract_extradata.inited) {
@@ -3542,27 +3536,26 @@ static int extract_extradata(AVStream *st, const 
AVPacket *pkt)
 if (sti->extract_extradata.inited && !sti->extract_extradata.bsf)
 return 0;
 
-pkt_ref = sti->extract_extradata.pkt;
-ret = av_packet_ref(pkt_ref, pkt);
+ret = av_packet_ref(tmp, pkt);
 if (ret < 0)
 return ret;
 
-ret = av_bsf_send_packet(sti->extract_extradata.bsf, pkt_ref);
+ret = av_bsf_send_packet(sti->extract_extradata.bsf, tmp);
 if (ret < 0) {
-av_packet_unref(pkt_ref);
+av_packet_unref(tmp);
 return ret;
 }
 
 while (ret >= 0 && !sti->avctx->extradata) {
-ret = av_bsf_receive_packet(sti->extract_extradata.bsf, pkt_ref);
+ret = av_bsf_receive_packet(sti->extract_extradata.bsf, tmp);
 if (ret < 0) {
 if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
 return ret;
 continue;
 }
 
-for (int i = 0; i < pkt_ref->side_data_elems; i++) {
-AVPacketSideData *side_data = &pkt_ref->side_data[i];
+for (int i = 0; i < tmp->side_data_elems; i++) {
+AVPacketSideData *side_data = &tmp->side_data[i];
 if (side_data->type == AV_PKT_DATA_NEW_EXTRADATA) {
 sti->avctx->extradata  = side_data->data;
 sti->avctx->extradata_size = side_data->size;
@@ -3571,7 +3564,7 @@ static int extract_extradata(AVStream *st, const AVPacket 
*pkt)
 break;
 }
 }
-av_packet_unref(pkt_ref);
+av_packet_unref(tmp);
 }
 
 return 0;
@@ -3923,7 +3916,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 st->internal->info->frame_delay_evidence = 1;
 }
 if (!st->internal->avctx->extradata) {
-ret = extract_extradata(st, pkt);
+ret = extract_extradata(st, ic->internal->parse_pkt, pkt);
 if (ret < 0)
 goto unref_then_goto_end;
 }
@@ -4189,7 +4182,6 @@ find_stream_info_err:
 avcodec_close(ic->streams[i]->internal->avctx);
 av_freep(&ic->streams[i]->internal->info);
 av_bsf_free(&ic->streams[i]->internal->extract_extradata.bsf);
-av_packet_free(&ic->streams[i]->internal->extract_extradata.pkt);
 }
 if (ic->pb)
 av_log(ic, AV_LOG_DEBUG, "After avformat_find_stream_info() pos: 
%"PRId64" bytes read:%"PRId64" seeks:%d frames:%d\n",
@@ -4391,7 +4383,6 @@ static void free_stream(AVStream **pst)
 av_freep(&st->internal->probe_data.buf);
 
 av_bsf_free(&st->internal->extract_extradata.bsf);
-av_packet_free(&st->internal->extract_extradata.pkt);
 

[FFmpeg-devel] [PATCH 04/18] avformat/matroskadec: Reuse AVFormatInternal.parse_pkt

2021-03-18 Thread Andreas Rheinhardt
Before 8d78e90a6ba96646f7f25aff6ca3e12e71cec164 the Matroska demuxer
used stack packets to hold temporary packets; now it uses a temporary
packet allocated by the Matroska demuxer. Yet because it used stack
packets the code has always properly reset the packet on error, while
on success these temporary packets were put into a packet list via
avpriv_packet_list_put(), which already resets the source packet.
This means that this code is compatible with just reusing
AVFormatInternal.parse_pkt (which is unused while one is in the
demuxer's read_packet() function). Compared to before 8d78e90a6
this no longer wastes one initialization per AVPacket read
(the resetting of the stack packet performed by av_packet_move_ref()
in avpriv_packet_list_put() was for naught).

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/internal.h| 3 +++
 libavformat/matroskadec.c | 8 +++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index a810d51bba..c730332031 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -98,6 +98,9 @@ struct AVFormatInternal {
  * for short periods that are guaranteed not to overlap
  * with calls to av_read_frame() (or ff_read_packet())
  * or with each other.
+ * It may be used by demuxers as a replacement for
+ * stack packets (unless they call one of the aforementioned
+ * functions with their own AVFormatContext).
  * Every user has to ensure that this packet is blank
  * after using it.
  */
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 9acfdf5b32..1dc188c946 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -381,6 +381,8 @@ typedef struct MatroskaDemuxContext {
 /* byte position of the segment inside the stream */
 int64_t segment_start;
 
+/* This packet coincides with AVFormatInternal.parse_pkt
+ * and is not owned by us. */
 AVPacket *pkt;
 
 /* the packet queue */
@@ -2945,9 +2947,7 @@ static int matroska_read_header(AVFormatContext *s)
 }
 ebml_free(ebml_syntax, &ebml);
 
-matroska->pkt = av_packet_alloc();
-if (!matroska->pkt)
-return AVERROR(ENOMEM);
+matroska->pkt = s->internal->parse_pkt;
 
 /* The next thing is a segment. */
 pos = avio_tell(matroska->ctx->pb);
@@ -3528,7 +3528,6 @@ static int matroska_parse_frame(MatroskaDemuxContext 
*matroska,
 if (!pkt_size && !additional_size)
 goto no_output;
 
-av_packet_unref(pkt);
 if (!buf)
 pkt->buf = av_buffer_create(pkt_data, pkt_size + 
AV_INPUT_BUFFER_PADDING_SIZE,
 NULL, NULL, 0);
@@ -3902,7 +3901,6 @@ static int matroska_read_close(AVFormatContext *s)
 int n;
 
 matroska_clear_queue(matroska);
-av_packet_free(&matroska->pkt);
 
 for (n = 0; n < matroska->tracks.nb_elem; n++)
 if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO)
-- 
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 05/18] avformat/moflex: Simplify freeing packets

2021-03-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/moflex.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavformat/moflex.c b/libavformat/moflex.c
index 41335ada78..dabe113e6b 100644
--- a/libavformat/moflex.c
+++ b/libavformat/moflex.c
@@ -369,10 +369,7 @@ static int moflex_read_seek(AVFormatContext *s, int 
stream_index,
 static int moflex_read_close(AVFormatContext *s)
 {
 for (int i = 0; i < s->nb_streams; i++) {
-AVPacket *packet = s->streams[i]->priv_data;
-
-av_packet_free(&packet);
-s->streams[i]->priv_data = 0;
+av_packet_free((AVPacket **)&s->streams[i]->priv_data);
 }
 
 return 0;
-- 
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 06/18] avformat/apetag: Avoid stack packet when reading attached picture

2021-03-18 Thread Andreas Rheinhardt
Read it directly into AVStream.attached_pic.

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

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 454c6c688b..23ee6b516d 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -79,10 +79,9 @@ static int ape_tag_read_field(AVFormatContext *s)
 av_dict_set(&st->metadata, key, filename, 0);
 
 if ((id = ff_guess_image2_codec(filename)) != AV_CODEC_ID_NONE) {
-AVPacket pkt;
 int ret;
 
-ret = av_get_packet(s->pb, &pkt, size);
+ret = av_get_packet(s->pb, &st->attached_pic, size);
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR, "Error reading cover art.\n");
 return ret;
@@ -92,7 +91,6 @@ static int ape_tag_read_field(AVFormatContext *s)
 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
 st->codecpar->codec_id   = id;
 
-st->attached_pic  = pkt;
 st->attached_pic.stream_index = st->index;
 st->attached_pic.flags   |= AV_PKT_FLAG_KEY;
 } else {
-- 
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 13/18] avformat/ipmovie: Avoid stack packet

2021-03-18 Thread Andreas Rheinhardt
Replace it in ipmovie_read_header() by AVFormatInternal.parse_pkt
which is unused when reading the header.

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

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index 048e748cfd..9118d7d807 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -608,7 +608,6 @@ static int ipmovie_read_header(AVFormatContext *s)
 {
 IPMVEContext *ipmovie = s->priv_data;
 AVIOContext *pb = s->pb;
-AVPacket pkt;
 AVStream *st;
 unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
 int chunk_type, i;
@@ -645,8 +644,7 @@ static int ipmovie_read_header(AVFormatContext *s)
 
 if (chunk_type == CHUNK_VIDEO)
 ipmovie->audio_type = AV_CODEC_ID_NONE;  /* no audio */
-else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO) {
-av_packet_unref(&pkt);
+else if (process_ipmovie_chunk(ipmovie, pb, s->internal->parse_pkt) != 
CHUNK_INIT_AUDIO) {
 return AVERROR_INVALIDDATA;
 }
 
-- 
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 07/18] avformat/asfdec_f: Avoid stack packet

2021-03-18 Thread Andreas Rheinhardt
Replace it by using AVFormatInternal.parse_pkt which is otherwise unused
when reading a header.

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

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 1484b544d9..2fae528f4d 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -860,17 +860,17 @@ static int asf_read_header(AVFormatContext *s)
 } else {
 if (!s->keylen) {
 if (!ff_guidcmp(&g, &ff_asf_content_encryption)) {
+AVPacket *pkt = s->internal->parse_pkt;
 unsigned int len;
-AVPacket pkt;
 av_log(s, AV_LOG_WARNING,
"DRM protected stream detected, decoding will 
likely fail!\n");
 len= avio_rl32(pb);
 av_log(s, AV_LOG_DEBUG, "Secret data:\n");
 
-if ((ret = av_get_packet(pb, &pkt, len)) < 0)
+if ((ret = av_get_packet(pb, pkt, len)) < 0)
 return ret;
-av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size);
-av_packet_unref(&pkt);
+av_hex_dump_log(s, AV_LOG_DEBUG, pkt->data, pkt->size);
+av_packet_unref(pkt);
 
 len= avio_rl32(pb);
 if (len > UINT16_MAX)
-- 
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 14/18] avformat/webpenc: Use init instead of write_header function

2021-03-18 Thread Andreas Rheinhardt
webp_write_header() didn't write anything.

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

diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c
index 9fb472257d..8c32ff66df 100644
--- a/libavformat/webpenc.c
+++ b/libavformat/webpenc.c
@@ -33,7 +33,7 @@ typedef struct WebpContext{
 int using_webp_anim_encoder;
 } WebpContext;
 
-static int webp_write_header(AVFormatContext *s)
+static int webp_init(AVFormatContext *s)
 {
 AVStream *st;
 
@@ -210,7 +210,7 @@ AVOutputFormat ff_webp_muxer = {
 .extensions = "webp",
 .priv_data_size = sizeof(WebpContext),
 .video_codec= AV_CODEC_ID_WEBP,
-.write_header   = webp_write_header,
+.init   = webp_init,
 .write_packet   = webp_write_packet,
 .write_trailer  = webp_write_trailer,
 .priv_class = &webp_muxer_class,
-- 
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 08/18] avformat/ipmovie: Remove redundant av_packet_unref()

2021-03-18 Thread Andreas Rheinhardt
When one of these errors happens during ipmovie_read_packet(),
an error is returned and the packet is cleaned up generically.
And since 712d3ac539f30239b764d8621829dc9dc913da61 the same happens
in ipmovie_read_header().

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/ipmovie.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index 3234d591da..26886d9592 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -194,7 +194,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext 
*pb,
 
 if (avio_read(pb, pkt->data + 8, s->video_chunk_size) !=
 s->video_chunk_size) {
-av_packet_unref(pkt);
 return CHUNK_EOF;
 }
 
@@ -205,7 +204,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext 
*pb,
 
 if (avio_read(pb, pkt->data + 8 + s->video_chunk_size,
 s->decode_map_chunk_size) != s->decode_map_chunk_size) {
-av_packet_unref(pkt);
 return CHUNK_EOF;
 }
 }
@@ -217,7 +215,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext 
*pb,
 
 if (avio_read(pb, pkt->data + 8 + s->video_chunk_size + 
s->decode_map_chunk_size,
 s->skip_map_chunk_size) != s->skip_map_chunk_size) {
-av_packet_unref(pkt);
 return CHUNK_EOF;
 }
 }
-- 
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 15/18] avformat/webpenc: Fix memleak when using invalid packets

2021-03-18 Thread Andreas Rheinhardt
The WebP muxer uses sometimes caches a packet it receives to write it
later; yet if a cached packet is too small (so small as to be invalid),
it is cached, but not written and not unreferenced. Such a packet leaks,
either by being overwritten by the next frame or because it is never
unreferenced at all.

Fix this by not caching unusable packets at all; and error out on
invalid packets.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/webpenc.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c
index 8c32ff66df..e3b12aeed2 100644
--- a/libavformat/webpenc.c
+++ b/libavformat/webpenc.c
@@ -53,24 +53,22 @@ static int webp_init(AVFormatContext *s)
 
 static int is_animated_webp_packet(AVPacket *pkt)
 {
-if (pkt->size) {
 int skip = 0;
 unsigned flags = 0;
 
 if (pkt->size < 4)
-return 0;
+return AVERROR_INVALIDDATA;
 if (AV_RL32(pkt->data) == AV_RL32("RIFF"))
 skip = 12;
-
+// Safe to do this as a valid WebP bitstream is >=30 bytes.
 if (pkt->size < skip + 4)
-return 0;
+return AVERROR_INVALIDDATA;
 if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) {
 flags |= pkt->data[skip + 4 + 4];
 }
 
 if (flags & 2)  // ANIMATION_FLAG is on
 return 1;
-}
 return 0;
 }
 
@@ -84,13 +82,9 @@ static int flush(AVFormatContext *s, int trailer, int64_t 
pts)
 unsigned flags = 0;
 int vp8x = 0;
 
-if (w->last_pkt.size < 4)
-return 0;
 if (AV_RL32(w->last_pkt.data) == AV_RL32("RIFF"))
 skip = 12;
 
-if (w->last_pkt.size < skip + 4)
-return 0;  // Safe to do this as a valid WebP bitstream is >=30 
bytes.
 if (AV_RL32(w->last_pkt.data + skip) == AV_RL32("VP8X")) {
 flags |= w->last_pkt.data[skip + 4 + 4];
 vp8x = 1;
@@ -149,7 +143,14 @@ static int flush(AVFormatContext *s, int trailer, int64_t 
pts)
 static int webp_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 WebpContext *w = s->priv_data;
-w->using_webp_anim_encoder |= is_animated_webp_packet(pkt);
+int ret;
+
+if (!pkt->size)
+return 0;
+ret = is_animated_webp_packet(pkt);
+if (ret < 0)
+return ret;
+w->using_webp_anim_encoder |= ret;
 
 if (w->using_webp_anim_encoder) {
 avio_write(s->pb, pkt->data, pkt->size);
-- 
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 09/18] avformat/ipmovie: Avoid reading packets during read_header

2021-03-18 Thread Andreas Rheinhardt
They will be discarded anyway because this can only happen
for invalid data. This already implies that the pkt won't be used
at all when parsing the very first chunk when reading the header,
so one can use NULL as argument and remove the av_packet_unref()
on error.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/ipmovie.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index 26886d9592..3f40bb8fe8 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -47,6 +47,7 @@
 #define CHUNK_SHUTDOWN 0x0004
 #define CHUNK_END  0x0005
 /* these last types are used internally */
+#define CHUNK_HAVE_PACKET  0xFFFB
 #define CHUNK_DONE 0xFFFC
 #define CHUNK_NOMEM0xFFFD
 #define CHUNK_EOF  0xFFFE
@@ -154,7 +155,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext 
*pb,
 av_log(s->avf, AV_LOG_TRACE, "sending audio frame with pts %"PRId64" 
(%d audio frames)\n",
 pkt->pts, s->audio_frame_count);
 
-chunk_type = CHUNK_VIDEO;
+chunk_type = CHUNK_HAVE_PACKET;
 
 } else if (s->frame_format) {
 
@@ -230,7 +231,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext 
*pb,
 
 s->video_pts += s->frame_pts_inc;
 
-chunk_type = CHUNK_VIDEO;
+chunk_type = CHUNK_HAVE_PACKET;
 
 } else {
 
@@ -602,10 +603,6 @@ static int process_ipmovie_chunk(IPMVEContext *s, 
AVIOContext *pb,
 /* make a note of where the stream is sitting */
 s->next_chunk_offset = avio_tell(pb);
 
-/* dispatch the first of any pending packets */
-if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
-chunk_type = load_ipmovie_packet(s, pb, pkt);
-
 return chunk_type;
 }
 
@@ -658,8 +655,7 @@ static int ipmovie_read_header(AVFormatContext *s)
 ipmovie->palette[i] = 0xFFU << 24;
 
 /* process the first chunk which should be CHUNK_INIT_VIDEO */
-if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO) {
-av_packet_unref(&pkt);
+if (process_ipmovie_chunk(ipmovie, pb, NULL) != CHUNK_INIT_VIDEO) {
 return AVERROR_INVALIDDATA;
 }
 
@@ -708,6 +704,10 @@ static int ipmovie_read_packet(AVFormatContext *s,
 
 for (;;) {
 ret = process_ipmovie_chunk(ipmovie, pb, pkt);
+/* dispatch the first of any pending packets */
+if ((ret == CHUNK_VIDEO) || (ret == CHUNK_AUDIO_ONLY))
+ret = load_ipmovie_packet(ipmovie, pb, pkt);
+
 if (ret == CHUNK_BAD)
 ret = AVERROR_INVALIDDATA;
 else if (ret == CHUNK_EOF)
@@ -716,7 +716,7 @@ static int ipmovie_read_packet(AVFormatContext *s,
 ret = AVERROR(ENOMEM);
 else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN)
 ret = AVERROR_EOF;
-else if (ret == CHUNK_VIDEO)
+else if (ret == CHUNK_HAVE_PACKET)
 ret = 0;
 else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
 continue;
-- 
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 16/18] avformat/webpenc: Reindentation

2021-03-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/webpenc.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c
index e3b12aeed2..d5edf89289 100644
--- a/libavformat/webpenc.c
+++ b/libavformat/webpenc.c
@@ -53,22 +53,22 @@ static int webp_init(AVFormatContext *s)
 
 static int is_animated_webp_packet(AVPacket *pkt)
 {
-int skip = 0;
-unsigned flags = 0;
+int skip = 0;
+unsigned flags = 0;
 
-if (pkt->size < 4)
+if (pkt->size < 4)
 return AVERROR_INVALIDDATA;
-if (AV_RL32(pkt->data) == AV_RL32("RIFF"))
-skip = 12;
+if (AV_RL32(pkt->data) == AV_RL32("RIFF"))
+skip = 12;
 // Safe to do this as a valid WebP bitstream is >=30 bytes.
-if (pkt->size < skip + 4)
+if (pkt->size < skip + 4)
 return AVERROR_INVALIDDATA;
-if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) {
-flags |= pkt->data[skip + 4 + 4];
-}
+if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) {
+flags |= pkt->data[skip + 4 + 4];
+}
 
-if (flags & 2)  // ANIMATION_FLAG is on
-return 1;
+if (flags & 2)  // ANIMATION_FLAG is on
+return 1;
 return 0;
 }
 
-- 
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 10/18] avformat/ipmovie: Deduplicate parsing video data opcodes

2021-03-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/ipmovie.c | 23 +++
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index 3f40bb8fe8..f1cc30b6c0 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -560,28 +560,11 @@ static int process_ipmovie_chunk(IPMVEContext *s, 
AVIOContext *pb,
 break;
 
 case OPCODE_VIDEO_DATA_06:
-av_log(s->avf, AV_LOG_TRACE, "set video data format 0x06\n");
-s->frame_format = 0x06;
-
-/* log position and move on for now */
-s->video_chunk_offset = avio_tell(pb);
-s->video_chunk_size = opcode_size;
-avio_skip(pb, opcode_size);
-break;
-
 case OPCODE_VIDEO_DATA_10:
-av_log(s->avf, AV_LOG_TRACE, "set video data format 0x10\n");
-s->frame_format = 0x10;
-
-/* log position and move on for now */
-s->video_chunk_offset = avio_tell(pb);
-s->video_chunk_size = opcode_size;
-avio_skip(pb, opcode_size);
-break;
-
 case OPCODE_VIDEO_DATA_11:
-av_log(s->avf, AV_LOG_TRACE, "set video data format 0x11\n");
-s->frame_format = 0x11;
+s->frame_format = opcode_type;
+av_log(s->avf, AV_LOG_TRACE, "set video data format 0x%02X\n",
+   opcode_type);
 
 /* log position and move on for now */
 s->video_chunk_offset = avio_tell(pb);
-- 
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 17/18] avformat/webpenc: Fix memleak when trailer is never written

2021-03-18 Thread Andreas Rheinhardt
When the trailer is never written (or when a stream switches from
non-animation mode to animation mode mid-stream), a cached packet
(if existing) would leak. Fix this by adding a deinit function.

Signed-off-by: Andreas Rheinhardt 
---
AVFormatInternal.parse_pkt is completely unused for muxers, so it can be
reused in this muxer and this deinit function removed again. See
https://github.com/mkver/FFmpeg/commits/packet_reuse for more.

 libavformat/webpenc.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c
index d5edf89289..ed8325c02d 100644
--- a/libavformat/webpenc.c
+++ b/libavformat/webpenc.c
@@ -191,6 +191,13 @@ static int webp_write_trailer(AVFormatContext *s)
 return 0;
 }
 
+static void webp_deinit(AVFormatContext *s)
+{
+WebpContext *w = s->priv_data;
+
+av_packet_unref(&w->last_pkt);
+}
+
 #define OFFSET(x) offsetof(WebpContext, x)
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
@@ -214,6 +221,7 @@ AVOutputFormat ff_webp_muxer = {
 .init   = webp_init,
 .write_packet   = webp_write_packet,
 .write_trailer  = webp_write_trailer,
+.deinit = webp_deinit,
 .priv_class = &webp_muxer_class,
 .flags  = AVFMT_VARIABLE_FPS,
 };
-- 
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 11/18] avformat/ipmovie: Fix indentation

2021-03-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/ipmovie.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index f1cc30b6c0..a71575235f 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -686,27 +686,27 @@ static int ipmovie_read_packet(AVFormatContext *s,
 int ret;
 
 for (;;) {
-ret = process_ipmovie_chunk(ipmovie, pb, pkt);
+ret = process_ipmovie_chunk(ipmovie, pb, pkt);
 /* dispatch the first of any pending packets */
 if ((ret == CHUNK_VIDEO) || (ret == CHUNK_AUDIO_ONLY))
 ret = load_ipmovie_packet(ipmovie, pb, pkt);
 
-if (ret == CHUNK_BAD)
-ret = AVERROR_INVALIDDATA;
-else if (ret == CHUNK_EOF)
-ret = AVERROR(EIO);
-else if (ret == CHUNK_NOMEM)
-ret = AVERROR(ENOMEM);
-else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN)
-ret = AVERROR_EOF;
-else if (ret == CHUNK_HAVE_PACKET)
-ret = 0;
-else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
-continue;
-else
-continue;
-
-return ret;
+if (ret == CHUNK_BAD)
+ret = AVERROR_INVALIDDATA;
+else if (ret == CHUNK_EOF)
+ret = AVERROR(EIO);
+else if (ret == CHUNK_NOMEM)
+ret = AVERROR(ENOMEM);
+else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN)
+ret = AVERROR_EOF;
+else if (ret == CHUNK_HAVE_PACKET)
+ret = 0;
+else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
+continue;
+else
+continue;
+
+return ret;
 }
 }
 
-- 
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 12/18] avformat/ipmovie: Remove redundant initializations

2021-03-18 Thread Andreas Rheinhardt
The demuxer's context has already been zeroed generically.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/ipmovie.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index a71575235f..048e748cfd 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -623,13 +623,6 @@ static int ipmovie_read_header(AVFormatContext *s)
 if (avio_feof(pb))
 return AVERROR_EOF;
 }
-/* initialize private context members */
-ipmovie->video_pts = ipmovie->audio_frame_count = 0;
-ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
-ipmovie->decode_map_chunk_offset = ipmovie->skip_map_chunk_offset = 0;
-ipmovie->decode_map_chunk_size = ipmovie->video_chunk_size =
-ipmovie->skip_map_chunk_size = 0;
-ipmovie->send_buffer = ipmovie->frame_format = 0;
 
 /* on the first read, this will position the stream at the first chunk */
 ipmovie->next_chunk_offset = avio_tell(pb) + 4;
-- 
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 18/18] avformat/amvenc: Remove unnecessary av_packet_free()

2021-03-18 Thread Andreas Rheinhardt
The muxer's deinit function takes care of cleaning up when init fails.

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

diff --git a/libavformat/amvenc.c b/libavformat/amvenc.c
index 5d13b618f4..362b474fa6 100644
--- a/libavformat/amvenc.c
+++ b/libavformat/amvenc.c
@@ -187,7 +187,6 @@ static av_cold int amv_init(AVFormatContext *s)
 if (!amv->apad)
 return AVERROR(ENOMEM);
 if ((ret = av_new_packet(amv->apad, amv->ablock_align)) < 0) {
-av_packet_free(&amv->apad);
 return ret;
 }
 
@@ -197,7 +196,6 @@ static av_cold int amv_init(AVFormatContext *s)
 
 amv->vpad = av_packet_alloc();
 if (!amv->vpad) {
-av_packet_free(&amv->apad);
 return AVERROR(ENOMEM);
 }
 amv->vpad->stream_index = AMV_STREAM_VIDEO;
-- 
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".