Re: [FFmpeg-devel] [PATCH v10 1/4] avutil: add AV_FRAME_DATA_SEI_UNREGISTERED side data type

2020-06-10 Thread lance . lmwang
On Wed, Jun 10, 2020 at 07:43:11AM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
> rebase with master only, I'll apply the patchset in two days if no objection.
> 
>  doc/APIchanges  | 3 +++
>  libavutil/frame.c   | 1 +
>  libavutil/frame.h   | 8 
>  libavutil/version.h | 2 +-
>  4 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 70579df..08cdbda 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2020-06-xx - xx - lavu 56.53.100 - frame.h
> +  Add AV_FRAME_DATA_SEI_UNREGISTERED.
> +
>  2020-06-05 - ec39c2276a - lavu 56.50.100 - buffer.h
>Passing NULL as alloc argument to av_buffer_pool_init2() is now allowed.
>  
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 2e952ed..9884eae 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -851,6 +851,7 @@ const char *av_frame_side_data_name(enum 
> AVFrameSideDataType type)
>  case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
> SMPTE2094-40 (HDR10+)";
>  case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest";
>  case AV_FRAME_DATA_VIDEO_ENC_PARAMS:return "Video encoding 
> parameters";
> +case AV_FRAME_DATA_SEI_UNREGISTERED:return "H.26[45] User 
> Data Unregistered SEI message";
>  }
>  return NULL;
>  }
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index fc67db0..3fb8c56 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -184,6 +184,14 @@ enum AVFrameSideDataType {
>   * Encoding parameters for a video frame, as described by 
> AVVideoEncParams.
>   */
>  AV_FRAME_DATA_VIDEO_ENC_PARAMS,
> +
> +/**
> + * User data unregistered metadata associated with a video frame.
> + * This is the H.26[45] UDU SEI message, and shouldn't be used for any 
> other purpose
> + * The data is stored as uint8_t in AVFrameSideData.data which is 16 
> bytes of
> + * uuid_iso_iec_11578 followed by AVFrameSideData.size - 16 bytes of 
> user_data_payload_byte.
> + */
> +AV_FRAME_DATA_SEI_UNREGISTERED,
>  };
>  
>  enum AVActiveFormatDescription {
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 652e1e9..e75e625 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>   */
>  
>  #define LIBAVUTIL_VERSION_MAJOR  56
> -#define LIBAVUTIL_VERSION_MINOR  52
> +#define LIBAVUTIL_VERSION_MINOR  53
>  #define LIBAVUTIL_VERSION_MICRO 100

will apply this patch to avoid conflict every time.


>  
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> -- 
> 1.8.3.1
> 

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v11 3/4] avfilter/vf_showinfo: display H.26[45] user data unregistered sei message

2020-06-10 Thread lance . lmwang
On Wed, Jun 10, 2020 at 08:13:59PM +0200, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/vf_showinfo.c | 37 +
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index 5d4aee4..2511da5 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -37,6 +37,7 @@
> >  #include "libavutil/timecode.h"
> >  #include "libavutil/mastering_display_metadata.h"
> >  #include "libavutil/video_enc_params.h"
> > +#include "libavutil/avstring.h"
> >  
> >  #include "avfilter.h"
> >  #include "internal.h"
> > @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext 
> > *ctx, AVFrameSideData *sd)
> >  av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
> >  }
> >  
> > +static int string_is_print(const uint8_t *str)
> > +{
> > +while (av_isgraph(*str)) str++;
> > +return !*str;
> 
> This is dangerous: The SEI message needn't be zero-terminated, so this
> may segfault. Furthermore, it is also wrong: If the user data payload
> happens to contain a binary zero preceded by printable ASCII characters,
> it will be considered a string, even if there are unprintable characters
> after the binary zero (which may really happen if the payload is
> actually binary).

Give below test example, if a binary zero preceded by "hello", the %s will print
out "hello" and ignore the other unprintable characters. I think it's expected.
We only dump the printable result if it is string or parial string.

 unsigned char test[10];

 test[0] = 'h';
 test[1] = 'e';
 test[2] = 'l';
 test[3] = 'l';
 test[4] = 'o';
 test[5] = 0;
 test[6] = 133;
 test[7] = 144;

 printf( "test: %s \n", test);

So I thbink it's safety after add one padding zero bytes for the user data
buffer.

> 
> > +}
> > +
> > +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, 
> > AVFrameSideData *sd)
> > +{
> > +const int uuid_size = 16;
> > +uint8_t *user_data = sd->data;
> > +
> > +if (sd->size < uuid_size) {
> > +av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", 
> > sd->size, uuid_size);
> > +return;
> > +}
> > +
> > +av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
> > +av_log(ctx, AV_LOG_INFO, "UUID=");
> > +for (int i = 0; i < uuid_size; i++) {
> > +av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
> > +if (i == 3 || i == 5 || i == 7 || i == 9)
> > +av_log(ctx, AV_LOG_INFO, "-");
> > +}
> > +av_log(ctx, AV_LOG_INFO, "\n");
> > +
> > +user_data += uuid_size;
> > +/* Only print the user data details if it's string */
> > +if (string_is_print(user_data)) {
> > +av_log(ctx, AV_LOG_INFO, "User Data=");
> > +av_log(ctx, AV_LOG_INFO, "%s", user_data);
> 
> Given that the user_data needn't be zero-terminated, you must specify
> the precision (i.e. the number of bytes to write) here.
> 
> > +}
> > +}
> > +
> >  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> >  {
> >  const char *color_range_str = 
> > av_color_range_name(frame->color_range);
> > @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> > *frame)
> >  case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
> >  dump_video_enc_params(ctx, sd);
> >  break;
> > +case AV_FRAME_DATA_SEI_UNREGISTERED:
> > +dump_sei_unregistered_metadata(ctx, sd);
> > +break;
> >  default:
> >  av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d 
> > bytes)",
> > sd->type, sd->size);
> > 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] OS/2:Support linking against libcx

2020-06-10 Thread Dave Yeo

On 06/10/20 02:09 PM, Michael Niedermayer wrote:

On Tue, Jun 09, 2020 at 11:11:48PM -0700, Dave Yeo wrote:

Hi, could I get this pushed to trunk and the 4.3 branch? Fixes a build break
in libavformat/ip.c (implicit declaration of function 'getaddrinfo') and
also need the prototype.
Thanks,
Dave

it seems this breaks build on linux


Sorry about that, I'll test on Linux in the future.
Here's a better patch as it doesn't touch configure.
Thanks,
Dave
From 033add727ca8c512a3f4a7d24fde88bb8c0455c8 Mon Sep 17 00:00:00 2001
From: Dave Yeo 
Date: Wed, 10 Jun 2020 18:55:44 -0700
Subject: [PATCH] libavformat/os_support.h:OS/2, support linking against libcx

Libcx contains extensions to libc such as getaddrinfo(), mmap() and poll(). While recommended to link against, it is optional

Signed-off-by: Dave Yeo 
---
 libavformat/os_support.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 5e6b32d2dc..6c60844b7d 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -56,6 +56,10 @@
 #  define fstat(f,s) _fstati64((f), (s))
 #endif /* defined(_WIN32) */
 
+#if defined (__OS2__) && defined (HAVE_GETADDRINFO)
+#include 
+#define HAVE_STRUCT_ADDRINFO 1
+#endif
 
 #ifdef __ANDROID__
 #  if HAVE_UNISTD_H
-- 
2.11.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] [RFC PATCH] libavcodec/libopenjpeg: pix fmt selection change

2020-06-10 Thread Gautam Ramakrishnan
On Tue, Jun 9, 2020 at 11:55 PM Carl Eugen Hoyos  wrote:
>
> Am Di., 9. Juni 2020 um 19:12 Uhr schrieb Gautam Ramakrishnan
> :
> >
> > On Tue, Jun 9, 2020 at 10:24 PM Carl Eugen Hoyos  wrote:
> > >
> > > Am Di., 9. Juni 2020 um 14:07 Uhr schrieb :
> > > >
> > > > From: Gautam Ramakrishnan 
> > > >
> > > > This patch makes selection of pix_fmt similar to
> > > > that in the native decoder. This makes samples such
> > > > as p0_05.j2k and p1_03.j2k decodable by libopenjpeg.
> > >
> > > Since both files are not YUVA420P, I am not sure if this
> > > patch is a good idea, in any case, the commit message
> > > mentioning the two files as reasons for this patch is wrong.
> > >
> > I am not sure what file format this is then.
>
> I failed to find out so far, possibly Bayer, CMYK seems less
> likely to me.
The reference file has 4 components, Whereas all the Bayer formats
have 3 components. Are we missing any Bayer pixel format in ffmpeg?
Also, any other ideas on what has to be done for the 2 reference files
mentioned? If this seems like a good idea, I could go through opj_decompress
and try to replicate what it does.
>
> Carl Eugen
> ___
> 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".



-- 
-
Gautam |
___
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] dnn-layer-mathunary-test: add unit test for tan

2020-06-10 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Ting Fu
> Sent: 2020年6月6日 20:13
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 6/6] dnn-layer-mathunary-test: add unit test 
> for
> tan
> 
> Signed-off-by: Ting Fu 
> ---
>  tests/dnn/dnn-layer-mathunary-test.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/dnn/dnn-layer-mathunary-test.c
> b/tests/dnn/dnn-layer-mathunary-test.c
> index 23e1766ad0..9a7e07c98c 100644
> --- a/tests/dnn/dnn-layer-mathunary-test.c
> +++ b/tests/dnn/dnn-layer-mathunary-test.c
> @@ -36,6 +36,8 @@ static float get_expected(float f,
> DNNMathUnaryOperation op)
>  return sin(f);
>  case DMUO_COS:
>  return cos(f);
> +case DMUO_TAN:
> +return tan(f);
>  default:
>  av_assert0(!"not supported yet");
>  return 0.f;
> @@ -85,5 +87,7 @@ int main(int agrc, char **argv)
>  return 1;
>  if (test(DMUO_COS))
>  return 1;
> +if (test(DMUO_TAN))
> +return 1;
>  return 0;
>  }
the patch set looks good to me, will push soon, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 4/7] avcodec: add adpcm_ima_apm encoder

2020-06-10 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  doc/general.texi   |  2 +-
>  libavcodec/Makefile|  1 +
>  libavcodec/adpcmenc.c  | 34 --
>  libavcodec/allcodecs.c |  1 +
>  libavcodec/utils.c |  1 +
>  5 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/general.texi b/doc/general.texi
> index 9b0ee96752..8df7445c36 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -1109,7 +1109,7 @@ following image formats are supported:
>  @item ADPCM IMA High Voltage Software ALP   @tab @tab  X
>  @item ADPCM IMA QuickTime@tab  X  @tab  X
>  @item ADPCM IMA Simon & Schuster Interactive   @tab  X  @tab  X
> -@item ADPCM IMA Ubisoft APM  @tab @tab X
> +@item ADPCM IMA Ubisoft APM  @tab  X  @tab  X
>  @item ADPCM IMA Loki SDL MJPEG  @tab @tab  X
>  @item ADPCM IMA WAV  @tab  X  @tab  X
>  @item ADPCM IMA Westwood @tab @tab  X
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 5a6ea59715..4ee0bf2d4c 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -853,6 +853,7 @@ OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o 
> adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER)  += adpcm.o adpcm_data.o
> +OBJS-$(CONFIG_ADPCM_IMA_APM_ENCODER)  += adpcmenc.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_CUNNING_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER)  += adpcm.o adpcm_data.o
> diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
> index d5fbc0b9a7..8396180cb6 100644
> --- a/libavcodec/adpcmenc.c
> +++ b/libavcodec/adpcmenc.c
> @@ -77,7 +77,9 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
>  return AVERROR(EINVAL);
>  }
>  
> -if (avctx->trellis && avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI) {
> +if (avctx->trellis &&
> +   (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
> +avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM)) {
>  /*
>   * The current trellis implementation doesn't work for extended
>   * runs of samples without periodic resets. Disallow it.
> @@ -152,6 +154,14 @@ static av_cold int adpcm_encode_init(AVCodecContext 
> *avctx)
>  avctx->frame_size = BLKSIZE * 2 / avctx->channels;
>  avctx->block_align = BLKSIZE;
>  break;
> +case AV_CODEC_ID_ADPCM_IMA_APM:
> +avctx->frame_size = BLKSIZE * 2 / avctx->channels;
> +avctx->block_align = BLKSIZE;
> +
> +if (!(avctx->extradata = av_mallocz(28)))

Missing padding. And zero-initializing the extradata is really enough?

> +goto error;
> +avctx->extradata_size = 28;
> +break;
>  default:
>  ret = AVERROR(EINVAL);
>  goto error;
> @@ -496,7 +506,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  
>  if (avctx->codec_id == AV_CODEC_ID_ADPCM_SWF)
>  pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) 
> + 7) / 8;
> -else if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI)
> +else if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
> + avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM)
>  pkt_size = (frame->nb_samples * avctx->channels) / 2;
>  else
>  pkt_size = avctx->block_align;
> @@ -717,6 +728,24 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  *dst++  = nibble;
>  }
>  break;
> +case AV_CODEC_ID_ADPCM_IMA_APM:
> +{
> +PutBitContext pb;
> +init_put_bits(, dst, pkt_size);
> +
> +av_assert0(avctx->trellis == 0);
> +
> +for (n = frame->nb_samples / 2; n > 0; n--) {
> +for (ch = 0; ch < avctx->channels; ch++) {
> +put_bits(, 4, adpcm_ima_qt_compress_sample(c->status + 
> ch, *samples++));
> +put_bits(, 4, adpcm_ima_qt_compress_sample(c->status + 
> ch, samples[st]));
> +}
> +samples += avctx->channels;
> +}
> +
> +flush_put_bits();
> +break;
> +}
>  default:
>  return AVERROR(EINVAL);
>  }
> @@ -751,6 +780,7 @@ AVCodec ff_ ## name_ ## _encoder = {  
>  \
>  .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,   \
>  }
>  
> +ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_APM, adpcm_ima_apm, sample_fmts,   
> AV_CODEC_CAP_SMALL_LAST_FRAME, "ADPCM IMA Ubisoft APM");
>  ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, 0,
>  "ADPCM IMA QuickTime");
>  ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_SSI, adpcm_ima_ssi, sample_fmts,   
> AV_CODEC_CAP_SMALL_LAST_FRAME, "ADPCM IMA Simon & Schuster Interactive");
>  

Re: [FFmpeg-devel] [PATCH v2 2/7] avformat/apm: prepare extradata handling for muxer

2020-06-10 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  libavformat/Makefile |   2 +-
>  libavformat/apm.c| 130 +++
>  2 files changed, 70 insertions(+), 62 deletions(-)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 0658fa3710..bb09dc6563 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -93,7 +93,7 @@ OBJS-$(CONFIG_AMRWB_DEMUXER) += amr.o
>  OBJS-$(CONFIG_ANM_DEMUXER)   += anm.o
>  OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
>  OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
> -OBJS-$(CONFIG_APM_DEMUXER)   += apm.o riffdec.o
> +OBJS-$(CONFIG_APM_DEMUXER)   += apm.o
>  OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
>  OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
>  OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
> diff --git a/libavformat/apm.c b/libavformat/apm.c
> index dc59c16562..57d23200b0 100644
> --- a/libavformat/apm.c
> +++ b/libavformat/apm.c
> @@ -21,12 +21,13 @@
>   */
>  #include "avformat.h"
>  #include "internal.h"
> -#include "riff.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/intreadwrite.h"
>  
> -#define APM_FILE_HEADER_SIZE20
> -#define APM_VS12_CHUNK_SIZE 76
> +#define APM_FILE_HEADER_SIZE18
> +#define APM_FILE_EXTRADATA_SIZE 80
> +#define APM_EXTRADATA_SIZE  28
> +
>  #define APM_MAX_READ_SIZE   4096
>  
>  #define APM_TAG_CODEC   0x2000
> @@ -43,34 +44,37 @@ typedef struct APMState {
>  int32_t saved_l;
>  } APMState;
>  
> -typedef struct APMVS12Chunk {
> +typedef struct APMExtraData {
>  uint32_tmagic;
>  uint32_tfile_size;
>  uint32_tdata_size;
>  uint32_tunk1;
>  uint32_tunk2;
>  APMStatestate;
> -uint32_tpad[7];
> -} APMVS12Chunk;
> +uint32_tunk3[7];
> +uint32_tdata;
> +} APMExtraData;
>  
> -static void apm_parse_vs12(APMVS12Chunk *vs12, const uint8_t *buf)
> +static void apm_parse_extradata(APMExtraData *ed, const uint8_t *buf)
>  {
> -vs12->magic = AV_RL32(buf + 0);
> -vs12->file_size = AV_RL32(buf + 4);
> -vs12->data_size = AV_RL32(buf + 8);
> -vs12->unk1  = AV_RL32(buf + 12);
> -vs12->unk2  = AV_RL32(buf + 16);
> -
> -vs12->state.has_saved   = AV_RL32(buf + 20);
> -vs12->state.predictor_r = AV_RL32(buf + 24);
> -vs12->state.step_index_r= AV_RL32(buf + 28);
> -vs12->state.saved_r = AV_RL32(buf + 32);
> -vs12->state.predictor_l = AV_RL32(buf + 36);
> -vs12->state.step_index_l= AV_RL32(buf + 40);
> -vs12->state.saved_l = AV_RL32(buf + 44);
> -
> -for (int i = 0; i < FF_ARRAY_ELEMS(vs12->pad); i++)
> -vs12->pad[i]= AV_RL32(buf + 48 + (i * 4));
> +ed->magic = AV_RL32(buf + 0);
> +ed->file_size = AV_RL32(buf + 4);
> +ed->data_size = AV_RL32(buf + 8);
> +ed->unk1  = AV_RL32(buf + 12);
> +ed->unk2  = AV_RL32(buf + 16);
> +
> +ed->state.has_saved   = AV_RL32(buf + 20);
> +ed->state.predictor_r = AV_RL32(buf + 24);
> +ed->state.step_index_r= AV_RL32(buf + 28);
> +ed->state.saved_r = AV_RL32(buf + 32);
> +ed->state.predictor_l = AV_RL32(buf + 36);
> +ed->state.step_index_l= AV_RL32(buf + 40);
> +ed->state.saved_l = AV_RL32(buf + 44);
> +
> +for (int i = 0; i < FF_ARRAY_ELEMS(ed->unk3); i++)
> +ed->unk3[i]   = AV_RL32(buf + 48 + (i * 4));
> +
> +ed->data  = AV_RL32(buf + 76);
>  }
>  
>  static int apm_probe(const AVProbeData *p)
> @@ -94,71 +98,75 @@ static int apm_read_header(AVFormatContext *s)
>  {
>  int64_t ret;
>  AVStream *st;
> -APMVS12Chunk vs12;
> -uint8_t buf[APM_VS12_CHUNK_SIZE];
> +APMExtraData extradata;
> +AVCodecParameters *par;
> +uint8_t buf[APM_FILE_EXTRADATA_SIZE];
>  
>  if (!(st = avformat_new_stream(s, NULL)))
>  return AVERROR(ENOMEM);
>  
> -/* The header starts with a WAVEFORMATEX */
> -if ((ret = ff_get_wav_header(s, s->pb, st->codecpar, 
> APM_FILE_HEADER_SIZE, 0)) < 0)
> -return ret;
> -
> -if (st->codecpar->bits_per_coded_sample != 4)
> +/*
> + * This is 98% a WAVEFORMATEX, but there's something screwy with the 
> extradata
> + * that ff_get_wav_header() can't (and shouldn't) handle properly.
> + */
> +if (avio_rl16(s->pb) != APM_TAG_CODEC)
>  return AVERROR_INVALIDDATA;
>  
> -if (st->codecpar->codec_tag != APM_TAG_CODEC)
> +par = st->codecpar;
> +par->channels  = avio_rl16(s->pb);
> +par->sample_rate   = avio_rl32(s->pb);
> +par->bit_rate  = avio_rl32(s->pb) * 8;
> +par->block_align   = avio_rl16(s->pb);
> +

Re: [FFmpeg-devel] [PATCH v2 5/7] avformat: add apm muxer

2020-06-10 Thread Zane van Iperen
On Thu, 11 Jun 2020 03:25:26 +0200
"Andreas Rheinhardt"  wrote:

> > +av_log(s, AV_LOG_ERROR,
> > +   "Filesize %"PRId64" invalid for APM, output file
> > will be broken\n",
> > +   file_size);
> > +return AVERROR(EINVAL);  
> 
> EINVAL seems wrong here (which invalid argument has been provided?).
> Maybe ERANGE?
> 

Okay, I'll use ERANGE. Is that the only thing? I'm prepared to send a
v3, but don't want to jump the gun.

Zane

___
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/7] avformat: add apm muxer

2020-06-10 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/apm.c| 110 ++-
>  4 files changed, 111 insertions(+), 2 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index 3c82f2ebd6..1f5250bb35 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -78,6 +78,7 @@ version 4.3:
>  - PFM decoder
>  - dblur video filter
>  - Real War KVAG muxer
> +- Rayman 2 APM muxer
>  
>  
>  version 4.2:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index bb09dc6563..a2691cb626 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -94,6 +94,7 @@ OBJS-$(CONFIG_ANM_DEMUXER)   += anm.o
>  OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
>  OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
>  OBJS-$(CONFIG_APM_DEMUXER)   += apm.o
> +OBJS-$(CONFIG_APM_MUXER) += apm.o rawenc.o
>  OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
>  OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
>  OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index a7c5c9db89..0c8788ef42 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -55,6 +55,7 @@ extern AVInputFormat  ff_anm_demuxer;
>  extern AVInputFormat  ff_apc_demuxer;
>  extern AVInputFormat  ff_ape_demuxer;
>  extern AVInputFormat  ff_apm_demuxer;
> +extern AVOutputFormat ff_apm_muxer;
>  extern AVInputFormat  ff_apng_demuxer;
>  extern AVOutputFormat ff_apng_muxer;
>  extern AVInputFormat  ff_aptx_demuxer;
> diff --git a/libavformat/apm.c b/libavformat/apm.c
> index 57d23200b0..dfdf451ec3 100644
> --- a/libavformat/apm.c
> +++ b/libavformat/apm.c
> @@ -1,5 +1,5 @@
>  /*
> - * Rayman 2 APM Demuxer
> + * Rayman 2 APM (De)muxer
>   *
>   * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
>   *
> @@ -21,6 +21,8 @@
>   */
>  #include "avformat.h"
>  #include "internal.h"
> +#include "rawenc.h"
> +#include "libavutil/avassert.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/intreadwrite.h"
>  
> @@ -48,13 +50,14 @@ typedef struct APMExtraData {
>  uint32_tmagic;
>  uint32_tfile_size;
>  uint32_tdata_size;
> -uint32_tunk1;
> +int32_t unk1;
>  uint32_tunk2;
>  APMStatestate;
>  uint32_tunk3[7];
>  uint32_tdata;
>  } APMExtraData;
>  
> +#if CONFIG_APM_DEMUXER
>  static void apm_parse_extradata(APMExtraData *ed, const uint8_t *buf)
>  {
>  ed->magic = AV_RL32(buf + 0);
> @@ -198,3 +201,106 @@ AVInputFormat ff_apm_demuxer = {
>  .read_header= apm_read_header,
>  .read_packet= apm_read_packet
>  };
> +#endif
> +
> +#if CONFIG_APM_MUXER
> +static int apm_write_init(AVFormatContext *s)
> +{
> +AVCodecParameters *par;
> +
> +if (s->nb_streams != 1) {
> +av_log(s, AV_LOG_ERROR, "APM files have exactly one stream\n");
> +return AVERROR(EINVAL);
> +}
> +
> +par = s->streams[0]->codecpar;
> +
> +if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_APM) {
> +av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
> +   avcodec_get_name(par->codec_id));
> +return AVERROR(EINVAL);
> +}
> +
> +if (par->channels > 2) {
> +av_log(s, AV_LOG_ERROR, "APM files only support up to 2 channels\n");
> +return AVERROR(EINVAL);
> +}
> +
> +if (par->extradata_size != APM_EXTRADATA_SIZE) {
> +av_log(s, AV_LOG_ERROR, "Invalid/missing extradata\n");
> +return AVERROR(EINVAL);
> +}
> +
> +if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
> +av_log(s, AV_LOG_ERROR, "Stream not seekable, unable to write output 
> file\n");
> +return AVERROR(EINVAL);
> +}
> +
> +return 0;
> +}
> +
> +static int apm_write_header(AVFormatContext *s)
> +{
> +uint8_t buf[APM_FILE_EXTRADATA_SIZE] = { 0 };
> +AVCodecParameters *par = s->streams[0]->codecpar;
> +
> +/*
> + * Bodge a WAVEFORMATEX manually, ff_put_wav_header() can't
> + * be used because of the extra 2 bytes.
> + */
> +avio_wl16(s->pb, APM_TAG_CODEC);
> +avio_wl16(s->pb, par->channels);
> +avio_wl32(s->pb, par->sample_rate);
> +avio_wl32(s->pb, par->sample_rate * par->channels * 2);
> +avio_wl16(s->pb, par->block_align);
> +avio_wl16(s->pb, par->bits_per_coded_sample);
> +avio_wl16(s->pb, APM_FILE_EXTRADATA_SIZE);
> +
> +avio_wl16(s->pb, 0); /* pad */
> +
> +/*
> + * Build the extradata. Assume the codec's given us correct data.
> + * File and data sizes are fixed later.
> + */
> +AV_WL32(buf +  0, APM_TAG_VS12); /* magic */
> +AV_WL32(buf + 12, -1);   /* unk1, always seems to be -1 */
> +memcpy( buf + 20, par->extradata, APM_EXTRADATA_SIZE);
> +AV_WL32(buf + 76, APM_TAG_DATA); /* 

Re: [FFmpeg-devel] [PATCH] added sei side data

2020-06-10 Thread Daniel Loman
Yes. I think what he was asking is are you sure you want to add this to the 
AVPacket which is encoded data and will be ordered in decode time not 
presentation time. The precision time stamp is a separate clock but should be 
more closely related to the presentation time stamp (assumming its there). It 
looks like there are several merge requests for adding side data to the AVFrame 
https://patchwork.ffmpeg.org/project/ffmpeg/patch/1591793766-15844-1-git-send-email-lance.lmw...@gmail.com/
 I am not sure if this is related or conincidental

Dan

From: ffmpeg-devel  on behalf of Brad Hards 

Sent: Wednesday, June 10, 2020 3:06 PM
To: 'FFmpeg development discussions and patches'
Subject: Re: [FFmpeg-devel] [PATCH] added sei side data

(CAUTION)This email originated outside Toyon. Do not click links or open 
attachments unless you recognize the sender and know the content is safe.


The side data that is added is a precision time stamp (MISB ST0603), which may 
or may not relate to the presentation time stamp.

Unfortunate overlap of acronym.

Brad

___
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 v11 4/4] avcodec/h264: create user data unregistered SEI side data for H.264

2020-06-10 Thread lance . lmwang
On Wed, Jun 10, 2020 at 08:02:10PM +0200, Marton Balint wrote:
> 
> 
> On Wed, 10 Jun 2020, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavcodec/h264_sei.c |  18 -
> > libavcodec/h264_sei.h |   2 +
> > libavcodec/h264_slice.c   |  14 
> > tests/ref/fate/mov-zombie | 195 
> > ++
> > 4 files changed, 161 insertions(+), 68 deletions(-)
> > 
> > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> > index 870dd90..a903706 100644
> > --- a/libavcodec/h264_sei.c
> > +++ b/libavcodec/h264_sei.c
> > @@ -52,6 +52,10 @@ void ff_h264_sei_uninit(H264SEIContext *h)
> > h->afd.present =  0;
> > 
> > av_buffer_unref(>a53_caption.buf_ref);
> > +for (int i = 0; i < h->unregistered.nb_buf_ref; i++)
> > +av_buffer_unref(>unregistered.buf_ref[i]);
> > +h->unregistered.nb_buf_ref = 0;
> > +av_freep(>unregistered.buf_ref);
> > }
> > 
> > int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS 
> > *sps,
> > @@ -260,25 +264,33 @@ static int 
> > decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext *
> > {
> > uint8_t *user_data;
> > int e, build, i;
> > +AVBufferRef *buf_ref, **tmp;
> > 
> > if (size < 16 || size >= INT_MAX - 1)
> > return AVERROR_INVALIDDATA;
> > 
> > -user_data = av_malloc(size + 1);
> > -if (!user_data)
> > +tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, 
> > sizeof(*h->buf_ref));
> > +if (!tmp)
> > return AVERROR(ENOMEM);
> > +h->buf_ref = tmp;
> > +
> > +buf_ref = av_buffer_alloc(size + 1);
> > +if (!buf_ref)
> > +return AVERROR(ENOMEM);
> 
> You are supposed to set buf_ref->size to size, otherwise the side data will
> also have the extra 1 byte padding as far as I see.

thanks, I got your points now.  I'll fix it

> 
> Thanks,
> Marton
> 
> > +user_data = buf_ref->data;
> > 
> > for (i = 0; i < size; i++)
> > user_data[i] = get_bits(gb, 8);
> > 
> > user_data[i] = 0;
> > +h->buf_ref[h->nb_buf_ref++] = buf_ref;
> > +
> > e = sscanf(user_data + 16, "x264 - core %d", );
> > if (e == 1 && build > 0)
> > h->x264_build = build;
> > if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core ", 
> > 16))
> > h->x264_build = 67;
> > 
> > -av_free(user_data);
> > return 0;
> > }
> > 
> > diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> > index f07a505..4fdcf4e 100644
> > --- a/libavcodec/h264_sei.h
> > +++ b/libavcodec/h264_sei.h
> > @@ -126,6 +126,8 @@ typedef struct H264SEIA53Caption {
> > 
> > typedef struct H264SEIUnregistered {
> > int x264_build;
> > +AVBufferRef **buf_ref;
> > +int nb_buf_ref;
> > } H264SEIUnregistered;
> > 
> > typedef struct H264SEIRecoveryPoint {
> > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> > index 7139537..47f3917 100644
> > --- a/libavcodec/h264_slice.c
> > +++ b/libavcodec/h264_slice.c
> > @@ -1289,6 +1289,20 @@ static int h264_export_frame_props(H264Context *h)
> > h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> > }
> > 
> > +for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
> > +H264SEIUnregistered *unreg = >sei.unregistered;
> > +
> > +if (unreg->buf_ref[i]) {
> > +AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f,
> > +AV_FRAME_DATA_SEI_UNREGISTERED,
> > +unreg->buf_ref[i]);
> > +if (!sd)
> > +av_buffer_unref(>buf_ref[i]);
> > +unreg->buf_ref[i] = NULL;
> > +}
> > +}
> > +h->sei.unregistered.nb_buf_ref = 0;
> > +
> > if (h->sei.picture_timing.timecode_cnt > 0) {
> > uint32_t tc = 0;
> > uint32_t *tc_sd;
> > diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie
> > index 445f921..1a6625b 100644
> > --- a/tests/ref/fate/mov-zombie
> > +++ b/tests/ref/fate/mov-zombie
> > @@ -1,133 +1,198 @@
> > packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_
> > packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1077|pos=15442|flags=__
> > 

Re: [FFmpeg-devel] [PATCH v11 3/4] avfilter/vf_showinfo: display H.26[45] user data unregistered sei message

2020-06-10 Thread lance . lmwang
On Wed, Jun 10, 2020 at 08:13:59PM +0200, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/vf_showinfo.c | 37 +
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index 5d4aee4..2511da5 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -37,6 +37,7 @@
> >  #include "libavutil/timecode.h"
> >  #include "libavutil/mastering_display_metadata.h"
> >  #include "libavutil/video_enc_params.h"
> > +#include "libavutil/avstring.h"
> >  
> >  #include "avfilter.h"
> >  #include "internal.h"
> > @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext 
> > *ctx, AVFrameSideData *sd)
> >  av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
> >  }
> >  
> > +static int string_is_print(const uint8_t *str)
> > +{
> > +while (av_isgraph(*str)) str++;
> > +return !*str;
> 
> This is dangerous: The SEI message needn't be zero-terminated, so this
> may segfault. Furthermore, it is also wrong: If the user data payload
> happens to contain a binary zero preceded by printable ASCII characters,
> it will be considered a string, even if there are unprintable characters
> after the binary zero (which may really happen if the payload is
> actually binary).

I'll consider to alloc one zero padding byte memory for user data to force
zero-terminated. For the second question, we'll print the printable string,
after the binary zero will ignored, I think it's expected? or do you want to
dump the left binary by hex? If so it's considerable to dump them by hex,
although it's not friendly if the data is string. 

> 
> > +}
> > +
> > +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, 
> > AVFrameSideData *sd)
> > +{
> > +const int uuid_size = 16;
> > +uint8_t *user_data = sd->data;
> > +
> > +if (sd->size < uuid_size) {
> > +av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", 
> > sd->size, uuid_size);
> > +return;
> > +}
> > +
> > +av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
> > +av_log(ctx, AV_LOG_INFO, "UUID=");
> > +for (int i = 0; i < uuid_size; i++) {
> > +av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
> > +if (i == 3 || i == 5 || i == 7 || i == 9)
> > +av_log(ctx, AV_LOG_INFO, "-");
> > +}
> > +av_log(ctx, AV_LOG_INFO, "\n");
> > +
> > +user_data += uuid_size;
> > +/* Only print the user data details if it's string */
> > +if (string_is_print(user_data)) {
> > +av_log(ctx, AV_LOG_INFO, "User Data=");
> > +av_log(ctx, AV_LOG_INFO, "%s", user_data);
> 
> Given that the user_data needn't be zero-terminated, you must specify
> the precision (i.e. the number of bytes to write) here.
> 
> > +}
> > +}
> > +
> >  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> >  {
> >  const char *color_range_str = 
> > av_color_range_name(frame->color_range);
> > @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> > *frame)
> >  case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
> >  dump_video_enc_params(ctx, sd);
> >  break;
> > +case AV_FRAME_DATA_SEI_UNREGISTERED:
> > +dump_sei_unregistered_metadata(ctx, sd);
> > +break;
> >  default:
> >  av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d 
> > bytes)",
> > sd->type, sd->size);
> > 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2 5/7] avformat: add apm muxer

2020-06-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/apm.c| 110 ++-
 4 files changed, 111 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 3c82f2ebd6..1f5250bb35 100644
--- a/Changelog
+++ b/Changelog
@@ -78,6 +78,7 @@ version 4.3:
 - PFM decoder
 - dblur video filter
 - Real War KVAG muxer
+- Rayman 2 APM muxer
 
 
 version 4.2:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index bb09dc6563..a2691cb626 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -94,6 +94,7 @@ OBJS-$(CONFIG_ANM_DEMUXER)   += anm.o
 OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
 OBJS-$(CONFIG_APM_DEMUXER)   += apm.o
+OBJS-$(CONFIG_APM_MUXER) += apm.o rawenc.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index a7c5c9db89..0c8788ef42 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -55,6 +55,7 @@ extern AVInputFormat  ff_anm_demuxer;
 extern AVInputFormat  ff_apc_demuxer;
 extern AVInputFormat  ff_ape_demuxer;
 extern AVInputFormat  ff_apm_demuxer;
+extern AVOutputFormat ff_apm_muxer;
 extern AVInputFormat  ff_apng_demuxer;
 extern AVOutputFormat ff_apng_muxer;
 extern AVInputFormat  ff_aptx_demuxer;
diff --git a/libavformat/apm.c b/libavformat/apm.c
index 57d23200b0..dfdf451ec3 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -1,5 +1,5 @@
 /*
- * Rayman 2 APM Demuxer
+ * Rayman 2 APM (De)muxer
  *
  * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
  *
@@ -21,6 +21,8 @@
  */
 #include "avformat.h"
 #include "internal.h"
+#include "rawenc.h"
+#include "libavutil/avassert.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 
@@ -48,13 +50,14 @@ typedef struct APMExtraData {
 uint32_tmagic;
 uint32_tfile_size;
 uint32_tdata_size;
-uint32_tunk1;
+int32_t unk1;
 uint32_tunk2;
 APMStatestate;
 uint32_tunk3[7];
 uint32_tdata;
 } APMExtraData;
 
+#if CONFIG_APM_DEMUXER
 static void apm_parse_extradata(APMExtraData *ed, const uint8_t *buf)
 {
 ed->magic = AV_RL32(buf + 0);
@@ -198,3 +201,106 @@ AVInputFormat ff_apm_demuxer = {
 .read_header= apm_read_header,
 .read_packet= apm_read_packet
 };
+#endif
+
+#if CONFIG_APM_MUXER
+static int apm_write_init(AVFormatContext *s)
+{
+AVCodecParameters *par;
+
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "APM files have exactly one stream\n");
+return AVERROR(EINVAL);
+}
+
+par = s->streams[0]->codecpar;
+
+if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_APM) {
+av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
+   avcodec_get_name(par->codec_id));
+return AVERROR(EINVAL);
+}
+
+if (par->channels > 2) {
+av_log(s, AV_LOG_ERROR, "APM files only support up to 2 channels\n");
+return AVERROR(EINVAL);
+}
+
+if (par->extradata_size != APM_EXTRADATA_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid/missing extradata\n");
+return AVERROR(EINVAL);
+}
+
+if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
+av_log(s, AV_LOG_ERROR, "Stream not seekable, unable to write output 
file\n");
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+
+static int apm_write_header(AVFormatContext *s)
+{
+uint8_t buf[APM_FILE_EXTRADATA_SIZE] = { 0 };
+AVCodecParameters *par = s->streams[0]->codecpar;
+
+/*
+ * Bodge a WAVEFORMATEX manually, ff_put_wav_header() can't
+ * be used because of the extra 2 bytes.
+ */
+avio_wl16(s->pb, APM_TAG_CODEC);
+avio_wl16(s->pb, par->channels);
+avio_wl32(s->pb, par->sample_rate);
+avio_wl32(s->pb, par->sample_rate * par->channels * 2);
+avio_wl16(s->pb, par->block_align);
+avio_wl16(s->pb, par->bits_per_coded_sample);
+avio_wl16(s->pb, APM_FILE_EXTRADATA_SIZE);
+
+avio_wl16(s->pb, 0); /* pad */
+
+/*
+ * Build the extradata. Assume the codec's given us correct data.
+ * File and data sizes are fixed later.
+ */
+AV_WL32(buf +  0, APM_TAG_VS12); /* magic */
+AV_WL32(buf + 12, -1);   /* unk1, always seems to be -1 */
+memcpy( buf + 20, par->extradata, APM_EXTRADATA_SIZE);
+AV_WL32(buf + 76, APM_TAG_DATA); /* data */
+
+avio_write(s->pb, buf, APM_FILE_EXTRADATA_SIZE);
+return 0;
+}
+
+static int apm_write_trailer(AVFormatContext *s)
+{
+int64_t file_size, data_size;
+
+file_size = avio_tell(s->pb);
+data_size = file_size - (APM_FILE_HEADER_SIZE + 2 + 
APM_FILE_EXTRADATA_SIZE);
+
+if (file_size >= 

[FFmpeg-devel] [PATCH v2 6/7] fate: add adpcm_ima_apm encoding test

2020-06-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 tests/fate/acodec.mak  | 2 ++
 tests/ref/acodec/adpcm-ima_apm | 4 
 2 files changed, 6 insertions(+)
 create mode 100644 tests/ref/acodec/adpcm-ima_apm

diff --git a/tests/fate/acodec.mak b/tests/fate/acodec.mak
index bb6bfe5ada..197b6ed7c0 100644
--- a/tests/fate/acodec.mak
+++ b/tests/fate/acodec.mak
@@ -45,6 +45,7 @@ fate-acodec-pcm-u%le: FMT = nut
 fate-acodec-pcm-f%be: FMT = au
 
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_ADX, ADX)  += adx
+FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_APM, APM)  += ima_apm
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_QT,  AIFF) += ima_qt
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_SSI, KVAG) += ima_ssi
 FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_WAV, WAV)  += ima_wav
@@ -59,6 +60,7 @@ fate-acodec-adpcm: $(FATE_ACODEC_ADPCM)
 fate-acodec-adpcm-%: CODEC = adpcm_$(@:fate-acodec-adpcm-%=%)
 
 fate-acodec-adpcm-adx: FMT = adx
+fate-acodec-adpcm-ima_apm: FMT = apm
 fate-acodec-adpcm-ima_qt:  FMT = aiff
 fate-acodec-adpcm-ima_ssi: FMT = kvag
 fate-acodec-adpcm-ima_wav: FMT = wav
diff --git a/tests/ref/acodec/adpcm-ima_apm b/tests/ref/acodec/adpcm-ima_apm
new file mode 100644
index 00..83bd21f831
--- /dev/null
+++ b/tests/ref/acodec/adpcm-ima_apm
@@ -0,0 +1,4 @@
+2e795c6c06baabe01ab92864d963e71b *tests/data/fate/acodec-adpcm-ima_apm.apm
+264700 tests/data/fate/acodec-adpcm-ima_apm.apm
+201607bf7610f062b9a1e6524354c569 *tests/data/fate/acodec-adpcm-ima_apm.out.wav
+stddev:  904.76 PSNR: 37.20 MAXDIFF:34029 bytes:  1058400/  1058400
-- 
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 v2 4/7] avcodec: add adpcm_ima_apm encoder

2020-06-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 doc/general.texi   |  2 +-
 libavcodec/Makefile|  1 +
 libavcodec/adpcmenc.c  | 34 --
 libavcodec/allcodecs.c |  1 +
 libavcodec/utils.c |  1 +
 5 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/doc/general.texi b/doc/general.texi
index 9b0ee96752..8df7445c36 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1109,7 +1109,7 @@ following image formats are supported:
 @item ADPCM IMA High Voltage Software ALP   @tab @tab  X
 @item ADPCM IMA QuickTime@tab  X  @tab  X
 @item ADPCM IMA Simon & Schuster Interactive   @tab  X  @tab  X
-@item ADPCM IMA Ubisoft APM  @tab @tab X
+@item ADPCM IMA Ubisoft APM  @tab  X  @tab  X
 @item ADPCM IMA Loki SDL MJPEG  @tab @tab  X
 @item ADPCM IMA WAV  @tab  X  @tab  X
 @item ADPCM IMA Westwood @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5a6ea59715..4ee0bf2d4c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -853,6 +853,7 @@ OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o 
adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER)  += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_IMA_APM_ENCODER)  += adpcmenc.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_CUNNING_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER)  += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index d5fbc0b9a7..8396180cb6 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -77,7 +77,9 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 
-if (avctx->trellis && avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI) {
+if (avctx->trellis &&
+   (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
+avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM)) {
 /*
  * The current trellis implementation doesn't work for extended
  * runs of samples without periodic resets. Disallow it.
@@ -152,6 +154,14 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 avctx->frame_size = BLKSIZE * 2 / avctx->channels;
 avctx->block_align = BLKSIZE;
 break;
+case AV_CODEC_ID_ADPCM_IMA_APM:
+avctx->frame_size = BLKSIZE * 2 / avctx->channels;
+avctx->block_align = BLKSIZE;
+
+if (!(avctx->extradata = av_mallocz(28)))
+goto error;
+avctx->extradata_size = 28;
+break;
 default:
 ret = AVERROR(EINVAL);
 goto error;
@@ -496,7 +506,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 if (avctx->codec_id == AV_CODEC_ID_ADPCM_SWF)
 pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) + 
7) / 8;
-else if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI)
+else if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
+ avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM)
 pkt_size = (frame->nb_samples * avctx->channels) / 2;
 else
 pkt_size = avctx->block_align;
@@ -717,6 +728,24 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 *dst++  = nibble;
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_APM:
+{
+PutBitContext pb;
+init_put_bits(, dst, pkt_size);
+
+av_assert0(avctx->trellis == 0);
+
+for (n = frame->nb_samples / 2; n > 0; n--) {
+for (ch = 0; ch < avctx->channels; ch++) {
+put_bits(, 4, adpcm_ima_qt_compress_sample(c->status + ch, 
*samples++));
+put_bits(, 4, adpcm_ima_qt_compress_sample(c->status + ch, 
samples[st]));
+}
+samples += avctx->channels;
+}
+
+flush_put_bits();
+break;
+}
 default:
 return AVERROR(EINVAL);
 }
@@ -751,6 +780,7 @@ AVCodec ff_ ## name_ ## _encoder = {
   \
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,   \
 }
 
+ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_APM, adpcm_ima_apm, sample_fmts,   
AV_CODEC_CAP_SMALL_LAST_FRAME, "ADPCM IMA Ubisoft APM");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, 0,  
   "ADPCM IMA QuickTime");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_SSI, adpcm_ima_ssi, sample_fmts,   
AV_CODEC_CAP_SMALL_LAST_FRAME, "ADPCM IMA Simon & Schuster Interactive");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, sample_fmts_p, 0,  
   "ADPCM IMA WAV");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 80f128cade..f7d560052e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -607,6 +607,7 @@ extern AVCodec ff_adpcm_ima_amv_decoder;
 extern 

[FFmpeg-devel] [PATCH v2 3/7] avcodec/adpcm_ima_apm: prepare extradata handling for encoder

2020-06-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavcodec/adpcm.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 79c5d625d1..328971adf1 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -162,11 +162,11 @@ static av_cold int adpcm_decode_init(AVCodecContext * 
avctx)
 }
 break;
 case AV_CODEC_ID_ADPCM_IMA_APM:
-if (avctx->extradata && avctx->extradata_size >= 16) {
-c->status[0].predictor  = av_clip_intp2(AV_RL32(avctx->extradata + 
 0), 18);
-c->status[0].step_index = av_clip(AV_RL32(avctx->extradata +  4), 
0, 88);
-c->status[1].predictor  = av_clip_intp2(AV_RL32(avctx->extradata + 
 8), 18);
-c->status[1].step_index = av_clip(AV_RL32(avctx->extradata + 12), 
0, 88);
+if (avctx->extradata && avctx->extradata_size >= 28) {
+c->status[0].predictor  = av_clip_intp2(AV_RL32(avctx->extradata + 
16), 18);
+c->status[0].step_index = av_clip(AV_RL32(avctx->extradata + 20), 
0, 88);
+c->status[1].predictor  = av_clip_intp2(AV_RL32(avctx->extradata + 
4), 18);
+c->status[1].step_index = av_clip(AV_RL32(avctx->extradata + 8), 
0, 88);
 }
 break;
 case AV_CODEC_ID_ADPCM_IMA_WS:
-- 
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 v2 7/7] avcodec/adpcmenc: cleanup trellis checks

2020-06-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavcodec/adpcmenc.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 8396180cb6..27b2a81f4b 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -72,25 +72,26 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 
-if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
-av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
-return AVERROR(EINVAL);
-}
+if (avctx->trellis) {
+int frontier, max_paths;
 
-if (avctx->trellis &&
-   (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
-avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM)) {
-/*
- * The current trellis implementation doesn't work for extended
- * runs of samples without periodic resets. Disallow it.
- */
-av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
-return AVERROR_PATCHWELCOME;
-}
+if ((unsigned)avctx->trellis > 16U) {
+av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
+return AVERROR(EINVAL);
+}
 
-if (avctx->trellis) {
-int frontier  = 1 << avctx->trellis;
-int max_paths =  frontier * FREEZE_INTERVAL;
+if (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
+avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM) {
+/*
+ * The current trellis implementation doesn't work for extended
+ * runs of samples without periodic resets. Disallow it.
+ */
+av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
+return AVERROR_PATCHWELCOME;
+}
+
+frontier  = 1 << avctx->trellis;
+max_paths =  frontier * FREEZE_INTERVAL;
 FF_ALLOC_OR_GOTO(avctx, s->paths,
  max_paths * sizeof(*s->paths), error);
 FF_ALLOC_OR_GOTO(avctx, s->node_buf,
-- 
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 v2 1/7] avformat/apm: check codec tag in probe and add constant

2020-06-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/apm.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/apm.c b/libavformat/apm.c
index 9d2a856cc4..dc59c16562 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -29,6 +29,7 @@
 #define APM_VS12_CHUNK_SIZE 76
 #define APM_MAX_READ_SIZE   4096
 
+#define APM_TAG_CODEC   0x2000
 #define APM_TAG_VS12MKTAG('v', 's', '1', '2')
 #define APM_TAG_DATAMKTAG('D', 'A', 'T', 'A')
 
@@ -74,6 +75,9 @@ static void apm_parse_vs12(APMVS12Chunk *vs12, const uint8_t 
*buf)
 
 static int apm_probe(const AVProbeData *p)
 {
+if (AV_RL16(p->buf) != APM_TAG_CODEC)
+return 0;
+
 if (p->buf_size < 100)
 return 0;
 
@@ -103,7 +107,7 @@ static int apm_read_header(AVFormatContext *s)
 if (st->codecpar->bits_per_coded_sample != 4)
 return AVERROR_INVALIDDATA;
 
-if (st->codecpar->codec_tag != 0x2000)
+if (st->codecpar->codec_tag != APM_TAG_CODEC)
 return AVERROR_INVALIDDATA;
 
 /* ff_get_wav_header() does most of the work, but we need to fix a few 
things. */
-- 
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 v2 2/7] avformat/apm: prepare extradata handling for muxer

2020-06-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/Makefile |   2 +-
 libavformat/apm.c| 130 +++
 2 files changed, 70 insertions(+), 62 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 0658fa3710..bb09dc6563 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -93,7 +93,7 @@ OBJS-$(CONFIG_AMRWB_DEMUXER) += amr.o
 OBJS-$(CONFIG_ANM_DEMUXER)   += anm.o
 OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
-OBJS-$(CONFIG_APM_DEMUXER)   += apm.o riffdec.o
+OBJS-$(CONFIG_APM_DEMUXER)   += apm.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
diff --git a/libavformat/apm.c b/libavformat/apm.c
index dc59c16562..57d23200b0 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -21,12 +21,13 @@
  */
 #include "avformat.h"
 #include "internal.h"
-#include "riff.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 
-#define APM_FILE_HEADER_SIZE20
-#define APM_VS12_CHUNK_SIZE 76
+#define APM_FILE_HEADER_SIZE18
+#define APM_FILE_EXTRADATA_SIZE 80
+#define APM_EXTRADATA_SIZE  28
+
 #define APM_MAX_READ_SIZE   4096
 
 #define APM_TAG_CODEC   0x2000
@@ -43,34 +44,37 @@ typedef struct APMState {
 int32_t saved_l;
 } APMState;
 
-typedef struct APMVS12Chunk {
+typedef struct APMExtraData {
 uint32_tmagic;
 uint32_tfile_size;
 uint32_tdata_size;
 uint32_tunk1;
 uint32_tunk2;
 APMStatestate;
-uint32_tpad[7];
-} APMVS12Chunk;
+uint32_tunk3[7];
+uint32_tdata;
+} APMExtraData;
 
-static void apm_parse_vs12(APMVS12Chunk *vs12, const uint8_t *buf)
+static void apm_parse_extradata(APMExtraData *ed, const uint8_t *buf)
 {
-vs12->magic = AV_RL32(buf + 0);
-vs12->file_size = AV_RL32(buf + 4);
-vs12->data_size = AV_RL32(buf + 8);
-vs12->unk1  = AV_RL32(buf + 12);
-vs12->unk2  = AV_RL32(buf + 16);
-
-vs12->state.has_saved   = AV_RL32(buf + 20);
-vs12->state.predictor_r = AV_RL32(buf + 24);
-vs12->state.step_index_r= AV_RL32(buf + 28);
-vs12->state.saved_r = AV_RL32(buf + 32);
-vs12->state.predictor_l = AV_RL32(buf + 36);
-vs12->state.step_index_l= AV_RL32(buf + 40);
-vs12->state.saved_l = AV_RL32(buf + 44);
-
-for (int i = 0; i < FF_ARRAY_ELEMS(vs12->pad); i++)
-vs12->pad[i]= AV_RL32(buf + 48 + (i * 4));
+ed->magic = AV_RL32(buf + 0);
+ed->file_size = AV_RL32(buf + 4);
+ed->data_size = AV_RL32(buf + 8);
+ed->unk1  = AV_RL32(buf + 12);
+ed->unk2  = AV_RL32(buf + 16);
+
+ed->state.has_saved   = AV_RL32(buf + 20);
+ed->state.predictor_r = AV_RL32(buf + 24);
+ed->state.step_index_r= AV_RL32(buf + 28);
+ed->state.saved_r = AV_RL32(buf + 32);
+ed->state.predictor_l = AV_RL32(buf + 36);
+ed->state.step_index_l= AV_RL32(buf + 40);
+ed->state.saved_l = AV_RL32(buf + 44);
+
+for (int i = 0; i < FF_ARRAY_ELEMS(ed->unk3); i++)
+ed->unk3[i]   = AV_RL32(buf + 48 + (i * 4));
+
+ed->data  = AV_RL32(buf + 76);
 }
 
 static int apm_probe(const AVProbeData *p)
@@ -94,71 +98,75 @@ static int apm_read_header(AVFormatContext *s)
 {
 int64_t ret;
 AVStream *st;
-APMVS12Chunk vs12;
-uint8_t buf[APM_VS12_CHUNK_SIZE];
+APMExtraData extradata;
+AVCodecParameters *par;
+uint8_t buf[APM_FILE_EXTRADATA_SIZE];
 
 if (!(st = avformat_new_stream(s, NULL)))
 return AVERROR(ENOMEM);
 
-/* The header starts with a WAVEFORMATEX */
-if ((ret = ff_get_wav_header(s, s->pb, st->codecpar, APM_FILE_HEADER_SIZE, 
0)) < 0)
-return ret;
-
-if (st->codecpar->bits_per_coded_sample != 4)
+/*
+ * This is 98% a WAVEFORMATEX, but there's something screwy with the 
extradata
+ * that ff_get_wav_header() can't (and shouldn't) handle properly.
+ */
+if (avio_rl16(s->pb) != APM_TAG_CODEC)
 return AVERROR_INVALIDDATA;
 
-if (st->codecpar->codec_tag != APM_TAG_CODEC)
+par = st->codecpar;
+par->channels  = avio_rl16(s->pb);
+par->sample_rate   = avio_rl32(s->pb);
+par->bit_rate  = avio_rl32(s->pb) * 8;
+par->block_align   = avio_rl16(s->pb);
+par->bits_per_coded_sample = avio_rl16(s->pb);
+
+if (avio_rl16(s->pb) != APM_FILE_EXTRADATA_SIZE)
 return AVERROR_INVALIDDATA;
 
-/* ff_get_wav_header() does most of the work, but we need to fix a few 
things. */
-st->codecpar->codec_id  = 

[FFmpeg-devel] [PATCH v2 0/7] adpcm_ima_apm encoder + apm muxer

2020-06-10 Thread Zane van Iperen
Add support for encoding adpcm_ima_apm and muxing to apm.

If possible, I would like to get this functionality into the 4.3
release.

v2: [1][2][3]
* fix mixed declarations and code
* remove unused variable
* fix array initialisation
* LOG_WARNING->LOG_ERROR
* reorder "name and probe fix"

Zane van Iperen (7):
  avformat/apm: check codec tag in probe and add constant
  avformat/apm: prepare extradata handling for muxer
  avcodec/adpcm_ima_apm: prepare extradata handling for encoder
  avcodec: add adpcm_ima_apm encoder
  avformat: add apm muxer
  fate: add adpcm_ima_apm encoding test
  avcodec/adpcmenc: cleanup trellis checks

 Changelog  |   1 +
 doc/general.texi   |   2 +-
 libavcodec/Makefile|   1 +
 libavcodec/adpcm.c |  10 +-
 libavcodec/adpcmenc.c  |  63 ++---
 libavcodec/allcodecs.c |   1 +
 libavcodec/utils.c |   1 +
 libavformat/Makefile   |   3 +-
 libavformat/allformats.c   |   1 +
 libavformat/apm.c  | 244 -
 tests/fate/acodec.mak  |   2 +
 tests/ref/acodec/adpcm-ima_apm |   4 +
 12 files changed, 247 insertions(+), 86 deletions(-)
 create mode 100644 tests/ref/acodec/adpcm-ima_apm

-- 
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] avfilter/vf_chromakey: The chromakey filter preserves non-opaque alpha transparency.

2020-06-10 Thread Gavin Smith


On 10/06/2020 22:33, Gavin Smith wrote:

From: Gavin Smith 


Sorry, new to all this. A description would have been helpful. I'll work 
on getting it right.


So this patch is to address Trac ticket #8724:

https://trac.ffmpeg.org/ticket/8724



---
  libavfilter/vf_chromakey.c | 43 ++
  1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/libavfilter/vf_chromakey.c b/libavfilter/vf_chromakey.c
index 4b1669d084..7206f1 100644
--- a/libavfilter/vf_chromakey.c
+++ b/libavfilter/vf_chromakey.c
@@ -47,7 +47,7 @@ typedef struct ChromakeyContext {
  int jobnr, int nb_jobs);
  } ChromakeyContext;
  
-static uint8_t do_chromakey_pixel(ChromakeyContext *ctx, uint8_t u[9], uint8_t v[9])

+static uint8_t do_chromakey_pixel(ChromakeyContext *ctx, uint8_t a, uint8_t 
u[9], uint8_t v[9])
  {
  double diff = 0.0;
  int du, dv, i;
@@ -62,13 +62,13 @@ static uint8_t do_chromakey_pixel(ChromakeyContext *ctx, 
uint8_t u[9], uint8_t v
  diff /= 9.0;
  
  if (ctx->blend > 0.0001) {

-return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * 
255.0;
+return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * 
(float)a;
  } else {
-return (diff > ctx->similarity) ? 255 : 0;
+return (diff > ctx->similarity) ? a : 0;
  }
  }
  
-static uint16_t do_chromakey_pixel16(ChromakeyContext *ctx, uint16_t u[9], uint16_t v[9])

+static uint16_t do_chromakey_pixel16(ChromakeyContext *ctx, uint16_t a, 
uint16_t u[9], uint16_t v[9])
  {
  double max = ctx->max;
  double diff = 0.0;
@@ -84,9 +84,9 @@ static uint16_t do_chromakey_pixel16(ChromakeyContext *ctx, 
uint16_t u[9], uint1
  diff /= 9.0;
  
  if (ctx->blend > 0.0001) {

-return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * max;
+return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * 
(float)a;
  } else {
-return (diff > ctx->similarity) ? max : 0;
+return (diff > ctx->similarity) ? a : 0;
  }
  }
  
@@ -131,13 +131,17 @@ static int do_chromakey_slice(AVFilterContext *avctx, void *arg, int jobnr, int
  
  for (y = slice_start; y < slice_end; ++y) {

  for (x = 0; x < frame->width; ++x) {
-for (yo = 0; yo < 3; ++yo) {
-for (xo = 0; xo < 3; ++xo) {
-get_pixel_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x + xo - 1, y 
+ yo - 1, [yo * 3 + xo], [yo * 3 + xo]);
+uint8_t *a = frame->data[3] + frame->linesize[3] * y;
+const uint8_t ao = a[x];
+
+if (ao != 0) {
+for (yo = 0; yo < 3; ++yo) {
+for (xo = 0; xo < 3; ++xo) {
+get_pixel_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x + xo - 
1, y + yo - 1, [yo * 3 + xo], [yo * 3 + xo]);
+}
  }
+a[x] = do_chromakey_pixel(ctx, ao, u, v);
  }
-
-frame->data[3][frame->linesize[3] * y + x] = 
do_chromakey_pixel(ctx, u, v);
  }
  }
  
@@ -163,15 +167,18 @@ static int do_chromakey16_slice(AVFilterContext *avctx, void *arg, int jobnr, in
  
  for (y = slice_start; y < slice_end; ++y) {

  for (x = 0; x < frame->width; ++x) {
-uint16_t *dst = (uint16_t *)(frame->data[3] + frame->linesize[3] * 
y);
-
-for (yo = 0; yo < 3; ++yo) {
-for (xo = 0; xo < 3; ++xo) {
-get_pixel16_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x + xo - 1, 
y + yo - 1, [yo * 3 + xo], [yo * 3 + xo]);
+uint16_t *a = (uint16_t *)(frame->data[3] + frame->linesize[3] * 
y);
+const uint16_t ao = a[x];
+
+if (ao != 0) {
+for (yo = 0; yo < 3; ++yo) {
+for (xo = 0; xo < 3; ++xo) {
+get_pixel16_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x + xo - 
1, y + yo - 1, [yo * 3 + xo], [yo * 3 + xo]);
+}
  }
-}
  
-dst[x] = do_chromakey_pixel16(ctx, u, v);

+a[x] = do_chromakey_pixel16(ctx, ao, u, v);
+}
  }
  }
  

___
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] pthread_frame: change the criterium for updating thread contexts

2020-06-10 Thread James Almer
On 6/9/2020 8:20 AM, Anton Khirnov wrote:
> Currently the next thread's context is updated from the previous one's
> if the codec descriptor is not marked as intra-only. That is not
> entirely correct, since that property does not necessarily imply
> anything about how a specific decoder implementation behaves.
> 
> Instead, use the presence of the update_thread_context() callback to
> decide whether an update should be performed. Fixes races in CFHD,
> should cause no behaviour change in any other decoders.
> ---
>  libavcodec/pthread_frame.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index 601f170447..3255aa9337 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -246,7 +246,7 @@ static int update_context_from_thread(AVCodecContext 
> *dst, AVCodecContext *src,
>  {
>  int err = 0;
>  
> -if (dst != src && (for_user || !(src->codec_descriptor->props & 
> AV_CODEC_PROP_INTRA_ONLY))) {
> +if (dst != src && (for_user || src->codec->update_thread_context)) {
>  dst->time_base = src->time_base;
>  dst->framerate = src->framerate;
>  dst->width = src->width;

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

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

Re: [FFmpeg-devel] [PATCH] added sei side data

2020-06-10 Thread Brad Hards
The side data that is added is a precision time stamp (MISB ST0603), which may 
or may not relate to the presentation time stamp. 

Unfortunate overlap of acronym.

Brad

___
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] OS/2:Support linking against libcx

2020-06-10 Thread Michael Niedermayer
On Tue, Jun 09, 2020 at 11:11:48PM -0700, Dave Yeo wrote:
> Hi, could I get this pushed to trunk and the 4.3 branch? Fixes a build break
> in libavformat/ip.c (implicit declaration of function 'getaddrinfo') and
> also need the prototype.
> Thanks,
> Dave

it seems this breaks build on linux

CC  libavformat/avio.o
In file included from libavformat/avio.c:31:0:
libavformat/network.h:137:8: error: redefinition of ‘struct addrinfo’
 struct addrinfo {
^~~~
In file included from libavformat/network.h:66:0,
 from libavformat/avio.c:31:
/usr/include/netdb.h:565:8: note: originally defined here
 struct addrinfo
^~~~
ffbuild/common.mak:59: recipe for target 'libavformat/avio.o' failed
make: *** [libavformat/avio.o] Error 1


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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



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

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

Re: [FFmpeg-devel] [PATCH 4/7] avformat: add apm muxer

2020-06-10 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/apm.c| 112 ++-
>  4 files changed, 113 insertions(+), 2 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index 3c82f2ebd6..1f5250bb35 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -78,6 +78,7 @@ version 4.3:
>  - PFM decoder
>  - dblur video filter
>  - Real War KVAG muxer
> +- Rayman 2 APM muxer
>  
>  
>  version 4.2:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index bb09dc6563..a2691cb626 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -94,6 +94,7 @@ OBJS-$(CONFIG_ANM_DEMUXER)   += anm.o
>  OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
>  OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
>  OBJS-$(CONFIG_APM_DEMUXER)   += apm.o
> +OBJS-$(CONFIG_APM_MUXER) += apm.o rawenc.o
>  OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
>  OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
>  OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index a7c5c9db89..0c8788ef42 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -55,6 +55,7 @@ extern AVInputFormat  ff_anm_demuxer;
>  extern AVInputFormat  ff_apc_demuxer;
>  extern AVInputFormat  ff_ape_demuxer;
>  extern AVInputFormat  ff_apm_demuxer;
> +extern AVOutputFormat ff_apm_muxer;
>  extern AVInputFormat  ff_apng_demuxer;
>  extern AVOutputFormat ff_apng_muxer;
>  extern AVInputFormat  ff_aptx_demuxer;
> diff --git a/libavformat/apm.c b/libavformat/apm.c
> index 16ac6a2b1a..46a0c67b79 100644
> --- a/libavformat/apm.c
> +++ b/libavformat/apm.c
> @@ -1,5 +1,5 @@
>  /*
> - * Rayman 2 APM Demuxer
> + * Rayman 2 APM (De)muxer
>   *
>   * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
>   *
> @@ -21,6 +21,8 @@
>   */
>  #include "avformat.h"
>  #include "internal.h"
> +#include "rawenc.h"
> +#include "libavutil/avassert.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/intreadwrite.h"
>  
> @@ -48,13 +50,14 @@ typedef struct APMExtraData {
>  uint32_tmagic;
>  uint32_tfile_size;
>  uint32_tdata_size;
> -uint32_tunk1;
> +int32_t unk1;
>  uint32_tunk2;
>  APMStatestate;
>  uint32_tunk3[7];
>  uint32_tdata;
>  } APMExtraData;
>  
> +#if CONFIG_APM_DEMUXER
>  static void apm_parse_extradata(APMExtraData *ed, const uint8_t *buf)
>  {
>  ed->magic = AV_RL32(buf + 0);
> @@ -195,3 +198,108 @@ AVInputFormat ff_apm_demuxer = {
>  .read_header= apm_read_header,
>  .read_packet= apm_read_packet
>  };
> +#endif
> +
> +#if CONFIG_APM_MUXER
> +static int apm_write_init(AVFormatContext *s)
> +{
> +AVCodecParameters *par;
> +
> +if (s->nb_streams != 1) {
> +av_log(s, AV_LOG_ERROR, "APM files have exactly one stream\n");
> +return AVERROR(EINVAL);
> +}
> +
> +par = s->streams[0]->codecpar;
> +
> +if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_APM) {
> +av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
> +   avcodec_get_name(par->codec_id));
> +return AVERROR(EINVAL);
> +}
> +
> +if (par->channels > 2) {
> +av_log(s, AV_LOG_ERROR, "APM files only support up to 2 channels\n");
> +return AVERROR(EINVAL);
> +}
> +
> +if (par->extradata_size != APM_EXTRADATA_SIZE) {
> +av_log(s, AV_LOG_ERROR, "Invalid/missing extradata\n");
> +return AVERROR(EINVAL);
> +}
> +
> +if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
> +av_log(s, AV_LOG_WARNING, "Stream not seekable, unable to write 
> output file\n");

You are erroring out here, so this should be AV_LOG_ERROR.

> +return AVERROR(EINVAL);
> +}
> +
> +return 0;
> +}
> +
> +static int apm_write_header(AVFormatContext *s)
> +{
> +APMExtraData extradata;

Unused.

> +uint8_t buf[APM_FILE_EXTRADATA_SIZE];

You can initialize this buf by = { 0 }; here and don't need to rely on
memset.

> +AVCodecParameters *par = s->streams[0]->codecpar;
> +
> +memset(buf, 0, APM_FILE_EXTRADATA_SIZE);
> +
> +/*
> + * Bodge a WAVEFORMATEX manually, ff_put_wav_header() can't
> + * be used because of the extra 2 bytes.
> + */
> +avio_wl16(s->pb, APM_CODEC_TAG);
> +avio_wl16(s->pb, par->channels);
> +avio_wl32(s->pb, par->sample_rate);
> +avio_wl32(s->pb, par->sample_rate * par->channels * 2);
> +avio_wl16(s->pb, par->block_align);
> +avio_wl16(s->pb, par->bits_per_coded_sample);
> +avio_wl16(s->pb, APM_FILE_EXTRADATA_SIZE);
> +
> +avio_wl16(s->pb, 0); /* pad */
> +
> +/*
> + * Build the extradata. Assume the codec's given us correct data.
> + * File and data sizes are fixed later.
> + */
> 

Re: [FFmpeg-devel] [PATCH 6/7] avformat/apm: name and probe fix

2020-06-10 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  libavformat/apm.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/apm.c b/libavformat/apm.c
> index 46a0c67b79..8ece104ae7 100644
> --- a/libavformat/apm.c
> +++ b/libavformat/apm.c
> @@ -31,8 +31,8 @@
>  #define APM_EXTRADATA_SIZE  28
>  
>  #define APM_MAX_READ_SIZE   4096
> -#define APM_CODEC_TAG   0x2000
>  
> +#define APM_TAG_CODEC   0x2000
>  #define APM_TAG_VS12MKTAG('v', 's', '1', '2')
>  #define APM_TAG_DATAMKTAG('D', 'A', 'T', 'A')
>  
> @@ -82,6 +82,9 @@ static void apm_parse_extradata(APMExtraData *ed, const 
> uint8_t *buf)
>  
>  static int apm_probe(const AVProbeData *p)
>  {
> +if (AV_RL16(p->buf) != APM_TAG_CODEC)
> +return 0;
> +
>  if (p->buf_size < 100)
>  return 0;
>  
> @@ -109,7 +112,7 @@ static int apm_read_header(AVFormatContext *s)
>   * This is 98% a WAVEFORMATEX, but there's something screwy with the 
> extradata
>   * that ff_get_wav_header() can't (and shouldn't) handle properly.
>   */
> -if (avio_rl16(s->pb) != APM_CODEC_TAG)
> +if (avio_rl16(s->pb) != APM_TAG_CODEC)
>  return AVERROR_INVALIDDATA;
>  
>  par = st->codecpar;
> @@ -248,7 +251,7 @@ static int apm_write_header(AVFormatContext *s)
>   * Bodge a WAVEFORMATEX manually, ff_put_wav_header() can't
>   * be used because of the extra 2 bytes.
>   */
> -avio_wl16(s->pb, APM_CODEC_TAG);
> +avio_wl16(s->pb, APM_TAG_CODEC);
>  avio_wl16(s->pb, par->channels);
>  avio_wl32(s->pb, par->sample_rate);
>  avio_wl32(s->pb, par->sample_rate * par->channels * 2);
> 
Why is this patch not applied before the addition of the muxer? If the
order were reversed, apm_write_header wouldn't need to be modified
immediately afterwards.

- 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 7/7] avcodec/adpcmenc: cleanup trellis checks

2020-06-10 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  libavcodec/adpcmenc.c | 29 ++---
>  1 file changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
> index 242c92e61a..c18e67a94f 100644
> --- a/libavcodec/adpcmenc.c
> +++ b/libavcodec/adpcmenc.c
> @@ -72,23 +72,22 @@ static av_cold int adpcm_encode_init(AVCodecContext 
> *avctx)
>  return AVERROR(EINVAL);
>  }
>  
> -if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
> -av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
> -return AVERROR(EINVAL);
> -}
> +if (avctx->trellis) {
> +if ((unsigned)avctx->trellis > 16U) {
> +av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
> +return AVERROR(EINVAL);
> +}
>  
> -if (avctx->trellis &&
> -   (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
> -avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM)) {
> -/*
> - * The current trellis implementation doesn't work for extended
> - * runs of samples without periodic resets. Disallow it.
> - */
> -av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
> -return AVERROR_PATCHWELCOME;
> -}
> +if (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
> +avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM) {
> +/*
> + * The current trellis implementation doesn't work for extended
> + * runs of samples without periodic resets. Disallow it.
> + */
> +av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
> +return AVERROR_PATCHWELCOME;
> +}
>  
> -if (avctx->trellis) {
>  int frontier  = 1 << avctx->trellis;>  int max_paths =  
> frontier * FREEZE_INTERVAL;

These declarations will be in the middle of the trellis block after this
patch, leading to new warnings.

>  FF_ALLOC_OR_GOTO(avctx, s->paths,
> 

___
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 v11 3/4] avfilter/vf_showinfo: display H.26[45] user data unregistered sei message

2020-06-10 Thread Andreas Rheinhardt
lance.lmw...@gmail.com:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/vf_showinfo.c | 37 +
>  1 file changed, 37 insertions(+)
> 
> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> index 5d4aee4..2511da5 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -37,6 +37,7 @@
>  #include "libavutil/timecode.h"
>  #include "libavutil/mastering_display_metadata.h"
>  #include "libavutil/video_enc_params.h"
> +#include "libavutil/avstring.h"
>  
>  #include "avfilter.h"
>  #include "internal.h"
> @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext *ctx, 
> AVFrameSideData *sd)
>  av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
>  }
>  
> +static int string_is_print(const uint8_t *str)
> +{
> +while (av_isgraph(*str)) str++;
> +return !*str;

This is dangerous: The SEI message needn't be zero-terminated, so this
may segfault. Furthermore, it is also wrong: If the user data payload
happens to contain a binary zero preceded by printable ASCII characters,
it will be considered a string, even if there are unprintable characters
after the binary zero (which may really happen if the payload is
actually binary).

> +}
> +
> +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, 
> AVFrameSideData *sd)
> +{
> +const int uuid_size = 16;
> +uint8_t *user_data = sd->data;
> +
> +if (sd->size < uuid_size) {
> +av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", 
> sd->size, uuid_size);
> +return;
> +}
> +
> +av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
> +av_log(ctx, AV_LOG_INFO, "UUID=");
> +for (int i = 0; i < uuid_size; i++) {
> +av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
> +if (i == 3 || i == 5 || i == 7 || i == 9)
> +av_log(ctx, AV_LOG_INFO, "-");
> +}
> +av_log(ctx, AV_LOG_INFO, "\n");
> +
> +user_data += uuid_size;
> +/* Only print the user data details if it's string */
> +if (string_is_print(user_data)) {
> +av_log(ctx, AV_LOG_INFO, "User Data=");
> +av_log(ctx, AV_LOG_INFO, "%s", user_data);

Given that the user_data needn't be zero-terminated, you must specify
the precision (i.e. the number of bytes to write) here.

> +}
> +}
> +
>  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
>  {
>  const char *color_range_str = 
> av_color_range_name(frame->color_range);
> @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *frame)
>  case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
>  dump_video_enc_params(ctx, sd);
>  break;
> +case AV_FRAME_DATA_SEI_UNREGISTERED:
> +dump_sei_unregistered_metadata(ctx, sd);
> +break;
>  default:
>  av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d 
> bytes)",
> sd->type, sd->size);
> 

___
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 v11 4/4] avcodec/h264: create user data unregistered SEI side data for H.264

2020-06-10 Thread Marton Balint



On Wed, 10 Jun 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavcodec/h264_sei.c |  18 -
libavcodec/h264_sei.h |   2 +
libavcodec/h264_slice.c   |  14 
tests/ref/fate/mov-zombie | 195 ++
4 files changed, 161 insertions(+), 68 deletions(-)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 870dd90..a903706 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -52,6 +52,10 @@ void ff_h264_sei_uninit(H264SEIContext *h)
h->afd.present =  0;

av_buffer_unref(>a53_caption.buf_ref);
+for (int i = 0; i < h->unregistered.nb_buf_ref; i++)
+av_buffer_unref(>unregistered.buf_ref[i]);
+h->unregistered.nb_buf_ref = 0;
+av_freep(>unregistered.buf_ref);
}

int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
@@ -260,25 +264,33 @@ static int 
decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext *
{
uint8_t *user_data;
int e, build, i;
+AVBufferRef *buf_ref, **tmp;

if (size < 16 || size >= INT_MAX - 1)
return AVERROR_INVALIDDATA;

-user_data = av_malloc(size + 1);
-if (!user_data)
+tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
+if (!tmp)
return AVERROR(ENOMEM);
+h->buf_ref = tmp;
+
+buf_ref = av_buffer_alloc(size + 1);
+if (!buf_ref)
+return AVERROR(ENOMEM);


You are supposed to set buf_ref->size to size, otherwise the side 
data will also have the extra 1 byte padding as far as I see.


Thanks,
Marton


+user_data = buf_ref->data;

for (i = 0; i < size; i++)
user_data[i] = get_bits(gb, 8);

user_data[i] = 0;
+h->buf_ref[h->nb_buf_ref++] = buf_ref;
+
e = sscanf(user_data + 16, "x264 - core %d", );
if (e == 1 && build > 0)
h->x264_build = build;
if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core ", 16))
h->x264_build = 67;

-av_free(user_data);
return 0;
}

diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index f07a505..4fdcf4e 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -126,6 +126,8 @@ typedef struct H264SEIA53Caption {

typedef struct H264SEIUnregistered {
int x264_build;
+AVBufferRef **buf_ref;
+int nb_buf_ref;
} H264SEIUnregistered;

typedef struct H264SEIRecoveryPoint {
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 7139537..47f3917 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1289,6 +1289,20 @@ static int h264_export_frame_props(H264Context *h)
h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
}

+for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
+H264SEIUnregistered *unreg = >sei.unregistered;
+
+if (unreg->buf_ref[i]) {
+AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f,
+AV_FRAME_DATA_SEI_UNREGISTERED,
+unreg->buf_ref[i]);
+if (!sd)
+av_buffer_unref(>buf_ref[i]);
+unreg->buf_ref[i] = NULL;
+}
+}
+h->sei.unregistered.nb_buf_ref = 0;
+
if (h->sei.picture_timing.timecode_cnt > 0) {
uint32_t tc = 0;
uint32_t *tc_sd;
diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie
index 445f921..1a6625b 100644
--- a/tests/ref/fate/mov-zombie
+++ b/tests/ref/fate/mov-zombie
@@ -1,133 +1,198 @@
packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_
packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1077|pos=15442|flags=__
-frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.00|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.00|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleft

Re: [FFmpeg-devel] [IMPORTANT] FOSDEM meeting

2020-06-10 Thread Thilo Borgmann
Hi,

> As a reminder, this week-end is the FOSDEM, in Brussels.
> 
> As promised, we will do a FFmpeg developer meeting, where we will vote on the 
> decisions taken during VDD.
> Notably, re-elect the committees, and the voted will  now be done by the new 
> electors.
> 
> This will take place on Saturday (Sunday is the dev room), probably at 14:00 
> if we can.
> It will be joinable through some VideoConf tool.
> 
> If you cannot go to FOSDEM for money reasons, please contact me. Both FFmpeg 
> and VideoLAN can sponsor your venue to Brussels!
> 
> Hoping on seeing you in BRU.

having settled (hopefully) on an implementation that complies to the voting 
scheme we agreed upon during the last developer meeting I just created a test 
vote as a final check.

During the meeting we agreed upon some requirements for selecting the General 
Assembly. A corresponding preliminary implementation from Josh has been used to 
identify 49 members of the General Assemby:

https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2020-April/261323.html

If your name appears in the output of the script you should have received an 
email form ffmpeg.vot...@gmail.com announcing the test vote.

If this test succeeds, the votes announced during the meeting can finally 
happen soon.

Cheers,
Thilo
___
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] release/4.3

2020-06-10 Thread Kieran Kunhya
>
> >> Against, release name as always should be George or Carl.
> >
> > Quit it.
>
> You are against my vote for release name?
> How unfortunate.
>

Give it a rest.
___
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] release/4.3

2020-06-10 Thread Paul B Mahol
On 6/10/20, James Almer  wrote:
> On 6/9/2020 6:00 PM, Paul B Mahol wrote:
>> On 6/9/20, Michael Niedermayer  wrote:
>>> On Tue, Jun 09, 2020 at 03:14:13PM +0200, Reto Kromer wrote:
 Michael Niedermayer wrote:

>> Is there any chance that the naming system could be changed
>> for this one release so it's 4:3 instead?
>
> thats a funny idea but we would be causing pain with that to
> anyone trying to grep or sort releases

 You could have the release 4.3 named "4:3" rather than a
 person's name.
>>>
>>> iam fine with that, anyone else has comments or a strong oppinion
>>> on that ?
>>
>> Against, release name as always should be George or Carl.
>
> Quit it.

You are against my vote for release name?
How unfortunate.

> ___
> 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] release/4.3

2020-06-10 Thread James Almer
On 6/9/2020 6:00 PM, Paul B Mahol wrote:
> On 6/9/20, Michael Niedermayer  wrote:
>> On Tue, Jun 09, 2020 at 03:14:13PM +0200, Reto Kromer wrote:
>>> Michael Niedermayer wrote:
>>>
> Is there any chance that the naming system could be changed
> for this one release so it's 4:3 instead?

 thats a funny idea but we would be causing pain with that to
 anyone trying to grep or sort releases
>>>
>>> You could have the release 4.3 named "4:3" rather than a
>>> person's name.
>>
>> iam fine with that, anyone else has comments or a strong oppinion
>> on that ?
> 
> Against, release name as always should be George or Carl.

Quit it.
___
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] dnn_backend_native: check operand index

2020-06-10 Thread Guo Yejun
it fixed the issue in https://trac.ffmpeg.org/ticket/8716

Signed-off-by: Guo Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   |  6 +-
 libavfilter/dnn/dnn_backend_native_layer_conv2d.c  |  7 ++-
 libavfilter/dnn/dnn_backend_native_layer_conv2d.h  |  2 +-
 libavfilter/dnn/dnn_backend_native_layer_depth2space.c |  6 +-
 libavfilter/dnn/dnn_backend_native_layer_depth2space.h |  2 +-
 libavfilter/dnn/dnn_backend_native_layer_mathbinary.c  | 12 +++-
 libavfilter/dnn/dnn_backend_native_layer_mathbinary.h  |  2 +-
 libavfilter/dnn/dnn_backend_native_layer_mathunary.c   |  6 +-
 libavfilter/dnn/dnn_backend_native_layer_mathunary.h   |  2 +-
 libavfilter/dnn/dnn_backend_native_layer_maximum.c |  6 +-
 libavfilter/dnn/dnn_backend_native_layer_maximum.h |  2 +-
 libavfilter/dnn/dnn_backend_native_layer_pad.c |  6 +-
 libavfilter/dnn/dnn_backend_native_layer_pad.h |  2 +-
 libavfilter/dnn/dnn_backend_native_layers.h|  2 +-
 14 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 12695a0..35236fc 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -196,7 +196,7 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 }
 
 network->layers[layer].type = layer_type;
-parsed_size = layer_funcs[layer_type].pf_load(>layers[layer], 
model_file_context, file_size);
+parsed_size = layer_funcs[layer_type].pf_load(>layers[layer], 
model_file_context, file_size, network->operands_num);
 if (!parsed_size) {
 goto fail;
 }
@@ -209,6 +209,10 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 int32_t operand_index = (int32_t)avio_rl32(model_file_context);
 dnn_size += 4;
 
+if (operand_index >= network->operands_num) {
+goto fail;
+}
+
 oprd = >operands[operand_index];
 name_len = (int32_t)avio_rl32(model_file_context);
 dnn_size += 4;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 7b29697..c05bb5e 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -23,7 +23,7 @@
 
 #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
 
-int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size)
+int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
 {
 ConvolutionalParams *conv_params;
 int kernel_size;
@@ -80,6 +80,11 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext 
*model_file_context, int fil
 layer->input_operand_indexes[0] = (int32_t)avio_rl32(model_file_context);
 layer->output_operand_index = (int32_t)avio_rl32(model_file_context);
 dnn_size += 8;
+
+if (layer->input_operand_indexes[0] >= operands_num || 
layer->output_operand_index >= operands_num) {
+return 0;
+}
+
 return dnn_size;
 }
 
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
index bf87264..eeb15fd 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
@@ -36,7 +36,7 @@ typedef struct ConvolutionalParams{
 float *biases;
 } ConvolutionalParams;
 
-int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size);
+int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num);
 int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t 
*input_operand_indexes,
  int32_t output_operand_index, const void 
*parameters);
 #endif
diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c 
b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
index 7dab19d..324871c 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
@@ -27,7 +27,7 @@
 #include "libavutil/avassert.h"
 #include "dnn_backend_native_layer_depth2space.h"
 
-int dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, 
int file_size)
+int dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, 
int file_size, int operands_num)
 {
 DepthToSpaceParams *params;
 int dnn_size = 0;
@@ -42,6 +42,10 @@ int dnn_load_layer_depth2space(Layer *layer, AVIOContext 
*model_file_context, in
 dnn_size += 8;
 layer->params = params;
 
+if (layer->input_operand_indexes[0] >= operands_num || 
layer->output_operand_index >= operands_num) {
+return 0;
+}
+
 return dnn_size;
 }
 
diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.h 

[FFmpeg-devel] [PATCH 1/2] dnn_backend_native.c: refine code for fail case

2020-06-10 Thread Guo Yejun
Signed-off-by: Guo Yejun 
---
 libavfilter/dnn/dnn_backend_native.c | 82 +---
 1 file changed, 38 insertions(+), 44 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 94634b3..12695a0 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -126,26 +126,23 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 int32_t layer;
 DNNLayerType layer_type;
 
-model = av_malloc(sizeof(DNNModel));
-if (!model){
-return NULL;
-}
-
 if (avio_open(_file_context, model_filename, AVIO_FLAG_READ) < 0){
-av_freep();
 return NULL;
 }
 file_size = avio_size(model_file_context);
 
+model = av_mallocz(sizeof(DNNModel));
+if (!model){
+goto fail;
+}
+
 /**
  * check file header with string and version
  */
 size = sizeof(header_expected);
 buf = av_malloc(size);
 if (!buf) {
-avio_closep(_file_context);
-av_freep();
-return NULL;
+goto fail;
 }
 
 // size - 1 to skip the ending '\0' which is not saved in file
@@ -153,18 +150,14 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 dnn_size = size - 1;
 if (strncmp(buf, header_expected, size) != 0) {
 av_freep();
-avio_closep(_file_context);
-av_freep();
-return NULL;
+goto fail;
 }
 av_freep();
 
 version = (int32_t)avio_rl32(model_file_context);
 dnn_size += 4;
 if (version != major_version_expected) {
-avio_closep(_file_context);
-av_freep();
-return NULL;
+goto fail;
 }
 
 // currently no need to check minor version
@@ -174,9 +167,7 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 
 network = av_mallocz(sizeof(ConvolutionalNetwork));
 if (!network){
-avio_closep(_file_context);
-av_freep();
-return NULL;
+goto fail;
 }
 model->model = (void *)network;
 
@@ -188,16 +179,12 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 
 network->layers = av_mallocz(network->layers_num * sizeof(Layer));
 if (!network->layers){
-avio_closep(_file_context);
-ff_dnn_free_model_native();
-return NULL;
+goto fail;
 }
 
 network->operands = av_mallocz(network->operands_num * sizeof(DnnOperand));
 if (!network->operands){
-avio_closep(_file_context);
-ff_dnn_free_model_native();
-return NULL;
+goto fail;
 }
 
 for (layer = 0; layer < network->layers_num; ++layer){
@@ -205,17 +192,13 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 dnn_size += 4;
 
 if (layer_type >= DLT_COUNT) {
-avio_closep(_file_context);
-ff_dnn_free_model_native();
-return NULL;
+goto fail;
 }
 
 network->layers[layer].type = layer_type;
 parsed_size = layer_funcs[layer_type].pf_load(>layers[layer], 
model_file_context, file_size);
 if (!parsed_size) {
-avio_closep(_file_context);
-ff_dnn_free_model_native();
-return NULL;
+goto fail;
 }
 dnn_size += parsed_size;
 }
@@ -258,6 +241,11 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename)
 model->get_input = _input_native;
 
 return model;
+
+fail:
+ff_dnn_free_model_native();
+avio_closep(_file_context);
+return NULL;
 }
 
 DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
*outputs, uint32_t nb_output)
@@ -314,23 +302,29 @@ void ff_dnn_free_model_native(DNNModel **model)
 
 if (*model)
 {
-network = (ConvolutionalNetwork *)(*model)->model;
-for (layer = 0; layer < network->layers_num; ++layer){
-if (network->layers[layer].type == DLT_CONV2D){
-conv_params = (ConvolutionalParams 
*)network->layers[layer].params;
-av_freep(_params->kernel);
-av_freep(_params->biases);
+if ((*model)->model) {
+network = (ConvolutionalNetwork *)(*model)->model;
+if (network->layers) {
+for (layer = 0; layer < network->layers_num; ++layer){
+if (network->layers[layer].type == DLT_CONV2D){
+conv_params = (ConvolutionalParams 
*)network->layers[layer].params;
+av_freep(_params->kernel);
+av_freep(_params->biases);
+}
+av_freep(>layers[layer].params);
+}
+av_freep(>layers);
 }
-av_freep(>layers[layer].params);
-}
-av_freep(>layers);
 
-for (uint32_t operand = 0; operand < network->operands_num; ++operand)
-av_freep(>operands[operand].data);
-  

Re: [FFmpeg-devel] [PATCH 0/7] adpcm_ima_apm encoder + apm muxer

2020-06-10 Thread Zane van Iperen
On Tue, 09 Jun 2020 00:19:24 +
"Zane van Iperen"  wrote:

> Add support for encoding adpcm_ima_apm and muxing to apm.
> 

Ping. If possible, I would like to get this functionality into the 4.3
release.

Zane

___
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 v11 4/4] avcodec/h264: create user data unregistered SEI side data for H.264

2020-06-10 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/h264_sei.c |  18 -
 libavcodec/h264_sei.h |   2 +
 libavcodec/h264_slice.c   |  14 
 tests/ref/fate/mov-zombie | 195 ++
 4 files changed, 161 insertions(+), 68 deletions(-)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 870dd90..a903706 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -52,6 +52,10 @@ void ff_h264_sei_uninit(H264SEIContext *h)
 h->afd.present =  0;
 
 av_buffer_unref(>a53_caption.buf_ref);
+for (int i = 0; i < h->unregistered.nb_buf_ref; i++)
+av_buffer_unref(>unregistered.buf_ref[i]);
+h->unregistered.nb_buf_ref = 0;
+av_freep(>unregistered.buf_ref);
 }
 
 int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
@@ -260,25 +264,33 @@ static int 
decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext *
 {
 uint8_t *user_data;
 int e, build, i;
+AVBufferRef *buf_ref, **tmp;
 
 if (size < 16 || size >= INT_MAX - 1)
 return AVERROR_INVALIDDATA;
 
-user_data = av_malloc(size + 1);
-if (!user_data)
+tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
+if (!tmp)
 return AVERROR(ENOMEM);
+h->buf_ref = tmp;
+
+buf_ref = av_buffer_alloc(size + 1);
+if (!buf_ref)
+return AVERROR(ENOMEM);
+user_data = buf_ref->data;
 
 for (i = 0; i < size; i++)
 user_data[i] = get_bits(gb, 8);
 
 user_data[i] = 0;
+h->buf_ref[h->nb_buf_ref++] = buf_ref;
+
 e = sscanf(user_data + 16, "x264 - core %d", );
 if (e == 1 && build > 0)
 h->x264_build = build;
 if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core ", 16))
 h->x264_build = 67;
 
-av_free(user_data);
 return 0;
 }
 
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index f07a505..4fdcf4e 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -126,6 +126,8 @@ typedef struct H264SEIA53Caption {
 
 typedef struct H264SEIUnregistered {
 int x264_build;
+AVBufferRef **buf_ref;
+int nb_buf_ref;
 } H264SEIUnregistered;
 
 typedef struct H264SEIRecoveryPoint {
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 7139537..47f3917 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1289,6 +1289,20 @@ static int h264_export_frame_props(H264Context *h)
 h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 
+for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
+H264SEIUnregistered *unreg = >sei.unregistered;
+
+if (unreg->buf_ref[i]) {
+AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f,
+AV_FRAME_DATA_SEI_UNREGISTERED,
+unreg->buf_ref[i]);
+if (!sd)
+av_buffer_unref(>buf_ref[i]);
+unreg->buf_ref[i] = NULL;
+}
+}
+h->sei.unregistered.nb_buf_ref = 0;
+
 if (h->sei.picture_timing.timecode_cnt > 0) {
 uint32_t tc = 0;
 uint32_t *tc_sd;
diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie
index 445f921..1a6625b 100644
--- a/tests/ref/fate/mov-zombie
+++ b/tests/ref/fate/mov-zombie
@@ -1,133 +1,198 @@
 
packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_
 
packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1077|pos=15442|flags=__
-frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.00|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.00|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleft
+frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.00|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.00|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45]
 User Data Unregistered SEI message
+
 

Re: [FFmpeg-devel] [PATCH] codec_desc: mark CFHD as intra-only

2020-06-10 Thread James Almer
On 6/10/2020 6:19 AM, Anton Khirnov wrote:
> Quoting James Almer (2020-06-09 14:45:33)
>> On 6/9/2020 6:06 AM, Anton Khirnov wrote:
>>> I don't think this needs to be visible externally, since it's only
>>> meaningful for internal use. I'm wondering if the presence of
>>> update_thread_context() callback won't be sufficient for this.
>>
>> True, it could be a caps_internal. But take for example the possibility
>> of an external library with a fully featured decoder getting a wrapper,
>> this being a public capability would let the user choose it over the
>> internal one, same as how it can choose a stable decoder over an
>> experimental one, or a software one over an hybrid/hw one.
> 
> I don't see why this should be a criterium for the user to base any
> decisions on. It's purely an internal implementation detail that's tied
> to the way frame threading is currently implemented and can potentially
> change later. So I don't see why it should be accessible through the
> API.

An intra only decoder returns I frames only. A fully feature decoder
would return I and P (and actually get you something other than a key
frame slideshow). Or at least that's how i understood it.
Giving the user a way to choose the best decoder for their needs is not
too crazy. We already do with other implementation specific
capabilities, as i mentioned above.

> 
> Also, not sure if you saw but I have new patch fixing this problem in
> another manner.

Yes, i saw. I'm arguing about this other approach because if it's done
now, it can be done seamlessly (Just revert the change and pretend the
flag was never deprecated). After 4.3 is effectively tagged, we would
require to undo the deprecation with another API change, and it will
look messy.

The flag was meaningless and a duplicate of the codec prop, but now we
found a way to use it to actually convey information about a decoder, so
why not do it?
___
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 v11 3/4] avfilter/vf_showinfo: display H.26[45] user data unregistered sei message

2020-06-10 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_showinfo.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 5d4aee4..2511da5 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -37,6 +37,7 @@
 #include "libavutil/timecode.h"
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/video_enc_params.h"
+#include "libavutil/avstring.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext *ctx, 
AVFrameSideData *sd)
 av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
 }
 
+static int string_is_print(const uint8_t *str)
+{
+while (av_isgraph(*str)) str++;
+return !*str;
+}
+
+static void dump_sei_unregistered_metadata(AVFilterContext *ctx, 
AVFrameSideData *sd)
+{
+const int uuid_size = 16;
+uint8_t *user_data = sd->data;
+
+if (sd->size < uuid_size) {
+av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", 
sd->size, uuid_size);
+return;
+}
+
+av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
+av_log(ctx, AV_LOG_INFO, "UUID=");
+for (int i = 0; i < uuid_size; i++) {
+av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
+if (i == 3 || i == 5 || i == 7 || i == 9)
+av_log(ctx, AV_LOG_INFO, "-");
+}
+av_log(ctx, AV_LOG_INFO, "\n");
+
+user_data += uuid_size;
+/* Only print the user data details if it's string */
+if (string_is_print(user_data)) {
+av_log(ctx, AV_LOG_INFO, "User Data=");
+av_log(ctx, AV_LOG_INFO, "%s", user_data);
+}
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
 const char *color_range_str = av_color_range_name(frame->color_range);
@@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
 dump_video_enc_params(ctx, sd);
 break;
+case AV_FRAME_DATA_SEI_UNREGISTERED:
+dump_sei_unregistered_metadata(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
sd->type, sd->size);
-- 
1.8.3.1

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

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

Re: [FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg: flush and recreate encoder instance if resolution changes

2020-06-10 Thread Nicolas George
Linjie Fu (12020-06-09):
> Signed-off-by: Linjie Fu 
> ---
> Should be squashed with:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1434

Apart from the issue of accessing non-public fields, this needs to be
intensively tested. If it allows to create unplayable files, then it is
not acceptable. It should be tested with codecs that use extradata (x264
for example) and also with rawvideo.

Regards,

-- 
  Nicolas George


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

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

[FFmpeg-devel] [PATCH] avformat/dashenc: Add hls_master_name option

2020-06-10 Thread Przemysław Sobala
---
 doc/muxers.texi   | 4 +++-
 libavformat/dashenc.c | 8 +---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index d6f9de3702..b1389a3227 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -267,8 +267,10 @@ Override User-Agent field in HTTP header. Applicable only 
for HTTP output.
 @item http_persistent @var{http_persistent}
 Use persistent HTTP connections. Applicable only for HTTP output.
 @item hls_playlist @var{hls_playlist}
-Generate HLS playlist files as well. The master playlist is generated with the 
filename master.m3u8.
+Generate HLS playlist files as well. The master playlist is generated with the 
filename @var{hls_master_name}.
 One media playlist file is generated for each stream with filenames 
media_0.m3u8, media_1.m3u8, etc.
+@item hls_master_name @var{file_name}
+HLS master playlist name. Default is "master.m3u8".
 @item streaming @var{streaming}
 Enable (1) or disable (0) chunk streaming mode of output. In chunk streaming
 mode, each frame will be a moof fragment which forms a chunk.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 00a37b175d..3e587acdff 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -171,6 +171,7 @@ typedef struct DASHContext {
 const char *user_agent;
 AVDictionary *http_opts;
 int hls_playlist;
+const char *hls_master_name;
 int http_persistent;
 int master_playlist_created;
 AVIOContext *mpd_out;
@@ -1261,9 +1262,9 @@ static int write_manifest(AVFormatContext *s, int final)
 return 0;
 
 if (*c->dirname)
-snprintf(filename_hls, sizeof(filename_hls), "%smaster.m3u8", 
c->dirname);
+snprintf(filename_hls, sizeof(filename_hls), "%s%s", c->dirname, 
c->hls_master_name);
 else
-snprintf(filename_hls, sizeof(filename_hls), "master.m3u8");
+snprintf(filename_hls, sizeof(filename_hls), "%s", 
c->hls_master_name);
 
 snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
"%s", filename_hls);
 
@@ -2292,7 +2293,7 @@ static int dash_write_trailer(AVFormatContext *s)
 
 if (c->hls_playlist && c->master_playlist_created) {
 char filename[1024];
-snprintf(filename, sizeof(filename), "%smaster.m3u8", c->dirname);
+snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
c->hls_master_name);
 dashenc_delete_file(s, filename);
 }
 }
@@ -2349,6 +2350,7 @@ static const AVOption options[] = {
 { "http_user_agent", "override User-Agent field in HTTP header", 
OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
 { "http_persistent", "Use persistent HTTP connections", 
OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 { "hls_playlist", "Generate HLS playlist files(master.m3u8, 
media_%d.m3u8)", OFFSET(hls_playlist), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E 
},
+{ "hls_master_name", "HLS master playlist name", OFFSET(hls_master_name), 
AV_OPT_TYPE_STRING, {.str = "master.m3u8"}, 0, 0, E },
 { "streaming", "Enable/Disable streaming mode of output. Each frame will 
be moof fragment", OFFSET(streaming), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "timeout", "set timeout for socket I/O operations", OFFSET(timeout), 
AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = E },
 { "index_correction", "Enable/Disable segment index correction logic", 
OFFSET(index_correction), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
-- 
2.25.4

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

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

Re: [FFmpeg-devel] [PATCH 1/2] codec_desc: drop the INTRA_ONLY property from TAK

2020-06-10 Thread Paul B Mahol
On 6/9/20, Anton Khirnov  wrote:
> Quoting Paul B Mahol (2020-06-09 13:34:21)
>> Not correct at all decoder is intra only it just have weird container,
>
> If it's intra only then why does the parser mark only some frames as
> keyframes? And why does it need update_thread_context().
>
>> this also makes it single threaded and much slower.
>
> No it doesn't. It's just as multithreaded as before.
>

If performance does not drop, patch is OK.

> --
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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 v10 4/4] avcodec/h264: create user data unregistered SEI side data for H.264

2020-06-10 Thread lance . lmwang
On Wed, Jun 10, 2020 at 10:57:00AM +0200, Marton Balint wrote:
> 
> 
> On Wed, 10 Jun 2020, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavcodec/h264_sei.c |  30 +--
> > libavcodec/h264_sei.h |   2 +
> > libavcodec/h264_slice.c   |  14 
> > tests/ref/fate/mov-zombie | 195 
> > ++
> > 4 files changed, 171 insertions(+), 70 deletions(-)
> > 
> > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> > index 870dd90..0d96fcb 100644
> > --- a/libavcodec/h264_sei.c
> > +++ b/libavcodec/h264_sei.c
> > @@ -24,6 +24,7 @@
> >  * H.264 / AVC / MPEG-4 part10 SEI decoding.
> >  * @author Michael Niedermayer 
> >  */
> > +#include 
> > 
> > #include "avcodec.h"
> > #include "get_bits.h"
> > @@ -52,6 +53,10 @@ void ff_h264_sei_uninit(H264SEIContext *h)
> > h->afd.present =  0;
> > 
> > av_buffer_unref(>a53_caption.buf_ref);
> > +for (int i = 0; i < h->unregistered.nb_buf_ref; i++)
> > +av_buffer_unref(>unregistered.buf_ref[i]);
> > +h->unregistered.nb_buf_ref = 0;
> > +av_freep(>unregistered.buf_ref);
> > }
> > 
> > int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS 
> > *sps,
> > @@ -255,30 +260,45 @@ static int decode_registered_user_data(H264SEIContext 
> > *h, GetBitContext *gb,
> > return 0;
> > }
> > 
> > +static int string_is_print(const uint8_t *str)
> > +{
> > +while (isprint(*str)) str++;
> > +return !*str;
> > +}
> > +
> > static int decode_unregistered_user_data(H264SEIUnregistered *h, 
> > GetBitContext *gb,
> >  void *logctx, int size)
> > {
> > uint8_t *user_data;
> > int e, build, i;
> > +AVBufferRef *buf_ref, **tmp;
> > 
> > -if (size < 16 || size >= INT_MAX - 1)
> > +if (size < 16)
> > return AVERROR_INVALIDDATA;
> > 
> > -user_data = av_malloc(size + 1);
> > -if (!user_data)
> > +tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, 
> > sizeof(*h->buf_ref));
> > +if (!tmp)
> > return AVERROR(ENOMEM);
> > +h->buf_ref = tmp;
> > +
> > +buf_ref = av_buffer_alloc(size);
> > +if (!buf_ref)
> > +return AVERROR(ENOMEM);
> > +user_data = buf_ref->data;
> > 
> > for (i = 0; i < size; i++)
> > user_data[i] = get_bits(gb, 8);
> > +h->buf_ref[h->nb_buf_ref++] = buf_ref;
> > +
> > +if (!string_is_print(user_data + 16))
> > +return 0;
> 
> This check is overkill, alloc size+1 buffer instead, so you can leave the
> code as is. This way you don't even need ctype here.

OK, will use size+1 although it's have one extra byte if user data is not
string. I haven't got such condition yet.

> 
> Thanks,
> Marton
> 
> > 
> > -user_data[i] = 0;
> > e = sscanf(user_data + 16, "x264 - core %d", );
> > if (e == 1 && build > 0)
> > h->x264_build = build;
> > if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core ", 
> > 16))
> > h->x264_build = 67;
> > 
> > -av_free(user_data);
> > return 0;
> > }
> > 
> > diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> > index f07a505..4fdcf4e 100644
> > --- a/libavcodec/h264_sei.h
> > +++ b/libavcodec/h264_sei.h
> > @@ -126,6 +126,8 @@ typedef struct H264SEIA53Caption {
> > 
> > typedef struct H264SEIUnregistered {
> > int x264_build;
> > +AVBufferRef **buf_ref;
> > +int nb_buf_ref;
> > } H264SEIUnregistered;
> > 
> > typedef struct H264SEIRecoveryPoint {
> > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> > index 7139537..47f3917 100644
> > --- a/libavcodec/h264_slice.c
> > +++ b/libavcodec/h264_slice.c
> > @@ -1289,6 +1289,20 @@ static int h264_export_frame_props(H264Context *h)
> > h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> > }
> > 
> > +for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
> > +H264SEIUnregistered *unreg = >sei.unregistered;
> > +
> > +if (unreg->buf_ref[i]) {
> > +AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f,
> > +AV_FRAME_DATA_SEI_UNREGISTERED,
> > +unreg->buf_ref[i]);
> > +if (!sd)
> > +av_buffer_unref(>buf_ref[i]);
> > +unreg->buf_ref[i] = NULL;
> > +}
> > +}
> > +h->sei.unregistered.nb_buf_ref = 0;
> > +
> > if (h->sei.picture_timing.timecode_cnt > 0) {
> > uint32_t tc = 0;
> > uint32_t *tc_sd;
> > diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie
> > index 445f921..1a6625b 100644
> > --- a/tests/ref/fate/mov-zombie
> > +++ b/tests/ref/fate/mov-zombie
> > @@ -1,133 +1,198 @@
> > packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_
> > 

Re: [FFmpeg-devel] [PATCH v10 3/4] avcodec/hevc_sei: add support for user data unregistered SEI message

2020-06-10 Thread lance . lmwang
On Wed, Jun 10, 2020 at 10:49:33AM +0200, Marton Balint wrote:
> 
> 
> On Wed, 10 Jun 2020, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavfilter/vf_showinfo.c | 37 +
> 
> Commit subject is wrong.

will fix it

> 
> > 1 file changed, 37 insertions(+)
> > 
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index 5d4aee4..9eaf8ff 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -23,6 +23,7 @@
> >  */
> > 
> > #include 
> > +#include 
> 
> Use av_isgraph() instead, ctype is locale dependant.

OK, will use it.

> 
> Regards,
> Marton
> 
> > 
> > #include "libavutil/bswap.h"
> > #include "libavutil/adler32.h"
> > @@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext 
> > *ctx, AVFrameSideData *sd)
> > av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
> > }
> > 
> > +static int string_is_print(const uint8_t *str)
> > +{
> > +while (isprint(*str)) str++;
> > +return !*str;
> > +}
> > +
> > +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, 
> > AVFrameSideData *sd)
> > +{
> > +const int uuid_size = 16;
> > +uint8_t *user_data = sd->data;
> > +
> > +if (sd->size < uuid_size) {
> > +av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", 
> > sd->size, uuid_size);
> > +return;
> > +}
> > +
> > +av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
> > +av_log(ctx, AV_LOG_INFO, "UUID=");
> > +for (int i = 0; i < uuid_size; i++) {
> > +av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
> > +if (i == 3 || i == 5 || i == 7 || i == 9)
> > +av_log(ctx, AV_LOG_INFO, "-");
> > +}
> > +av_log(ctx, AV_LOG_INFO, "\n");
> > +
> > +user_data += uuid_size;
> > +/* Only print the user data details if it's string */
> > +if (string_is_print(user_data)) {
> > +av_log(ctx, AV_LOG_INFO, "User Data=");
> > +av_log(ctx, AV_LOG_INFO, "%s", user_data);
> > +}
> > +}
> > +
> > static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> > {
> > const char *color_range_str = 
> > av_color_range_name(frame->color_range);
> > @@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> > *frame)
> > case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
> > dump_video_enc_params(ctx, sd);
> > break;
> > +case AV_FRAME_DATA_SEI_UNREGISTERED:
> > +dump_sei_unregistered_metadata(ctx, sd);
> > +break;
> > default:
> > av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d 
> > bytes)",
> >sd->type, sd->size);
> > -- 
> > 1.8.3.1
> > 
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] codec_desc: mark CFHD as intra-only

2020-06-10 Thread Anton Khirnov
Quoting James Almer (2020-06-09 14:45:33)
> On 6/9/2020 6:06 AM, Anton Khirnov wrote:
> > I don't think this needs to be visible externally, since it's only
> > meaningful for internal use. I'm wondering if the presence of
> > update_thread_context() callback won't be sufficient for this.
> 
> True, it could be a caps_internal. But take for example the possibility
> of an external library with a fully featured decoder getting a wrapper,
> this being a public capability would let the user choose it over the
> internal one, same as how it can choose a stable decoder over an
> experimental one, or a software one over an hybrid/hw one.

I don't see why this should be a criterium for the user to base any
decisions on. It's purely an internal implementation detail that's tied
to the way frame threading is currently implemented and can potentially
change later. So I don't see why it should be accessible through the
API.

Also, not sure if you saw but I have new patch fixing this problem in
another manner.

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

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

Re: [FFmpeg-devel] [PATCH v10 4/4] avcodec/h264: create user data unregistered SEI side data for H.264

2020-06-10 Thread Marton Balint



On Wed, 10 Jun 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavcodec/h264_sei.c |  30 +--
libavcodec/h264_sei.h |   2 +
libavcodec/h264_slice.c   |  14 
tests/ref/fate/mov-zombie | 195 ++
4 files changed, 171 insertions(+), 70 deletions(-)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 870dd90..0d96fcb 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -24,6 +24,7 @@
 * H.264 / AVC / MPEG-4 part10 SEI decoding.
 * @author Michael Niedermayer 
 */
+#include 

#include "avcodec.h"
#include "get_bits.h"
@@ -52,6 +53,10 @@ void ff_h264_sei_uninit(H264SEIContext *h)
h->afd.present =  0;

av_buffer_unref(>a53_caption.buf_ref);
+for (int i = 0; i < h->unregistered.nb_buf_ref; i++)
+av_buffer_unref(>unregistered.buf_ref[i]);
+h->unregistered.nb_buf_ref = 0;
+av_freep(>unregistered.buf_ref);
}

int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
@@ -255,30 +260,45 @@ static int decode_registered_user_data(H264SEIContext *h, 
GetBitContext *gb,
return 0;
}

+static int string_is_print(const uint8_t *str)
+{
+while (isprint(*str)) str++;
+return !*str;
+}
+
static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext 
*gb,
 void *logctx, int size)
{
uint8_t *user_data;
int e, build, i;
+AVBufferRef *buf_ref, **tmp;

-if (size < 16 || size >= INT_MAX - 1)
+if (size < 16)
return AVERROR_INVALIDDATA;

-user_data = av_malloc(size + 1);
-if (!user_data)
+tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
+if (!tmp)
return AVERROR(ENOMEM);
+h->buf_ref = tmp;
+
+buf_ref = av_buffer_alloc(size);
+if (!buf_ref)
+return AVERROR(ENOMEM);
+user_data = buf_ref->data;

for (i = 0; i < size; i++)
user_data[i] = get_bits(gb, 8);
+h->buf_ref[h->nb_buf_ref++] = buf_ref;
+
+if (!string_is_print(user_data + 16))
+return 0;


This check is overkill, alloc size+1 buffer instead, so you can leave the 
code as is. This way you don't even need ctype here.


Thanks,
Marton



-user_data[i] = 0;
e = sscanf(user_data + 16, "x264 - core %d", );
if (e == 1 && build > 0)
h->x264_build = build;
if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core ", 16))
h->x264_build = 67;

-av_free(user_data);
return 0;
}

diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index f07a505..4fdcf4e 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -126,6 +126,8 @@ typedef struct H264SEIA53Caption {

typedef struct H264SEIUnregistered {
int x264_build;
+AVBufferRef **buf_ref;
+int nb_buf_ref;
} H264SEIUnregistered;

typedef struct H264SEIRecoveryPoint {
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 7139537..47f3917 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1289,6 +1289,20 @@ static int h264_export_frame_props(H264Context *h)
h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
}

+for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
+H264SEIUnregistered *unreg = >sei.unregistered;
+
+if (unreg->buf_ref[i]) {
+AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f,
+AV_FRAME_DATA_SEI_UNREGISTERED,
+unreg->buf_ref[i]);
+if (!sd)
+av_buffer_unref(>buf_ref[i]);
+unreg->buf_ref[i] = NULL;
+}
+}
+h->sei.unregistered.nb_buf_ref = 0;
+
if (h->sei.picture_timing.timecode_cnt > 0) {
uint32_t tc = 0;
uint32_t *tc_sd;
diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie
index 445f921..1a6625b 100644
--- a/tests/ref/fate/mov-zombie
+++ b/tests/ref/fate/mov-zombie
@@ -1,133 +1,198 @@
packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_
packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1077|pos=15442|flags=__
-frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.00|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.00|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleft

Re: [FFmpeg-devel] [PATCH] added sei side data

2020-06-10 Thread Kieran Kunhya
On Tue, 9 Jun 2020 at 22:26, Daniel Loman  wrote:

> KK>>Are you aware that this is not going to be frame accurate for the
> non-SPS
> KK>>frame because of reordering?
>
> reordering of the frame in terms of pts versus dts?
>
> these are attached to the AVPackets not AVFrame. They data should
> correspond with the pts of the packet. unless i am confused with what youre
> saying
>

 Ok. as long as you are aware PTS may not be in order.

Kieran
___
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 v10 3/4] avcodec/hevc_sei: add support for user data unregistered SEI message

2020-06-10 Thread Marton Balint



On Wed, 10 Jun 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavfilter/vf_showinfo.c | 37 +


Commit subject is wrong.


1 file changed, 37 insertions(+)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 5d4aee4..9eaf8ff 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -23,6 +23,7 @@
 */

#include 
+#include 


Use av_isgraph() instead, ctype is locale dependant.

Regards,
Marton



#include "libavutil/bswap.h"
#include "libavutil/adler32.h"
@@ -190,6 +191,39 @@ static void dump_video_enc_params(AVFilterContext *ctx, 
AVFrameSideData *sd)
av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
}

+static int string_is_print(const uint8_t *str)
+{
+while (isprint(*str)) str++;
+return !*str;
+}
+
+static void dump_sei_unregistered_metadata(AVFilterContext *ctx, 
AVFrameSideData *sd)
+{
+const int uuid_size = 16;
+uint8_t *user_data = sd->data;
+
+if (sd->size < uuid_size) {
+av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", 
sd->size, uuid_size);
+return;
+}
+
+av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
+av_log(ctx, AV_LOG_INFO, "UUID=");
+for (int i = 0; i < uuid_size; i++) {
+av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
+if (i == 3 || i == 5 || i == 7 || i == 9)
+av_log(ctx, AV_LOG_INFO, "-");
+}
+av_log(ctx, AV_LOG_INFO, "\n");
+
+user_data += uuid_size;
+/* Only print the user data details if it's string */
+if (string_is_print(user_data)) {
+av_log(ctx, AV_LOG_INFO, "User Data=");
+av_log(ctx, AV_LOG_INFO, "%s", user_data);
+}
+}
+
static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
{
const char *color_range_str = av_color_range_name(frame->color_range);
@@ -375,6 +409,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
dump_video_enc_params(ctx, sd);
break;
+case AV_FRAME_DATA_SEI_UNREGISTERED:
+dump_sei_unregistered_metadata(ctx, sd);
+break;
default:
av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
   sd->type, sd->size);
--
1.8.3.1

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

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

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

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

Re: [FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg: flush and recreate encoder instance if resolution changes

2020-06-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-06-09 10:48:46)
> Signed-off-by: Linjie Fu 
> ---
> Should be squashed with:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1434
> 
>  fftools/ffmpeg.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 5859781..8cdd532 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -130,6 +130,7 @@ static void do_video_stats(OutputStream *ost, int 
> frame_size);
>  static BenchmarkTimeStamps get_benchmark_time_stamps(void);
>  static int64_t getmaxrss(void);
>  static int ifilter_has_all_input_formats(FilterGraph *fg);
> +static void flush_encoders(void);
>  
>  static int run_as_daemon  = 0;
>  static int nb_frames_dup = 0;
> @@ -1058,11 +1059,21 @@ static void do_video_out(OutputFile *of,
>  
>  if (next_picture && (enc->width != next_picture->width ||
>   enc->height != next_picture->height)) {
> +flush_encoders();
> +avcodec_flush_buffers(enc);
>  if (!(enc->codec->capabilities & AV_CODEC_CAP_VARIABLE_DIMENSIONS)) {
>  av_log(NULL, AV_LOG_ERROR, "Variable dimension encoding "
>  "is not supported by %s.\n", enc->codec->name);
>  goto error;
>  }
> +
> +enc->width  = next_picture->width;
> +enc->height = next_picture->height;
> +
> +if (enc->codec->close(enc) < 0)
> +goto error;
> +if (enc->codec->init(enc) < 0)
> +goto error;

Absolutely not.
Those are private fields, they must not be accessed by libavcodec
callers.

What I meant was freeing the encoder and creating a completely new
encoder instance.

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/dashenc.c:add support to change mpd update interval

2020-06-10 Thread 黄思远


0001-libavformat-dashenc.c-add-support-to-change-mpd-upda.patch
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] libavformat/dashenc.c:add support to change mpd update interval

2020-06-10 Thread Siyuan Huang
I have trouble with mailman email system . 

My company email client can reply email . but looks mailman can not read out
text content . and it will add a warning picture automatically .

And third part email client such as outlook , though it works with text
content without warning pitcture. but It can not reply to specific mail loop
..

 

I'm trying make all works . But if you can give some suggestion for mailman
client . it's much better 

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/dashenc.c:add support to change mpd update interval

2020-06-10 Thread 黄思远


0001-libavformat-dashenc.c-add-support-to-change-mpd-upda.patch
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] Reply-To: RE: [Please Ignore] reply test

2020-06-10 Thread Siyuan Huang
Reply test

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

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

Re: [FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg: flush and recreate encoder instance if resolution changes

2020-06-10 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> James Almer
> Sent: Wednesday, June 10, 2020 12:22
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg: flush and recreate
> encoder instance if resolution changes
> 
> On 6/9/2020 5:48 AM, Linjie Fu wrote:
> > Signed-off-by: Linjie Fu 
> > ---
> > Should be squashed with:
> > https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1434
> >
> >  fftools/ffmpeg.c | 11 +++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > index 5859781..8cdd532 100644
> > --- a/fftools/ffmpeg.c
> > +++ b/fftools/ffmpeg.c
> > @@ -130,6 +130,7 @@ static void do_video_stats(OutputStream *ost, int
> frame_size);
> >  static BenchmarkTimeStamps get_benchmark_time_stamps(void);
> >  static int64_t getmaxrss(void);
> >  static int ifilter_has_all_input_formats(FilterGraph *fg);
> > +static void flush_encoders(void);
> >
> >  static int run_as_daemon  = 0;
> >  static int nb_frames_dup = 0;
> > @@ -1058,11 +1059,21 @@ static void do_video_out(OutputFile *of,
> >
> >  if (next_picture && (enc->width != next_picture->width ||
> >   enc->height != next_picture->height)) {
> > +flush_encoders();
> > +avcodec_flush_buffers(enc);
> 
> This only works for a limited amount of encoders that set the
> AV_CODEC_CAP_ENCODER_FLUSH codec capability, and it's a no-op after
> emitting a warning otherwise.

Yes, hence would like to declare VARIABLE_DIMENSIONS and ENCODER_FLUSH
capability for encoders as well:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/1591692568-19385-1-git-send-email-linjie...@intel.com/

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/dashenc.c:add support to change mpd update interval

2020-06-10 Thread Siyuan Huang
Hello Mr. Moritz

 

I update docs . and here is the latest patch .

 

 

Ps: when I test doc file , muxers.texi

It show some warning by 

root@saber:/ffmpeg# makeinfo --html --no-split -o muext.html doc/muxers.texi

doc/muxers.texi:1948: @ref reference to nonexistent node `concat'

doc/muxers.texi:2357: @ref reference to nonexistent node `Format

stream specifiers

 

look the doc have some issue before add my patch, please info related guys
update  it .

 

B.R

Huang Siyuan

 



0001-libavformat-dashenc.c-add-support-to-change-mpd-upda.patch
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] OS/2:Support linking against libcx

2020-06-10 Thread Dave Yeo
Hi, could I get this pushed to trunk and the 4.3 branch? Fixes a build 
break in libavformat/ip.c (implicit declaration of function 
'getaddrinfo') and also need the prototype.

Thanks,
Dave
From f9fbdaaf6cdb6f886cbdf31c1983e452567cd857 Mon Sep 17 00:00:00 2001
From: Dave Yeo 
Date: Tue, 9 Jun 2020 22:51:53 -0700
Subject: [PATCH] OS/2:Support linking against libcx

Libcx contains extensions to libc such as getaddrinfo(), mmap() and poll(). While recommended to link against, it is optional

Signed-off-by: Dave Yeo 
---
 configure| 1 +
 libavformat/os_support.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/configure b/configure
index 8569a60bf8..24ad990b52 100755
--- a/configure
+++ b/configure
@@ -5997,6 +5997,7 @@ if ! disabled network; then
 check_func inet_aton $network_extralibs
 
 check_type netdb.h "struct addrinfo"
+check_type libcx/net.h "struct addrinfo"
 check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
 check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
 check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 5e6b32d2dc..1904fc8d5d 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -56,6 +56,9 @@
 #  define fstat(f,s) _fstati64((f), (s))
 #endif /* defined(_WIN32) */
 
+#if defined (__OS2__) && defined (HAVE_GETADDRINFO)
+#include 
+#endif
 
 #ifdef __ANDROID__
 #  if HAVE_UNISTD_H
-- 
2.11.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] libavformat/dashenc.c:add support to change mpd update interval

2020-06-10 Thread Siyuan Huang
Hello Mr. Moritz

 

I update docs . and here is the latest patch .

 

 

Ps: when I test doc file , muxers.texi

It show some warning by 

root@saber:/ffmpeg# makeinfo --html --no-split -o muext.html doc/muxers.texi

doc/muxers.texi:1948: @ref reference to nonexistent node `concat'

doc/muxers.texi:2357: @ref reference to nonexistent node `Format

stream specifiers

 

look the doc have some issue before add my patch, please info related guys
update  it .

 

B.R

Huang Siyuan

 



0001-libavformat-dashenc.c-add-support-to-change-mpd-upda.patch
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".