Re: [FFmpeg-devel] [PATCH 1/3] avformat/matroskadec: Sanitize SeekHead entries

2020-05-06 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> A Seek element in a Matroska SeekHead should contain a SeekID and a
> SeekPosition element and upon reading, they should be sanitized:
> 
> Given that IDs are restricted to 32 bit, longer SeekIDs should be treated
> as invalid. Instead currently the lower 32 bits have been used.
> 
> For SeekPosition, no checks were performed for the element to be
> present and if present, whether it was excessively large (i.e. the
> absolute file position described by it exceeding INT64_MAX). The
> SeekPosition element had a default value of -1 which means that a check
> seems to have been intended; but it was not implemented. This commit adds
> a check for overflow to the calculation of the absolute file position of
> the referenced level 1 elements.
> Using -1 (i.e. UINT64_MAX) as default value for SeekPosition implies that
> a Seek element without SeekPosition will run afoul of this check.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/matroskadec.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 8e1326abf6..dea8f14f9e 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1865,8 +1865,12 @@ static void 
> matroska_execute_seekhead(MatroskaDemuxContext *matroska)
>  MatroskaSeekhead *seekheads = seekhead_list->elem;
>  uint32_t id = seekheads[i].id;
>  int64_t pos = seekheads[i].pos + matroska->segment_start;
> +MatroskaLevel1Element *elem;
>  
> -MatroskaLevel1Element *elem = matroska_find_level1_elem(matroska, 
> id);
> +if (id != seekheads[i].id || pos < matroska->segment_start)
> +continue;
> +
> +elem = matroska_find_level1_elem(matroska, id);
>  if (!elem || elem->parsed)
>  continue;
>  
Will apply this patchset tomorrow if there are no objections.

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

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

Re: [FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m: Adapt to call close() on init fail

2020-05-06 Thread Andriy Gelman
On Tue, 28. Apr 22:54, Andriy Gelman wrote:
> From: Andriy Gelman 
> 
> This fixes several mem leaks when init of encoder/decoder failed.
> 
> Fixes ticket #8285
> 
> Signed-off-by: Andriy Gelman 
> ---
> 
>  Changes in v2:
>   - Use FF_CODEC_CAP_INIT_CLEANUP
> 
>  This patch supersedes:
>  
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200310045541.13048-1-andriy.gel...@gmail.com/
>  
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200310045541.13048-2-andriy.gel...@gmail.com/
> 
>  libavcodec/v4l2_m2m.c |  8 
>  libavcodec/v4l2_m2m_dec.c | 10 ++
>  libavcodec/v4l2_m2m_enc.c |  2 ++
>  3 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
> index e48b3a8ccf..bfea70ff0c 100644
> --- a/libavcodec/v4l2_m2m.c
> +++ b/libavcodec/v4l2_m2m.c
> @@ -338,6 +338,13 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
>  V4L2m2mContext *s = priv->context;
>  int ret;
>  
> +if (!s)
> +return 0;
> +
> +if (av_codec_is_decoder(s->avctx->codec))
> +av_packet_unref(>buf_pkt);
> +
> +if (s->fd >= 0) {
>  ret = ff_v4l2_context_set_status(>output, VIDIOC_STREAMOFF);
>  if (ret)
>  av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", 
> s->output.name);
> @@ -345,6 +352,7 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
>  ret = ff_v4l2_context_set_status(>capture, VIDIOC_STREAMOFF);
>  if (ret)
>  av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", 
> s->capture.name);
> +}
>  
>  ff_v4l2_context_release(>output);
>  
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index 3e17e0fcac..a2ea0ff73a 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -212,9 +212,6 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
>  ret = ff_v4l2_m2m_codec_init(priv);
>  if (ret) {
>  av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");
> -s->self_ref = NULL;
> -av_buffer_unref(>context_ref);
> -
>  return ret;
>  }
>  
> @@ -223,10 +220,7 @@ static av_cold int v4l2_decode_init(AVCodecContext 
> *avctx)
>  
>  static av_cold int v4l2_decode_close(AVCodecContext *avctx)
>  {
> -V4L2m2mPriv *priv = avctx->priv_data;
> -V4L2m2mContext *s = priv->context;
> -av_packet_unref(>buf_pkt);
> -return ff_v4l2_m2m_codec_end(priv);
> +return ff_v4l2_m2m_codec_end(avctx->priv_data);
>  }
>  
>  #define OFFSET(x) offsetof(V4L2m2mPriv, x)
> @@ -261,7 +255,7 @@ static const AVOption options[] = {
>  .close  = v4l2_decode_close, \
>  .bsfs   = bsf_name, \
>  .capabilities   = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | 
> AV_CODEC_CAP_AVOID_PROBING, \
> -.caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS, \
> +.caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS | 
> FF_CODEC_CAP_INIT_CLEANUP, \
>  .wrapper_name   = "v4l2m2m", \
>  }
>  
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index 8454e2326c..97c937fdf9 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include "libavcodec/avcodec.h"
> +#include "libavcodec/internal.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/pixfmt.h"
>  #include "libavutil/opt.h"
> @@ -391,6 +392,7 @@ static const AVOption options[] = {
>  .receive_packet = v4l2_receive_packet, \
>  .close  = v4l2_encode_close, \
>  .capabilities   = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
> +.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP, \
>  .wrapper_name   = "v4l2m2m", \
>  };
>  

ping

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/mpeg12enc: replace return -1 with proper error codes

2020-05-06 Thread lance . lmwang
On Thu, May 07, 2020 at 01:21:44AM +0200, Nicolas George wrote:
> lance.lmw...@gmail.com (12020-05-07):
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/mpeg12enc.c | 10 +-
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
> > index 643ba81..f317c63 100644
> > --- a/libavcodec/mpeg12enc.c
> > +++ b/libavcodec/mpeg12enc.c
> > @@ -142,13 +142,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
> >  MpegEncContext *s = avctx->priv_data;
> >  
> 
> >  if (ff_mpv_encode_init(avctx) < 0)
> 
> > -return -1;
> > +return AVERROR(EINVAL);
> 
> You have an accurate return code available.

Yeah, then I had to change the ff_mpv_encode_init() return with accurate error 
code also.

> 
> >  
> >  if (find_frame_rate_index(s) < 0) {
> >  if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
> >  av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d 
> > fps\n",
> > avctx->time_base.den, avctx->time_base.num);
> > -return -1;
> > +return AVERROR(EINVAL);
> >  } else {
> >  av_log(avctx, AV_LOG_INFO,
> > "MPEG-1/2 does not support %d/%d fps, there may be AV 
> > sync issues\n",
> > @@ -159,7 +159,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
> >  if (avctx->profile == FF_PROFILE_UNKNOWN) {
> >  if (avctx->level != FF_LEVEL_UNKNOWN) {
> >  av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
> > -return -1;
> > +return AVERROR(EINVAL);
> >  }
> >  /* Main or 4:2:2 */
> >  avctx->profile = s->chroma_format == CHROMA_420 ? 
> > FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
> > @@ -175,7 +175,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
> >  if (avctx->profile != FF_PROFILE_MPEG2_HIGH && 
> > s->chroma_format != CHROMA_420) {
> >  av_log(avctx, AV_LOG_ERROR,
> > "Only High(1) and 4:2:2(0) profiles support 4:2:2 
> > color sampling\n");
> > -return -1;
> > +return AVERROR(EINVAL);
> >  }
> >  if (avctx->width <= 720 && avctx->height <= 576)
> >  avctx->level = 8;   /* Main */
> > @@ -205,7 +205,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
> >  if (s->drop_frame_timecode && s->frame_rate_index != 4) {
> >  av_log(avctx, AV_LOG_ERROR,
> > "Drop frame time code only allowed with 1001/3 fps\n");
> > -return -1;
> > +return AVERROR(EINVAL);
> >  }
> >  
> >  #if FF_API_PRIVATE_OPT
> 
> Regards,
> 
> -- 
>   Nicolas George



-- 
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 3/3] avcodec/exr: add option to output pixels in float

2020-05-06 Thread Mark Reid
On Wed, May 6, 2020 at 1:07 PM Anton Khirnov  wrote:

> Quoting mindm...@gmail.com (2020-04-29 05:02:35)
> > From: Mark Reid 
> >
> > ---
> >  libavcodec/exr.c | 103 +++
> >  1 file changed, 86 insertions(+), 17 deletions(-)
> >
> > diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> > @@ -1888,6 +1955,8 @@ static const AVOption options[] = {
> >  AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD },
> >  { "gamma", "Set the float gamma value when decoding", OFFSET(gamma),
> >  AV_OPT_TYPE_FLOAT, { .dbl = 1.0f }, 0.001, FLT_MAX, VD },
> > +{ "float", "Output frame in floating point pixel format, apply_trc
> does not get applied", OFFSET(output_float),
> > +AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD},
>
> Wouldn't it make more sense to export the coded format rather than have
> an option like this?
>
>
I could do that, I just was worried about breaking any user's use case. But
now that I think about it, I don't think it would, and I think that would
be simpler.


> --
> 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 v1] avfilter/src_movie: Fix the loop function of dynamic logo

2020-05-06 Thread lance . lmwang
On Wed, May 06, 2020 at 09:43:32PM +0200, Marton Balint wrote:
> 
> 
> On Tue, 5 May 2020, lance.lmw...@gmail.com wrote:
> 
> > On Mon, May 04, 2020 at 09:34:02PM +0200, Marton Balint wrote:
> > > 
> > > 
> > > On Mon, 4 May 2020, lance.lmw...@gmail.com wrote:
> > > 
> > > > On Sun, May 03, 2020 at 07:10:07PM +0200, Marton Balint wrote:
> > > > > > > > > On Sun, 3 May 2020, lance.lmw...@gmail.com wrote:
> > > > > > > > On Tue, Mar 17, 2020 at 06:55:00PM +0800,
> > > lance.lmw...@gmail.com wrote:
> > > > > > > From: Limin Wang 
> > > > > > > > > The following command will attempt to create the input and
> > > > > overlay test sequence for you.
> > > > > > > ./ffmpeg -f lavfi  -i color=white:duration=100:r=25:size=1280x720 
> > > > > > >  input.mkv
> > > > > > > ./ffmpeg -f lavfi -i "testsrc=duration=5:size=320x240:rate=25" 
> > > > > > > overlay.mkv
> > > > > > > > > Please try with below command and compare the final output.
> > > > > > > ./ffmpeg -y -filter_complex 
> > > > > > > "movie=./input.mkv,setpts=PTS-STARTPTS[main];movie=./overlay.mkv:loop=5,setpts=PTS-STARTPTS[overlay];[main][overlay]overlay=10:10:
> > > > > > >  enable='between(t,0,25)" test.mkv
> > > > > > > > >  Without the patch applied, the overlay will repeat the last
> > > > > frame in overlay.mkv after the first loop.
> > > > > > > Why?
> > > > > I haven't clear about the question yet, if you try to insert a
> > > dynamic logo
> > > > repeatly, without the patch, the dynamic logo will not overlay repeatly.
> > > 
> > > But why is that? You explained what this patch fixes. But you have not
> > > explained why the error is happening and what goes wrong in the current
> > > code. I am asking, because there is some timestamp discontinuity handling 
> > > in
> > > src_movie, shouldn't that handle the timestamp discontinuity caused by
> > > looping?
> > 
> > When the dynamic logo is end for reading, the pts will not accumulate with 
> > the
> > first loop, so it'll failed to overlay.
> 
> That is intentional, that is how the src_movie works. It passes on source
> pts values by default. If you want discontinuty handling to kick in either
> for seeking or looping, you should use the discontinuity option.
> 
> E.g:
> 
> ./ffmpeg -y -filter_complex 
> "movie=./input.mkv[main];movie=./overlay.mkv:loop=5:discontinuity=0.04[overlay];[main][overlay]overlay=10:10:enable='between(t,0,25)"
> test.mkv
> 
> So this patch is wrong I am afraid.

Thanks for the comments, I'm clear for the discontinuity flag now. Please 
ignore 
the patch. 


> 
> Regards,
> Marton
> 
> 
> > 
> > > 
> > > Thanks,
> > > Marton
> > > 
> > >  > >
> > > > > > > Thanks,
> > > > > Marton
> > > > > > > > > > > Signed-off-by: Limin Wang 
> > > > > > > ---
> > > > > > >  libavfilter/src_movie.c | 6 ++
> > > > > > >  1 file changed, 6 insertions(+)
> > > > > > > > > diff --git a/libavfilter/src_movie.c
> > > > > b/libavfilter/src_movie.c
> > > > > > > index 79423a8..2327046 100644
> > > > > > > --- a/libavfilter/src_movie.c
> > > > > > > +++ b/libavfilter/src_movie.c
> > > > > > > @@ -68,6 +68,8 @@ typedef struct MovieContext {
> > > > > > >  int loop_count;
> > > > > > >  int64_t discontinuity_threshold;
> > > > > > >  int64_t ts_offset;
> > > > > > > +int64_t last_pts;
> > > > > > > +int64_t last_loop_pts;
> > > > > > > > >  AVFormatContext *format_ctx;
> > > > > > >  int eof;
> > > > > > > @@ -455,6 +457,7 @@ static int rewind_file(AVFilterContext *ctx)
> > > > > > >  movie->st[i].done = 0;
> > > > > > >  }
> > > > > > >  movie->eof = 0;
> > > > > > > +movie->last_loop_pts = movie->last_pts;
> > > > > > >  return 0;
> > > > > > >  }
> > > > > > > > > @@ -565,6 +568,8 @@ static int
> > > > > movie_push_frame(AVFilterContext *ctx, unsigned out_id)
> > > > > > >  if (frame->pts != AV_NOPTS_VALUE) {
> > > > > > >  if (movie->ts_offset)
> > > > > > >  frame->pts += av_rescale_q_rnd(movie->ts_offset, 
> > > > > > > AV_TIME_BASE_Q, outlink->time_base, AV_ROUND_UP);
> > > > > > > +if (movie->last_loop_pts)
> > > > > > > +frame->pts += movie->last_loop_pts;
> > > > > > >  if (st->discontinuity_threshold) {
> > > > > > >  if (st->last_pts != AV_NOPTS_VALUE) {
> > > > > > >  int64_t diff = frame->pts - st->last_pts;
> > > > > > > @@ -575,6 +580,7 @@ static int movie_push_frame(AVFilterContext 
> > > > > > > *ctx, unsigned out_id)
> > > > > > >  }
> > > > > > >  }
> > > > > > >  }
> > > > > > > +movie->last_pts =
> > > > > > >  st->last_pts = frame->pts;
> > > > > > >  }
> > > > > > >  ff_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", 
> > > > > > > movie->file_name,
> > > > > > > -- > > 2.9.5
> > > > > > > > > ping
> > > > > > > -- > Thanks,
> > > > > > Limin Wang
> > > > > > ___
> > > > > > ffmpeg-devel mailing list
> > > > > > ffmpeg-devel@ffmpeg.org
> > 

Re: [FFmpeg-devel] [PATCH] avcodec/mpeg12enc: replace return -1 with proper error codes

2020-05-06 Thread Nicolas George
lance.lmw...@gmail.com (12020-05-07):
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/mpeg12enc.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
> index 643ba81..f317c63 100644
> --- a/libavcodec/mpeg12enc.c
> +++ b/libavcodec/mpeg12enc.c
> @@ -142,13 +142,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
>  MpegEncContext *s = avctx->priv_data;
>  

>  if (ff_mpv_encode_init(avctx) < 0)

> -return -1;
> +return AVERROR(EINVAL);

You have an accurate return code available.

>  
>  if (find_frame_rate_index(s) < 0) {
>  if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
>  av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d 
> fps\n",
> avctx->time_base.den, avctx->time_base.num);
> -return -1;
> +return AVERROR(EINVAL);
>  } else {
>  av_log(avctx, AV_LOG_INFO,
> "MPEG-1/2 does not support %d/%d fps, there may be AV 
> sync issues\n",
> @@ -159,7 +159,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
>  if (avctx->profile == FF_PROFILE_UNKNOWN) {
>  if (avctx->level != FF_LEVEL_UNKNOWN) {
>  av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
> -return -1;
> +return AVERROR(EINVAL);
>  }
>  /* Main or 4:2:2 */
>  avctx->profile = s->chroma_format == CHROMA_420 ? 
> FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
> @@ -175,7 +175,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
>  if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format 
> != CHROMA_420) {
>  av_log(avctx, AV_LOG_ERROR,
> "Only High(1) and 4:2:2(0) profiles support 4:2:2 
> color sampling\n");
> -return -1;
> +return AVERROR(EINVAL);
>  }
>  if (avctx->width <= 720 && avctx->height <= 576)
>  avctx->level = 8;   /* Main */
> @@ -205,7 +205,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
>  if (s->drop_frame_timecode && s->frame_rate_index != 4) {
>  av_log(avctx, AV_LOG_ERROR,
> "Drop frame time code only allowed with 1001/3 fps\n");
> -return -1;
> +return AVERROR(EINVAL);
>  }
>  
>  #if FF_API_PRIVATE_OPT

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] avcodec/mpeg12enc: replace return -1 with proper error codes

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

Signed-off-by: Limin Wang 
---
 libavcodec/mpeg12enc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 643ba81..f317c63 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -142,13 +142,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
 MpegEncContext *s = avctx->priv_data;
 
 if (ff_mpv_encode_init(avctx) < 0)
-return -1;
+return AVERROR(EINVAL);
 
 if (find_frame_rate_index(s) < 0) {
 if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
 av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d 
fps\n",
avctx->time_base.den, avctx->time_base.num);
-return -1;
+return AVERROR(EINVAL);
 } else {
 av_log(avctx, AV_LOG_INFO,
"MPEG-1/2 does not support %d/%d fps, there may be AV sync 
issues\n",
@@ -159,7 +159,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 if (avctx->profile == FF_PROFILE_UNKNOWN) {
 if (avctx->level != FF_LEVEL_UNKNOWN) {
 av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
-return -1;
+return AVERROR(EINVAL);
 }
 /* Main or 4:2:2 */
 avctx->profile = s->chroma_format == CHROMA_420 ? 
FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
@@ -175,7 +175,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
 av_log(avctx, AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color 
sampling\n");
-return -1;
+return AVERROR(EINVAL);
 }
 if (avctx->width <= 720 && avctx->height <= 576)
 avctx->level = 8;   /* Main */
@@ -205,7 +205,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 if (s->drop_frame_timecode && s->frame_rate_index != 4) {
 av_log(avctx, AV_LOG_ERROR,
"Drop frame time code only allowed with 1001/3 fps\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 #if FF_API_PRIVATE_OPT
-- 
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 v4 2/2] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-05-06 Thread lance . lmwang
On Wed, May 06, 2020 at 07:12:23PM +0200, Marton Balint wrote:
> 
> 
> On Wed, 6 May 2020, lance.lmw...@gmail.com wrote:
> 
> > On Wed, May 06, 2020 at 10:11:22AM +0200, Marton Balint wrote:
> > > 
> > > 
> > > On Tue, 21 Apr 2020, lance.lmw...@gmail.com wrote:
> > > 
> > > > From: Limin Wang 
> > > > > The patch will make audio and subtitle packets be marked as
> > > AV_PKT_FLAG_KEY.
> > > 
> > > Why the subtitles? Is it possible that the patch description is outdated? 
> > > I
> > > don't see from the code how would this apply to subtitles, after all
> > > is_intra_only only check for audio and video, no?
> > 
> > No, is_intra_only() check for subtitle also. It'll return 0 for audio and 
> > video
> > and not AV_CODEC_PROP_INTRA_ONLY, other will return 1(is_intra).
> 
> Ah, ok. Is there a practical benefit for setting the keyframe flag for
> subtitles? Or it just happens to work out this way?

yes, hls webvtt subtitle need split by segment by the keyframe flag.

> 
> Either way, fine by me.
> 
> Thanks,
> Marton
> 
> > 
> > 
> > > 
> > > Thanks,
> > > Marton
> > > 
> > > > > For audio, it'll caused the audio sample to be sync sample.
> > > > To verify ref/fate/movenc results:
> > > > 1. Get the movenc test data
> > > > [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_old 
> > > > && mv *.mp4 audio_old_
> > > > > After applied the patch:
> > > > [lmwang@vpn ffmpeg]$ make fate-movenc SAMPLES=../fate-suite
> > > > [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_key 
> > > > && mv *.mp4 audio_key
> > > > > 2. Get l-smash and build boxdumper
> > > > https://github.com/l-smash/l-smash.git
> > > > > 3. dump the box of crc change mp4 and diff -u
> > > > [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
> > > > audio_key/non-empty-moov-no-elst.mp4  > 
> > > > audio_key/non-empty-moov-no-elst.log
> > > > [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
> > > > audio_old/non-empty-moov-no-elst.mp4  > 
> > > > audio_old/non-empty-moov-no-elst.log
> > > > [lmwang@vpn ffmpeg]$ diff -u audio_key/non-empty-moov-no-elst.log 
> > > > audio_old/non-empty-moov-no-elst.log
> > > > -default_sample_flags = 0x0200
> > > > -independent
> > > > -sync sample
> > > > +default_sample_flags = 0x0101
> > > > +dependent
> > > > +non-sync sample
> > > > > 4. have checked the change of crc are caused by
> > > default_sample_flags
> > > > non-empty-moov.mp4, non-empty-moov-elst.mp4,
> > > > non-empty-moov-no-elst.mp4, empty-moov.mp4, delay-moov-content.mp4,
> > > > empty-moov-second-frag.mp4, empty-moov-second-frag-discont.mp4,
> > > > delay-moov-second-frag-discont.mp4, delay-moov-elst-second-frag.mp4
> > > > etc
> > > > > 5 For subtitle, it'll effect for
> > > tests/ref/fate/binsub-movtextenc and
> > > > tests/ref/fate/sub2video, that's expecting result for the subtitle is
> > > > marked as keyframe. Below is the checking result of binsub-movtextenc:
> > > > > [lmwang@vpn ffmpeg]$ ./ffmpeg -i
> > > ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec
> > > mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags
> > > frag_keyframe+empty_moov audio_key/binsub-movtextenc.mp4
> > > > [lmwang@vpn ffmpeg]$ ./ffmpeg -i 
> > > > ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text 
> > > > -f mp4 -flags +bitexact -fflags +bitexact -movflags 
> > > > frag_keyframe+empty_moov audio_old/binsub-movtextenc.mp4
> > > > [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper 
> > > > audio_key/binsub-movtextenc.mp4  > audio_key/binsub-movtextenc.log
> > > > [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper 
> > > > audio_old/binsub-movtextenc.mp4  > audio_old/binsub-movtextenc.log
> > > > [lmwang@vpn ffmpeg]$ diff -u audio_key/binsub-movtextenc.log 
> > > > audio_old/binsub-movtextenc.log
> > > >  // the key difference is the flag for sync sample
> > > > -flags = 0x000701
> > > > +flags = 0x000301
> > > > data-offset-present
> > > > sample-duration-present
> > > > sample-size-present
> > > > -sample-flags-present
> > > > sample_count = 6
> > > > -data_offset = 188
> > > > +data_offset = 164
> > > > sample[0]
> > > > sample_duration = 157
> > > > sample_size = 21
> > > > -sample_flags = 0x0200
> > > > -independent
> > > > -sync sample
> > > > -degradation_priority = 0
> > > > sample[1]
> > > > sample_duration = 51
> > > > sample_size = 2
> > > > -sample_flags = 0x0101
> > > > -dependent
> > > > -non-sync sample
> > > > - 

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/exr: add option to output pixels in float

2020-05-06 Thread Anton Khirnov
Quoting mindm...@gmail.com (2020-04-29 05:02:35)
> From: Mark Reid 
> 
> ---
>  libavcodec/exr.c | 103 +++
>  1 file changed, 86 insertions(+), 17 deletions(-)
> 
> diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> @@ -1888,6 +1955,8 @@ static const AVOption options[] = {
>  AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD },
>  { "gamma", "Set the float gamma value when decoding", OFFSET(gamma),
>  AV_OPT_TYPE_FLOAT, { .dbl = 1.0f }, 0.001, FLT_MAX, VD },
> +{ "float", "Output frame in floating point pixel format, apply_trc does 
> not get applied", OFFSET(output_float),
> +AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD},

Wouldn't it make more sense to export the coded format rather than have
an option like this?

-- 
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 v1] avfilter/src_movie: Fix the loop function of dynamic logo

2020-05-06 Thread Marton Balint



On Tue, 5 May 2020, lance.lmw...@gmail.com wrote:


On Mon, May 04, 2020 at 09:34:02PM +0200, Marton Balint wrote:



On Mon, 4 May 2020, lance.lmw...@gmail.com wrote:

> On Sun, May 03, 2020 at 07:10:07PM +0200, Marton Balint wrote:
> > 
> > 
> > On Sun, 3 May 2020, lance.lmw...@gmail.com wrote:
> > 
> > > On Tue, Mar 17, 2020 at 06:55:00PM +0800, lance.lmw...@gmail.com wrote:

> > > > From: Limin Wang 
> > > > > > The following command will attempt to create the input and
> > overlay test sequence for you.
> > > > ./ffmpeg -f lavfi  -i color=white:duration=100:r=25:size=1280x720  
input.mkv
> > > > ./ffmpeg -f lavfi -i "testsrc=duration=5:size=320x240:rate=25" 
overlay.mkv
> > > > > > Please try with below command and compare the final output.
> > > > ./ffmpeg -y -filter_complex 
"movie=./input.mkv,setpts=PTS-STARTPTS[main];movie=./overlay.mkv:loop=5,setpts=PTS-STARTPTS[overlay];[main][overlay]overlay=10:10:
> > > >  enable='between(t,0,25)" test.mkv
> > > > > >  Without the patch applied, the overlay will repeat the last
> > frame in overlay.mkv after the first loop.
> > 
> > Why?
> 
> I haven't clear about the question yet, if you try to insert a dynamic logo

> repeatly, without the patch, the dynamic logo will not overlay repeatly.

But why is that? You explained what this patch fixes. But you have not
explained why the error is happening and what goes wrong in the current
code. I am asking, because there is some timestamp discontinuity handling in
src_movie, shouldn't that handle the timestamp discontinuity caused by
looping?


When the dynamic logo is end for reading, the pts will not accumulate with the
first loop, so it'll failed to overlay.


That is intentional, that is how the src_movie works. It passes on source 
pts values by default. If you want discontinuty handling to kick in either 
for seeking or looping, you should use the discontinuity option.


E.g:

./ffmpeg -y -filter_complex 
"movie=./input.mkv[main];movie=./overlay.mkv:loop=5:discontinuity=0.04[overlay];[main][overlay]overlay=10:10:enable='between(t,0,25)" 
test.mkv


So this patch is wrong I am afraid.

Regards,
Marton






Thanks,
Marton

 > >
> > 
> > Thanks,

> > Marton
> > 
> > > > > > Signed-off-by: Limin Wang 

> > > > ---
> > > >  libavfilter/src_movie.c | 6 ++
> > > >  1 file changed, 6 insertions(+)
> > > > > > diff --git a/libavfilter/src_movie.c
> > b/libavfilter/src_movie.c
> > > > index 79423a8..2327046 100644
> > > > --- a/libavfilter/src_movie.c
> > > > +++ b/libavfilter/src_movie.c
> > > > @@ -68,6 +68,8 @@ typedef struct MovieContext {
> > > >  int loop_count;
> > > >  int64_t discontinuity_threshold;
> > > >  int64_t ts_offset;
> > > > +int64_t last_pts;
> > > > +int64_t last_loop_pts;
> > > > > >  AVFormatContext *format_ctx;
> > > >  int eof;
> > > > @@ -455,6 +457,7 @@ static int rewind_file(AVFilterContext *ctx)
> > > >  movie->st[i].done = 0;
> > > >  }
> > > >  movie->eof = 0;
> > > > +movie->last_loop_pts = movie->last_pts;
> > > >  return 0;
> > > >  }
> > > > > > @@ -565,6 +568,8 @@ static int
> > movie_push_frame(AVFilterContext *ctx, unsigned out_id)
> > > >  if (frame->pts != AV_NOPTS_VALUE) {
> > > >  if (movie->ts_offset)
> > > >  frame->pts += av_rescale_q_rnd(movie->ts_offset, 
AV_TIME_BASE_Q, outlink->time_base, AV_ROUND_UP);
> > > > +if (movie->last_loop_pts)
> > > > +frame->pts += movie->last_loop_pts;
> > > >  if (st->discontinuity_threshold) {
> > > >  if (st->last_pts != AV_NOPTS_VALUE) {
> > > >  int64_t diff = frame->pts - st->last_pts;
> > > > @@ -575,6 +580,7 @@ static int movie_push_frame(AVFilterContext *ctx, 
unsigned out_id)
> > > >  }
> > > >  }
> > > >  }
> > > > +movie->last_pts =
> > > >  st->last_pts = frame->pts;
> > > >  }
> > > >  ff_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", 
movie->file_name,
> > > > -- > > 2.9.5
> > > > > > ping
> > > > -- > 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 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] Reporting bugs

2020-05-06 Thread Lou Logan
On Tue, May 5, 2020, at 4:07 AM, Nico Coesel wrote:
> Hello all,
> I want to report a bug in the jpeg encoding but I can't seem to register 
> to trac.
> 
> Is there a special trick to it?

Are you having trouble getting past the antispam check?
Or did not not receive the verification email?
___
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, RFC] lavc/options_table: Add basic candidate h264 profiles

2020-05-06 Thread Marton Balint



On Wed, 6 May 2020, Fu, Linjie wrote:


From: ffmpeg-devel  On Behalf Of
lance.lmw...@gmail.com
Sent: Wednesday, May 6, 2020 22:57
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH, RFC] lavc/options_table: Add basic
candidate h264 profiles

On Wed, May 06, 2020 at 06:13:10PM +0800, myp...@gmail.com wrote:

On Wed, May 6, 2020 at 6:04 PM myp...@gmail.com

 wrote:


On Wed, May 6, 2020 at 5:40 PM Martin Storsjö 

wrote:


On Wed, 6 May 2020, Linjie Fu wrote:


Allows specifying avctx->profile with string type profile for
h264 encoders.

Private field/option "profile" may be abled to be removed for basic
h264 profiles, directly for encoders like libopenh264/h264_vaapi,
or with an map to hardware profile like h264_qsv.

Signed-off-by: Linjie Fu 
---
One concern is some encoders have options for specific profiles,
like "high444p" for nvenc_h264 and "constrained_high" for h264_amf,
hence they may not be able to remove the private option easily.

Please help to comment.

libavcodec/options_table.h | 4 
1 file changed, 4 insertions(+)


This change in itself looks sensible to me (but I'd like for someone else
to comment as well). Even if it might not be able to get rid of the
private option for all encoders, it should at least simplify the easiest
cases.

// Martin

I think we have a discussion about this case,
https://patchwork.ffmpeg.org/project/ffmpeg/patch/fa14da65-9e1a-

c74b-b3cb-46fc5f3ea...@gmail.com/


I agree with Hendrik Leppkes, and I think "main" more natural than
"h264_main"  for 264 codec profile from a user viewpoint, both of
command line tools or  application program interface


So what's the conclusion? I have submit a patch to add mpeg2 profile
 52 and Marton prefer to use global profile with mpeg2_. By Hendrik's
comments, I think it's more reasonable to use private profile.


I'd also prefer an option without prefix which seems more natural, especially
for the codecs that already have implemented it as a private option. Otherwise
it seems to be a sudden break for users to use "h264_main"/"mepg2_main"
instead of "main" unless we declared some deprecated flags and get rid of
the private options later.



I was against the private option because there is no clear path in what to 
support in the future.


Storing the profile in two places is problematic becuase priority between 
the two is not consistently enforced. So I guess for some codecs the 
private profile will have priority, for others, the avctx profile.


If libavcodec should store all profiles for a codec, can't we make the 
profile option a string and do the parsing later from code? This way we 
can eliminate the per-codec profile options and use the shorter options at 
the same time them having different meaning according to the used codec.


I can wrap up a patch if this seems like a viable way forward.

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

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

Re: [FFmpeg-devel] [PATCH] MAINTAINERS: Add myself to libopenh264enc

2020-05-06 Thread Michael Niedermayer
On Thu, Apr 30, 2020 at 09:12:44AM +0800, Linjie Fu wrote:
> Reviewed-by: Martin Storsjö 
> Signed-off-by: Linjie Fu 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)

will apply

thx

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

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



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 v4 2/2] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-05-06 Thread Marton Balint



On Wed, 6 May 2020, lance.lmw...@gmail.com wrote:


On Wed, May 06, 2020 at 10:11:22AM +0200, Marton Balint wrote:



On Tue, 21 Apr 2020, lance.lmw...@gmail.com wrote:

> From: Limin Wang 
> 
> The patch will make audio and subtitle packets be marked as AV_PKT_FLAG_KEY.


Why the subtitles? Is it possible that the patch description is outdated? I
don't see from the code how would this apply to subtitles, after all
is_intra_only only check for audio and video, no?


No, is_intra_only() check for subtitle also. It'll return 0 for audio and video
and not AV_CODEC_PROP_INTRA_ONLY, other will return 1(is_intra).


Ah, ok. Is there a practical benefit for setting the keyframe flag for 
subtitles? Or it just happens to work out this way?


Either way, fine by me.

Thanks,
Marton






Thanks,
Marton

> 
> For audio, it'll caused the audio sample to be sync sample.

> To verify ref/fate/movenc results:
> 1. Get the movenc test data
> [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_old && mv 
*.mp4 audio_old_
> 
> After applied the patch:

> [lmwang@vpn ffmpeg]$ make fate-movenc SAMPLES=../fate-suite
> [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_key && mv 
*.mp4 audio_key
> 
> 2. Get l-smash and build boxdumper

> https://github.com/l-smash/l-smash.git
> 
> 3. dump the box of crc change mp4 and diff -u

> [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
audio_key/non-empty-moov-no-elst.mp4  > audio_key/non-empty-moov-no-elst.log
> [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
audio_old/non-empty-moov-no-elst.mp4  > audio_old/non-empty-moov-no-elst.log
> [lmwang@vpn ffmpeg]$ diff -u audio_key/non-empty-moov-no-elst.log 
audio_old/non-empty-moov-no-elst.log
> -default_sample_flags = 0x0200
> -independent
> -sync sample
> +default_sample_flags = 0x0101
> +dependent
> +non-sync sample
> 
> 4. have checked the change of crc are caused by default_sample_flags

> non-empty-moov.mp4, non-empty-moov-elst.mp4,
> non-empty-moov-no-elst.mp4, empty-moov.mp4, delay-moov-content.mp4,
> empty-moov-second-frag.mp4, empty-moov-second-frag-discont.mp4,
> delay-moov-second-frag-discont.mp4, delay-moov-elst-second-frag.mp4
> etc
> 
> 5 For subtitle, it'll effect for tests/ref/fate/binsub-movtextenc and

> tests/ref/fate/sub2video, that's expecting result for the subtitle is
> marked as keyframe. Below is the checking result of binsub-movtextenc:
> 
> [lmwang@vpn ffmpeg]$ ./ffmpeg -i ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov audio_key/binsub-movtextenc.mp4

> [lmwang@vpn ffmpeg]$ ./ffmpeg -i 
../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 
-flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov 
audio_old/binsub-movtextenc.mp4
> [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_key/binsub-movtextenc.mp4  
> audio_key/binsub-movtextenc.log
> [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_old/binsub-movtextenc.mp4  
> audio_old/binsub-movtextenc.log
> [lmwang@vpn ffmpeg]$ diff -u audio_key/binsub-movtextenc.log 
audio_old/binsub-movtextenc.log
>  // the key difference is the flag for sync sample
> -flags = 0x000701
> +flags = 0x000301
> data-offset-present
> sample-duration-present
> sample-size-present
> -sample-flags-present
> sample_count = 6
> -data_offset = 188
> +data_offset = 164
> sample[0]
> sample_duration = 157
> sample_size = 21
> -sample_flags = 0x0200
> -independent
> -sync sample
> -degradation_priority = 0
> sample[1]
> sample_duration = 51
> sample_size = 2
> -sample_flags = 0x0101
> -dependent
> -non-sync sample
> -degradation_priority = 0
> sample[2]
> sample_duration = 169
> sample_size = 9
> -sample_flags = 0x0200
> -independent
> -sync sample
> -degradation_priority = 0
> 
> Signed-off-by: Limin Wang 

> ---
> libavformat/internal.h   |  2 +
> libavformat/mux.c|  7 +++-
> tests/ref/fate/binsub-movtextenc |  2 +-
> tests/ref/fate/movenc| 50 +++
> tests/ref/fate/sub2video | 86 
> 5 files changed, 77 insertions(+), 70 deletions(-)
> 
> diff --git 

Re: [FFmpeg-devel] [PATCH, RFC] lavc/options_table: Add basic candidate h264 profiles

2020-05-06 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> lance.lmw...@gmail.com
> Sent: Wednesday, May 6, 2020 22:57
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH, RFC] lavc/options_table: Add basic
> candidate h264 profiles
> 
> On Wed, May 06, 2020 at 06:13:10PM +0800, myp...@gmail.com wrote:
> > On Wed, May 6, 2020 at 6:04 PM myp...@gmail.com
>  wrote:
> > >
> > > On Wed, May 6, 2020 at 5:40 PM Martin Storsjö 
> wrote:
> > > >
> > > > On Wed, 6 May 2020, Linjie Fu wrote:
> > > >
> > > > > Allows specifying avctx->profile with string type profile for
> > > > > h264 encoders.
> > > > >
> > > > > Private field/option "profile" may be abled to be removed for basic
> > > > > h264 profiles, directly for encoders like libopenh264/h264_vaapi,
> > > > > or with an map to hardware profile like h264_qsv.
> > > > >
> > > > > Signed-off-by: Linjie Fu 
> > > > > ---
> > > > > One concern is some encoders have options for specific profiles,
> > > > > like "high444p" for nvenc_h264 and "constrained_high" for h264_amf,
> > > > > hence they may not be able to remove the private option easily.
> > > > >
> > > > > Please help to comment.
> > > > >
> > > > > libavcodec/options_table.h | 4 
> > > > > 1 file changed, 4 insertions(+)
> > > >
> > > > This change in itself looks sensible to me (but I'd like for someone 
> > > > else
> > > > to comment as well). Even if it might not be able to get rid of the
> > > > private option for all encoders, it should at least simplify the easiest
> > > > cases.
> > > >
> > > > // Martin
> > > I think we have a discussion about this case,
> > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/fa14da65-9e1a-
> c74b-b3cb-46fc5f3ea...@gmail.com/
> >
> > I agree with Hendrik Leppkes, and I think "main" more natural than
> > "h264_main"  for 264 codec profile from a user viewpoint, both of
> > command line tools or  application program interface
> 
> So what's the conclusion? I have submit a patch to add mpeg2 profile
>  52 and Marton prefer to use global profile with mpeg2_. By Hendrik's
> comments, I think it's more reasonable to use private profile.

I'd also prefer an option without prefix which seems more natural, especially
for the codecs that already have implemented it as a private option. Otherwise
it seems to be a sudden break for users to use "h264_main"/"mepg2_main"
instead of "main" unless we declared some deprecated flags and get rid of
the private options later.

Please help to comment.

- 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] libavutil: add clean aperture (CLAP) side data.

2020-05-06 Thread James Almer
On 5/6/2020 12:22 PM, Neil Birkbeck wrote:
> On Tue, May 5, 2020 at 5:11 AM Kieran O Leary 
> wrote:
> 
>> Hi,
>>
>> I broke the threading with my last reply, i apologise. Here goes another
>> attempt:
>>
>> On Tue, Apr 28, 2020 at 6:23 PM Neil Birkbeck 
>> wrote:
>>
>>> On Tue, Apr 28, 2020 at 3:18 AM Nicolas George  wrote:
>>>
 Andreas Rheinhardt (12020-04-28):
> That's expected. The patch provided only provides the structure in
>>> which
> the values are intended to be exported; it does not add any demuxing
>> or
> muxing capabilities for mov or mkv (as you can see from the fact that
> none of these (de)muxers have been changed in the patch).

 Which is something I intended to comment on: adding code without users
 is rarely a good idea. I suggest we do not commit until at least one
 demuxer use it, preferably at least two. Otherwise, we may realize that
 “oh crap, it doesn't work” because of a tiny unforeseen detail.
>>>
>>>
>>> Thanks for the feedback. I also have patches for the demux (MOV/MKV) and
>>> mux (MOV/MKV).
>>>
>>> As there is still the alternative of using the fields in the
>>> AVCodecParameters/AVCodecContext, my intention was to keep the first
>> patch
>>> small to resolve discussion on that point.
>>>
>>> I've included the patches, if you'd like to try test it, Kieren. I see on
>>> your test file that there may be some slight rounding error making output
>>> crop 704 not 703 (MKV file ends up with pixel_crop_{left,right} = 8).
>>>
>>> /ffprobe ../testdata/clap.mov 2>&1 | grep -A1 "Side"
>>> Side data:
>>>   Clean aperture:[width 41472/59 height:576/1 h_offset:0/1
>>> v_offset:0/1]
>>> ./ffmpeg -i ../testdata/clap.mov  -vcodec copy -acodec copy /tmp/clap.mkv
>>> ./ffprobe /tmp/clap.mkv 2>&1 | grep -A1 "Side"
>>> Side data:
>>>   Clean aperture:[width 704/1 height:576/1 h_offset:0/1 v_offset:0/1]
>>>
>>
>> I have to look deeper into the MKV side of things and most likely raise it
>> with the cellar mailing list so that better minds than mine can weigh in. I
>> do see that the rounding up to 704 could be an issue alright.
>> As for MOV, your patch appears to generate the same output clap values as
>> the input, so that's really great! command line and mediainfo trace below:
>>
> 
> Thanks for testing, Kieran and for linking the discussion on the cellar
> list.
> 
> Any additional thoughts from ffmpeg devs on container-level SideData vs
> adding the extra fields into AVCodecParameters/AVCodecContext and plumbing
> into the frame instead? I anticipate some situations where there can be
> interaction between cropping in bitstream and container-level cropping.
> Maybe the best way forward is for me to share some sample patches for the
> alternative to validate whether it supports the various use cases
> (transmux, decode+crop, any other application level handling), and to
> confirm the interface changes for the structs.

One option could be to also introduce a frame side data for this new
struct and have it replace the AVFrame fields, which would then be
deprecated (But of course keep working until removed).
This would allow to either inject stream side data from clap atoms and
Matroska crop fields into packets (Which would then be propagated to
frames to be applied during decoding), or use and export the bitstream
cropping information as it's the case right now, all while preventing
the addition of new fields to AVCodecParameters.

I would like a developer that makes use of this feature to also comment,
especially seeing how the AVFrame fields and this clap side data are
pretty different.
___
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] libavutil: add clean aperture (CLAP) side data.

2020-05-06 Thread Neil Birkbeck
On Tue, May 5, 2020 at 5:11 AM Kieran O Leary 
wrote:

> Hi,
>
> I broke the threading with my last reply, i apologise. Here goes another
> attempt:
>
> On Tue, Apr 28, 2020 at 6:23 PM Neil Birkbeck 
> wrote:
>
> > On Tue, Apr 28, 2020 at 3:18 AM Nicolas George  wrote:
> >
> > > Andreas Rheinhardt (12020-04-28):
> > > > That's expected. The patch provided only provides the structure in
> > which
> > > > the values are intended to be exported; it does not add any demuxing
> or
> > > > muxing capabilities for mov or mkv (as you can see from the fact that
> > > > none of these (de)muxers have been changed in the patch).
> > >
> > > Which is something I intended to comment on: adding code without users
> > > is rarely a good idea. I suggest we do not commit until at least one
> > > demuxer use it, preferably at least two. Otherwise, we may realize that
> > > “oh crap, it doesn't work” because of a tiny unforeseen detail.
> >
> >
> > Thanks for the feedback. I also have patches for the demux (MOV/MKV) and
> > mux (MOV/MKV).
> >
> > As there is still the alternative of using the fields in the
> > AVCodecParameters/AVCodecContext, my intention was to keep the first
> patch
> > small to resolve discussion on that point.
> >
> > I've included the patches, if you'd like to try test it, Kieren. I see on
> > your test file that there may be some slight rounding error making output
> > crop 704 not 703 (MKV file ends up with pixel_crop_{left,right} = 8).
> >
> > /ffprobe ../testdata/clap.mov 2>&1 | grep -A1 "Side"
> > Side data:
> >   Clean aperture:[width 41472/59 height:576/1 h_offset:0/1
> > v_offset:0/1]
> > ./ffmpeg -i ../testdata/clap.mov  -vcodec copy -acodec copy /tmp/clap.mkv
> > ./ffprobe /tmp/clap.mkv 2>&1 | grep -A1 "Side"
> > Side data:
> >   Clean aperture:[width 704/1 height:576/1 h_offset:0/1 v_offset:0/1]
> >
>
> I have to look deeper into the MKV side of things and most likely raise it
> with the cellar mailing list so that better minds than mine can weigh in. I
> do see that the rounding up to 704 could be an issue alright.
> As for MOV, your patch appears to generate the same output clap values as
> the input, so that's really great! command line and mediainfo trace below:
>

Thanks for testing, Kieran and for linking the discussion on the cellar
list.

Any additional thoughts from ffmpeg devs on container-level SideData vs
adding the extra fields into AVCodecParameters/AVCodecContext and plumbing
into the frame instead? I anticipate some situations where there can be
interaction between cropping in bitstream and container-level cropping.
Maybe the best way forward is for me to share some sample patches for the
alternative to validate whether it supports the various use cases
(transmux, decode+crop, any other application level handling), and to
confirm the interface changes for the structs.
___
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 v1 1/2] avformat/ftp: Fix for invalid use of av_strtok

2020-05-06 Thread lance . lmwang
On Sat, Apr 18, 2020 at 12:19:30PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> By the av_strtok() description:
>  * On the first call to av_strtok(), s should point to the string to
>  * parse, and the value of saveptr is ignored. In subsequent calls, s
>  * should be NULL, and saveptr should be unchanged since the previous
>  * call.
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/ftp.c | 14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/ftp.c b/libavformat/ftp.c
> index e3d194d..caeea42 100644
> --- a/libavformat/ftp.c
> +++ b/libavformat/ftp.c
> @@ -333,15 +333,15 @@ static int ftp_passive_mode(FTPContext *s)
>  *end  = '\0';
>  /* skip ip */
>  if (!av_strtok(start, ",", )) goto fail;
> -if (!av_strtok(end, ",", )) goto fail;
> -if (!av_strtok(end, ",", )) goto fail;
> -if (!av_strtok(end, ",", )) goto fail;
> +if (!av_strtok(NULL, ",", )) goto fail;
> +if (!av_strtok(NULL, ",", )) goto fail;
> +if (!av_strtok(NULL, ",", )) goto fail;
>  
>  /* parse port number */
> -start = av_strtok(end, ",", );
> +start = av_strtok(NULL, ",", );
>  if (!start) goto fail;
>  s->server_data_port = atoi(start) * 256;
> -start = av_strtok(end, ",", );
> +start = av_strtok(NULL, ",", );
>  if (!start) goto fail;
>  s->server_data_port += atoi(start);
>  ff_dlog(s, "Server data port: %d\n", s->server_data_port);
> @@ -963,8 +963,10 @@ static int ftp_parse_entry_nlst(char *line, AVIODirEntry 
> *next)
>  static int ftp_parse_entry_mlsd(char *mlsd, AVIODirEntry *next)
>  {
>  char *fact, *value;
> +char *saveptr = NULL, *p = mlsd;
>  ff_dlog(NULL, "%s\n", mlsd);
> -while(fact = av_strtok(mlsd, ";", )) {
> +while(fact = av_strtok(p, ";", )) {
> +p = NULL;
>  if (fact[0] == ' ') {
>  next->name = av_strdup([1]);
>  continue;
> -- 
> 2.9.5
> 

ping the patchset. Please see the discussion of  av_strtok from here:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200417141315.17560-1-lance.lmw...@gmail.com/



-- 
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, RFC] lavc/options_table: Add basic candidate h264 profiles

2020-05-06 Thread lance . lmwang
On Wed, May 06, 2020 at 06:13:10PM +0800, myp...@gmail.com wrote:
> On Wed, May 6, 2020 at 6:04 PM myp...@gmail.com  wrote:
> >
> > On Wed, May 6, 2020 at 5:40 PM Martin Storsjö  wrote:
> > >
> > > On Wed, 6 May 2020, Linjie Fu wrote:
> > >
> > > > Allows specifying avctx->profile with string type profile for
> > > > h264 encoders.
> > > >
> > > > Private field/option "profile" may be abled to be removed for basic
> > > > h264 profiles, directly for encoders like libopenh264/h264_vaapi,
> > > > or with an map to hardware profile like h264_qsv.
> > > >
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > > One concern is some encoders have options for specific profiles,
> > > > like "high444p" for nvenc_h264 and "constrained_high" for h264_amf,
> > > > hence they may not be able to remove the private option easily.
> > > >
> > > > Please help to comment.
> > > >
> > > > libavcodec/options_table.h | 4 
> > > > 1 file changed, 4 insertions(+)
> > >
> > > This change in itself looks sensible to me (but I'd like for someone else
> > > to comment as well). Even if it might not be able to get rid of the
> > > private option for all encoders, it should at least simplify the easiest
> > > cases.
> > >
> > > // Martin
> > I think we have a discussion about this case,
> > https://patchwork.ffmpeg.org/project/ffmpeg/patch/fa14da65-9e1a-c74b-b3cb-46fc5f3ea...@gmail.com/
> 
> I agree with Hendrik Leppkes, and I think "main" more natural than
> "h264_main"  for 264 codec profile from a user viewpoint, both of
> command line tools or  application program interface

So what's the conclusion? I have submit a patch to add mpeg2 profile
 52 and Marton prefer to use global profile with mpeg2_. By Hendrik's
comments, I think it's more reasonable to use private profile.

> ___
> 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 v4 2/2] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-05-06 Thread lance . lmwang
On Wed, May 06, 2020 at 10:11:22AM +0200, Marton Balint wrote:
> 
> 
> On Tue, 21 Apr 2020, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > The patch will make audio and subtitle packets be marked as AV_PKT_FLAG_KEY.
> 
> Why the subtitles? Is it possible that the patch description is outdated? I
> don't see from the code how would this apply to subtitles, after all
> is_intra_only only check for audio and video, no?

No, is_intra_only() check for subtitle also. It'll return 0 for audio and video
and not AV_CODEC_PROP_INTRA_ONLY, other will return 1(is_intra).


> 
> Thanks,
> Marton
> 
> > 
> > For audio, it'll caused the audio sample to be sync sample.
> > To verify ref/fate/movenc results:
> > 1. Get the movenc test data
> > [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_old && 
> > mv *.mp4 audio_old_
> > 
> > After applied the patch:
> > [lmwang@vpn ffmpeg]$ make fate-movenc SAMPLES=../fate-suite
> > [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_key && 
> > mv *.mp4 audio_key
> > 
> > 2. Get l-smash and build boxdumper
> > https://github.com/l-smash/l-smash.git
> > 
> > 3. dump the box of crc change mp4 and diff -u
> > [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
> > audio_key/non-empty-moov-no-elst.mp4  > audio_key/non-empty-moov-no-elst.log
> > [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
> > audio_old/non-empty-moov-no-elst.mp4  > audio_old/non-empty-moov-no-elst.log
> > [lmwang@vpn ffmpeg]$ diff -u audio_key/non-empty-moov-no-elst.log 
> > audio_old/non-empty-moov-no-elst.log
> > -default_sample_flags = 0x0200
> > -independent
> > -sync sample
> > +default_sample_flags = 0x0101
> > +dependent
> > +non-sync sample
> > 
> > 4. have checked the change of crc are caused by default_sample_flags
> > non-empty-moov.mp4, non-empty-moov-elst.mp4,
> > non-empty-moov-no-elst.mp4, empty-moov.mp4, delay-moov-content.mp4,
> > empty-moov-second-frag.mp4, empty-moov-second-frag-discont.mp4,
> > delay-moov-second-frag-discont.mp4, delay-moov-elst-second-frag.mp4
> > etc
> > 
> > 5 For subtitle, it'll effect for tests/ref/fate/binsub-movtextenc and
> > tests/ref/fate/sub2video, that's expecting result for the subtitle is
> > marked as keyframe. Below is the checking result of binsub-movtextenc:
> > 
> > [lmwang@vpn ffmpeg]$ ./ffmpeg -i 
> > ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f 
> > mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov 
> > audio_key/binsub-movtextenc.mp4
> > [lmwang@vpn ffmpeg]$ ./ffmpeg -i 
> > ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f 
> > mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov 
> > audio_old/binsub-movtextenc.mp4
> > [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper 
> > audio_key/binsub-movtextenc.mp4  > audio_key/binsub-movtextenc.log
> > [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper 
> > audio_old/binsub-movtextenc.mp4  > audio_old/binsub-movtextenc.log
> > [lmwang@vpn ffmpeg]$ diff -u audio_key/binsub-movtextenc.log 
> > audio_old/binsub-movtextenc.log
> >  // the key difference is the flag for sync sample
> > -flags = 0x000701
> > +flags = 0x000301
> > data-offset-present
> > sample-duration-present
> > sample-size-present
> > -sample-flags-present
> > sample_count = 6
> > -data_offset = 188
> > +data_offset = 164
> > sample[0]
> > sample_duration = 157
> > sample_size = 21
> > -sample_flags = 0x0200
> > -independent
> > -sync sample
> > -degradation_priority = 0
> > sample[1]
> > sample_duration = 51
> > sample_size = 2
> > -sample_flags = 0x0101
> > -dependent
> > -non-sync sample
> > -degradation_priority = 0
> > sample[2]
> > sample_duration = 169
> > sample_size = 9
> > -sample_flags = 0x0200
> > -independent
> > -sync sample
> > -degradation_priority = 0
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/internal.h   |  2 +
> > libavformat/mux.c|  7 +++-
> > tests/ref/fate/binsub-movtextenc |  2 +-
> > tests/ref/fate/movenc| 50 +++
> > tests/ref/fate/sub2video | 86 
> > 
> > 5 files changed, 77 insertions(+), 70 deletions(-)
> > 
> > diff --git 

Re: [FFmpeg-devel] [PATCH] [libavutil] Add saturated add/sub operations for int64_t.

2020-05-06 Thread Michael Niedermayer
On Mon, May 04, 2020 at 04:06:56PM -0700, Dale Curtis wrote:
> On Mon, May 4, 2020 at 3:39 PM Michael Niedermayer 
> wrote:
> 
> > On Mon, May 04, 2020 at 02:19:47PM -0700, Dale Curtis wrote:
> > > On Mon, May 4, 2020 at 1:48 PM Michael Niedermayer
> > 
> > [...]
> >
> 
> You snipped out the example I provided, 

yes because it was messed up from linebreaks which made both variants
unreadable


> but did you have an opinion on
> which approach looked best there? I think the concept of an "eint" type is
> interesting, but is a project wide change that's a bit beyond what I can
> commit to.

yes, i didnt mean to ask you to implement that
in fact iam happy to implement it, it just seems recently i always have more
things i want to work on than what i actually succeed finding time for
so i ended up throwing the idea onto the mailing list, and if noone does 
implement
it before i find time, then ill probably do it

> 
> > Are you just proposing sentinel values for those extensions? E.g., +inf =
> > > INT64_MAX, -inf=-INT64_MAX, nan=INT64_MIN?
> >
> > yes
> >
> 
> Okay. Having an "eint" type for timestamps seems reasonable. Some sort of
> "AVTimestamp" type perhaps with a new class of arithmetic to handle
> operations to it. This would be similar to how we handle time in Chromium:
> https://source.chromium.org/chromium/chromium/src/+/master:base/time/time.h;l=119

yes

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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 v5 1/3] lavc/libopenh264enc: Rewrite profile handling

2020-05-06 Thread Linjie Fu
Support the profiles "constrained_baseline" and "high" for libopenh264
version >= 1.8, support "constrained_baseline" and "main" for earlier
version.

If option not supported with current version, convert to constrained
baseline with a warning for users.

Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 44 +
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 3bb3cceb64..12c71ca0e9 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -44,7 +44,7 @@ typedef struct SVCContext {
 ISVCEncoder *encoder;
 int slice_mode;
 int loopfilter;
-char *profile;
+int profile;
 int max_nal_size;
 int skip_frames;
 int skipped;
@@ -75,7 +75,12 @@ static const AVOption options[] = {
 #endif
 #endif
 { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, 
{ .i64 = 1 }, 0, 1, VE },
-{ "profile", "set profile restrictions", OFFSET(profile), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
+{ "profile", "set profile restrictions", OFFSET(profile), AV_OPT_TYPE_INT, 
{ .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 0x, VE, "profile" },
+#define PROFILE(name, value)  name, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = value 
}, 0, 0, VE, "profile"
+{ PROFILE("constrained_baseline", 
FF_PROFILE_H264_CONSTRAINED_BASELINE) },
+{ PROFILE("main", FF_PROFILE_H264_MAIN) },
+{ PROFILE("high", FF_PROFILE_H264_HIGH) },
+#undef PROFILE
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
@@ -176,10 +181,41 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.iLoopFilterDisableIdc  = !s->loopfilter;
 param.iEntropyCodingModeFlag = 0;
 param.iMultipleThreadIdc = avctx->thread_count;
-if (s->profile && !strcmp(s->profile, "main"))
+
+if (s->profile == FF_PROFILE_UNKNOWN)
+s->profile = !s->cabac ? FF_PROFILE_H264_CONSTRAINED_BASELINE :
+#if OPENH264_VER_AT_LEAST(1, 8)
+ FF_PROFILE_H264_HIGH;
+#else
+ FF_PROFILE_H264_MAIN;
+#endif
+
+switch (s->profile) {
+#if OPENH264_VER_AT_LEAST(1, 8)
+case FF_PROFILE_H264_HIGH:
 param.iEntropyCodingModeFlag = 1;
-else if (!s->profile && s->cabac)
+av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
+"select EProfileIdc PRO_HIGH in libopenh264.\n");
+break;
+#else
+case FF_PROFILE_H264_MAIN:
 param.iEntropyCodingModeFlag = 1;
+av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
+"select EProfileIdc PRO_MAIN in libopenh264.\n");
+break;
+#endif
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+case FF_PROFILE_UNKNOWN:
+param.iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+default:
+param.iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+}
 
 param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
 param.sSpatialLayers[0].iVideoHeight= param.iPicHeight;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v5 2/3] lavc/libopenh264enc: Allow specifying the profile through AVCodecContext

2020-05-06 Thread Linjie Fu
And determine the profile with following priority:
1. s->profile; then
2. avctx->profile; then
3. s->cabac; then
4. a default profile.

This seems more natural in case user somehow sets both avctx->profile and
s->profile.

Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 12c71ca0e9..4c57fa1c89 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -182,6 +182,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.iEntropyCodingModeFlag = 0;
 param.iMultipleThreadIdc = avctx->thread_count;
 
+/* Allow specifying the libopenh264 profile through AVCodecContext. */
+if (FF_PROFILE_UNKNOWN == s->profile &&
+FF_PROFILE_UNKNOWN != avctx->profile)
+switch (avctx->profile) {
+case FF_PROFILE_H264_HIGH:
+case FF_PROFILE_H264_MAIN:
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+s->profile = avctx->profile;
+break;
+default:
+av_log(avctx, AV_LOG_WARNING,
+   "Unsupported avctx->profile: %d.\n", avctx->profile);
+break;
+}
+
 if (s->profile == FF_PROFILE_UNKNOWN)
 s->profile = !s->cabac ? FF_PROFILE_H264_CONSTRAINED_BASELINE :
 #if OPENH264_VER_AT_LEAST(1, 8)
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v5 3/3] lavc/libopenh264enc: Add coder option to replace cabac

2020-05-06 Thread Linjie Fu
Set DEPRECATED flag to option cabac, replace with coder. The
priority logic is:
1. s->coder; then
2. avctx->coder_type; then
3. s->cabac.

Change the default option to -1 and allow the default cabac to be
determined by profile.

Add FF_API_OPENH264_CABAC macro for cabac to remove this option after
LIBAVCODEC_VERSION_MAJOR = 59.

Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 40 +
 libavcodec/version.h|  3 +++
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 4c57fa1c89..f63aa52348 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -48,7 +48,10 @@ typedef struct SVCContext {
 int max_nal_size;
 int skip_frames;
 int skipped;
-int cabac;
+#if FF_API_OPENH264_CABAC
+int cabac;  // deprecated
+#endif
+int coder;
 
 // rate control mode
 int rc_mode;
@@ -83,7 +86,15 @@ static const AVOption options[] = {
 #undef PROFILE
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
-{ "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
+#if FF_API_OPENH264_CABAC
+{ "cabac", "Enable cabac(deprecated, use coder)", OFFSET(cabac), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE|DEPRECATED },
+#endif
+{ "coder", "Coder type",  OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, 
-1, 1, VE, "coder" },
+{ "default",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 
INT_MIN, INT_MAX, VE, "coder" },
+{ "cavlc",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "cabac",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "vlc",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "ac",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  
INT_MIN, INT_MAX, VE, "coder" },
 
 { "rc_mode", "Select rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, 
{ .i64 = RC_QUALITY_MODE }, RC_OFF_MODE, RC_TIMESTAMP_MODE, VE, "rc_mode" },
 { "off",   "bit rate control off", 
0, AV_OPT_TYPE_CONST, { .i64 = RC_OFF_MODE }, 0, 0, VE, 
"rc_mode" },
@@ -145,13 +156,6 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 
 (*s->encoder)->GetDefaultParams(s->encoder, );
 
-#if FF_API_CODER_TYPE
-FF_DISABLE_DEPRECATION_WARNINGS
-if (!s->cabac)
-s->cabac = avctx->coder_type == FF_CODER_TYPE_AC;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 param.fMaxFrameRate  = 1/av_q2d(avctx->time_base);
 param.iPicWidth  = avctx->width;
 param.iPicHeight = avctx->height;
@@ -197,12 +201,22 @@ FF_ENABLE_DEPRECATION_WARNINGS
 break;
 }
 
-if (s->profile == FF_PROFILE_UNKNOWN)
-s->profile = !s->cabac ? FF_PROFILE_H264_CONSTRAINED_BASELINE :
+#if FF_API_CODER_TYPE && FF_API_OPENH264_CABAC
+FF_DISABLE_DEPRECATION_WARNINGS
+if (s->coder < 0 && avctx->coder_type == FF_CODER_TYPE_AC)
+s->coder = 1;
+
+if (s->coder < 0)
+s->coder = s->cabac;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+if (s->profile == FF_PROFILE_UNKNOWN && s->coder >= 0)
+s->profile = s->coder == 0 ? FF_PROFILE_H264_CONSTRAINED_BASELINE :
 #if OPENH264_VER_AT_LEAST(1, 8)
- FF_PROFILE_H264_HIGH;
+ FF_PROFILE_H264_HIGH;
 #else
- FF_PROFILE_H264_MAIN;
+ FF_PROFILE_H264_MAIN;
 #endif
 
 switch (s->profile) {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 521342..622c85d5ff 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -138,6 +138,9 @@
 #ifndef FF_API_OPENH264_SLICE_MODE
 #define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_OPENH264_CABAC
+#define FF_API_OPENH264_CABAC  (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 
 #endif /* AVCODEC_VERSION_H */
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 0/3] Patch set to delay output live stream

2020-05-06 Thread Nicolas George
Andreas Rheinhardt (12020-05-05):
> (This proposal would increase sizeof(AVOutputFormat) and would therefore
> cause problems when one uses a new libavformat together with an old
> libavdevice (despite no libavdevice muxer using custom interleavement
> functions)

Can I count you among the developers who would be favorable to merging
the shared objects to avoid gratuitous issues of ABI compatibility?

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH, RFC] lavc/options_table: Add basic candidate h264 profiles

2020-05-06 Thread Fu, Linjie
> From: myp...@gmail.com 
> Sent: Wednesday, May 6, 2020 18:13
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Fu, Linjie 
> Subject: Re: [FFmpeg-devel] [PATCH, RFC] lavc/options_table: Add basic
> candidate h264 profiles
> 
> On Wed, May 6, 2020 at 6:04 PM myp...@gmail.com 
> wrote:
> >
> > On Wed, May 6, 2020 at 5:40 PM Martin Storsjö  wrote:
> > >
> > > On Wed, 6 May 2020, Linjie Fu wrote:
> > >
> > > > Allows specifying avctx->profile with string type profile for
> > > > h264 encoders.
> > > >
> > > > Private field/option "profile" may be abled to be removed for basic
> > > > h264 profiles, directly for encoders like libopenh264/h264_vaapi,
> > > > or with an map to hardware profile like h264_qsv.
> > > >
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > > One concern is some encoders have options for specific profiles,
> > > > like "high444p" for nvenc_h264 and "constrained_high" for h264_amf,
> > > > hence they may not be able to remove the private option easily.
> > > >
> > > > Please help to comment.
> > > >
> > > > libavcodec/options_table.h | 4 
> > > > 1 file changed, 4 insertions(+)
> > >
> > > This change in itself looks sensible to me (but I'd like for someone else
> > > to comment as well). Even if it might not be able to get rid of the
> > > private option for all encoders, it should at least simplify the easiest
> > > cases.
> > >
> > > // Martin
> > I think we have a discussion about this case,
> > https://patchwork.ffmpeg.org/project/ffmpeg/patch/fa14da65-9e1a-
> c74b-b3cb-46fc5f3ea...@gmail.com/

Ahh, thanks for this input since it seems to be well-discussed.

> I agree with Hendrik Leppkes, and I think "main" more natural than
> "h264_main"  for 264 codec profile from a user viewpoint, both of
> command line tools or  application program interface

Indeed, being natural makes sense.
(otherwise we would have used numeric values instead)

- 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] avformat/dashdec: compute the segment size use current pos minus offset plus one

2020-05-06 Thread myp...@gmail.com
On Wed, May 6, 2020 at 2:53 PM Steven Liu  wrote:
>
> because the offset should use one byte
>
> Reported-by: Zhao Jun >
> Signed-off-by: Steven Liu 
> ---
>  libavformat/dashdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 5ba7feb245..04a1baea15 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -590,7 +590,7 @@ static struct fragment * get_Fragment(char *range)
>  char *str_end_offset;
>  char *str_offset = av_strtok(range, "-", _end_offset);
>  seg->url_offset = strtoll(str_offset, NULL, 10);
> -seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset;
> +seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset + 1;
>  }
>
>  return seg;
> --
> 2.25.0

LGTM, tested and verified
___
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, RFC] lavc/options_table: Add basic candidate h264 profiles

2020-05-06 Thread myp...@gmail.com
On Wed, May 6, 2020 at 6:04 PM myp...@gmail.com  wrote:
>
> On Wed, May 6, 2020 at 5:40 PM Martin Storsjö  wrote:
> >
> > On Wed, 6 May 2020, Linjie Fu wrote:
> >
> > > Allows specifying avctx->profile with string type profile for
> > > h264 encoders.
> > >
> > > Private field/option "profile" may be abled to be removed for basic
> > > h264 profiles, directly for encoders like libopenh264/h264_vaapi,
> > > or with an map to hardware profile like h264_qsv.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > One concern is some encoders have options for specific profiles,
> > > like "high444p" for nvenc_h264 and "constrained_high" for h264_amf,
> > > hence they may not be able to remove the private option easily.
> > >
> > > Please help to comment.
> > >
> > > libavcodec/options_table.h | 4 
> > > 1 file changed, 4 insertions(+)
> >
> > This change in itself looks sensible to me (but I'd like for someone else
> > to comment as well). Even if it might not be able to get rid of the
> > private option for all encoders, it should at least simplify the easiest
> > cases.
> >
> > // Martin
> I think we have a discussion about this case,
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/fa14da65-9e1a-c74b-b3cb-46fc5f3ea...@gmail.com/

I agree with Hendrik Leppkes, and I think "main" more natural than
"h264_main"  for 264 codec profile from a user viewpoint, both of
command line tools or  application program interface
___
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, RFC] lavc/options_table: Add basic candidate h264 profiles

2020-05-06 Thread myp...@gmail.com
On Wed, May 6, 2020 at 5:40 PM Martin Storsjö  wrote:
>
> On Wed, 6 May 2020, Linjie Fu wrote:
>
> > Allows specifying avctx->profile with string type profile for
> > h264 encoders.
> >
> > Private field/option "profile" may be abled to be removed for basic
> > h264 profiles, directly for encoders like libopenh264/h264_vaapi,
> > or with an map to hardware profile like h264_qsv.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> > One concern is some encoders have options for specific profiles,
> > like "high444p" for nvenc_h264 and "constrained_high" for h264_amf,
> > hence they may not be able to remove the private option easily.
> >
> > Please help to comment.
> >
> > libavcodec/options_table.h | 4 
> > 1 file changed, 4 insertions(+)
>
> This change in itself looks sensible to me (but I'd like for someone else
> to comment as well). Even if it might not be able to get rid of the
> private option for all encoders, it should at least simplify the easiest
> cases.
>
> // Martin
I think we have a discussion about this case,
https://patchwork.ffmpeg.org/project/ffmpeg/patch/fa14da65-9e1a-c74b-b3cb-46fc5f3ea...@gmail.com/
___
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, RFC] lavc/options_table: Add basic candidate h264 profiles

2020-05-06 Thread Martin Storsjö

On Wed, 6 May 2020, Linjie Fu wrote:


Allows specifying avctx->profile with string type profile for
h264 encoders.

Private field/option "profile" may be abled to be removed for basic
h264 profiles, directly for encoders like libopenh264/h264_vaapi,
or with an map to hardware profile like h264_qsv.

Signed-off-by: Linjie Fu 
---
One concern is some encoders have options for specific profiles,
like "high444p" for nvenc_h264 and "constrained_high" for h264_amf,
hence they may not be able to remove the private option easily.

Please help to comment.

libavcodec/options_table.h | 4 
1 file changed, 4 insertions(+)


This change in itself looks sensible to me (but I'd like for someone else 
to comment as well). Even if it might not be able to get rid of the 
private option for all encoders, it should at least simplify the easiest 
cases.


// Martin

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

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

Re: [FFmpeg-devel] [PATCH v3] Add support for playing Audible AAXC (.aaxc) files

2020-05-06 Thread Vesselin Bontchev
08.04.2020, 06:54, "Vesselin Bontchev" :
> The AAXC container format is the same as the (already supported) Audible
> AAX format but it uses a different encryption scheme.
>
> Note: audible_key and audible_iv values are variable (per file) and are
> externally fed.

Can we please merge this patch?

Thanks,
Vesselin
___
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 v4 2/2] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-05-06 Thread Marton Balint



On Tue, 21 Apr 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

The patch will make audio and subtitle packets be marked as AV_PKT_FLAG_KEY.


Why the subtitles? Is it possible that the patch description is outdated? 
I don't see from the code how would this apply to subtitles, after all 
is_intra_only only check for audio and video, no?


Thanks,
Marton



For audio, it'll caused the audio sample to be sync sample.
To verify ref/fate/movenc results:
1. Get the movenc test data
[lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_old && mv 
*.mp4 audio_old_

After applied the patch:
[lmwang@vpn ffmpeg]$ make fate-movenc SAMPLES=../fate-suite
[lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_key && mv 
*.mp4 audio_key

2. Get l-smash and build boxdumper
https://github.com/l-smash/l-smash.git

3. dump the box of crc change mp4 and diff -u
[lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
audio_key/non-empty-moov-no-elst.mp4  > audio_key/non-empty-moov-no-elst.log
[lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box 
audio_old/non-empty-moov-no-elst.mp4  > audio_old/non-empty-moov-no-elst.log
[lmwang@vpn ffmpeg]$ diff -u audio_key/non-empty-moov-no-elst.log 
audio_old/non-empty-moov-no-elst.log
-default_sample_flags = 0x0200
-independent
-sync sample
+default_sample_flags = 0x0101
+dependent
+non-sync sample

4. have checked the change of crc are caused by default_sample_flags
non-empty-moov.mp4, non-empty-moov-elst.mp4,
non-empty-moov-no-elst.mp4, empty-moov.mp4, delay-moov-content.mp4,
empty-moov-second-frag.mp4, empty-moov-second-frag-discont.mp4,
delay-moov-second-frag-discont.mp4, delay-moov-elst-second-frag.mp4
etc

5 For subtitle, it'll effect for tests/ref/fate/binsub-movtextenc and
tests/ref/fate/sub2video, that's expecting result for the subtitle is
marked as keyframe. Below is the checking result of binsub-movtextenc:

[lmwang@vpn ffmpeg]$ ./ffmpeg -i 
../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 
-flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov 
audio_key/binsub-movtextenc.mp4
[lmwang@vpn ffmpeg]$ ./ffmpeg -i 
../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 
-flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov 
audio_old/binsub-movtextenc.mp4
[lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_key/binsub-movtextenc.mp4  > 
audio_key/binsub-movtextenc.log
[lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_old/binsub-movtextenc.mp4  > 
audio_old/binsub-movtextenc.log
[lmwang@vpn ffmpeg]$ diff -u audio_key/binsub-movtextenc.log 
audio_old/binsub-movtextenc.log
 // the key difference is the flag for sync sample
-flags = 0x000701
+flags = 0x000301
data-offset-present
sample-duration-present
sample-size-present
-sample-flags-present
sample_count = 6
-data_offset = 188
+data_offset = 164
sample[0]
sample_duration = 157
sample_size = 21
-sample_flags = 0x0200
-independent
-sync sample
-degradation_priority = 0
sample[1]
sample_duration = 51
sample_size = 2
-sample_flags = 0x0101
-dependent
-non-sync sample
-degradation_priority = 0
sample[2]
sample_duration = 169
sample_size = 9
-sample_flags = 0x0200
-independent
-sync sample
-degradation_priority = 0

Signed-off-by: Limin Wang 
---
libavformat/internal.h   |  2 +
libavformat/mux.c|  7 +++-
tests/ref/fate/binsub-movtextenc |  2 +-
tests/ref/fate/movenc| 50 +++
tests/ref/fate/sub2video | 86 
5 files changed, 77 insertions(+), 70 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 716e42c..c4fac5c 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -189,6 +189,8 @@ struct AVStreamInternal {
 */
int need_context_update;

+int is_intra_only;
+
FFFrac *priv_pts;
};

diff --git a/libavformat/mux.c b/libavformat/mux.c
index a6253f5..ea6524f 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -357,6 +357,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (desc && desc->props & AV_CODEC_PROP_REORDER)
st->internal->reorder = 1;

+st->internal->is_intra_only = ff_is_intra_only(par->codec_id);
+
  

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Improve checks for invalid stream mappings

2020-05-06 Thread Andreas Rheinhardt
Steven Liu:
> 
> 
>> 2020年5月6日 下午12:17,Andreas Rheinhardt  写道:
>>
>> The mapping of streams to the various variant streams to be created by
>> the HLS muxer is roughly as follows: Space and tab separate variant
>> stream group maps while the entries in each variant stream group map are
>> separated by ','.
>>
>> The parsing process of each variant stream group proceeded as follows:
>> At first the number of occurences of "a:", "v:" and "s:" in each variant
>> stream group is calculated so that one can can allocate an array of
>> streams with this number of entries. Then each entry is checked and the
>> check for stream numbers was deficient: It did check that there is a
>> number beginning after the ":", but it did not check that the number
>> extends until the next "," (or until the end).
>>
>> This means that an invalid variant stream group like v:0_v:1 will not be
>> rejected; the problem is that the variant stream in this example is
>> supposed to have two streams associated with it (because it contains two
>> "v:"), yet only one stream is actually associated with it (because there
>> is no ',' to start a second stream specifier). This discrepancy led to
>> segfaults (null pointer dereferencing) in the rest of the code (when the
>> nonexistent second stream associated to the variant stream was inspected).
>>
>> Furthermore, this commit also removes an instance of using atoi() whose
>> behaviour on a range error is undefined.
>>
>> Fixes ticket #8652.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> libavformat/hlsenc.c | 14 +-
>> 1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index b269d015d8..5695c6cc95 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1880,7 +1880,7 @@ fail:
>>
>> static int get_nth_codec_stream_index(AVFormatContext *s,
>>   enum AVMediaType codec_type,
>> -  int stream_id)
>> +  int64_t stream_id)
>> {
>> unsigned int stream_index, cnt;
>> if (stream_id < 0 || stream_id > s->nb_streams - 1)
>> @@ -1963,6 +1963,8 @@ static int 
>> parse_variant_stream_mapstring(AVFormatContext *s)
>>
>> nb_streams = 0;
>> while (keyval = av_strtok(varstr, ",", )) {
>> +int64_t num;
>> +char *end;
>> varstr = NULL;
>> if (av_strstart(keyval, "language:", )) {
>> av_free(vs->language);
>> @@ -2011,10 +2013,12 @@ static int 
>> parse_variant_stream_mapstring(AVFormatContext *s)
>> return AVERROR(EINVAL);
>> }
>>
>> -stream_index = -1;
>> -if (av_isdigit(*val))
>> -stream_index = get_nth_codec_stream_index (s, codec_type,
>> -   atoi(val));
>> +num = strtoll(val, , 0);
>> +if (!av_isdigit(*val) || *end != '\0') {
>> +av_log(s, AV_LOG_ERROR, "Invalid stream number: '%s'\n", 
>> val);
>> +return AVERROR(EINVAL);
>> +}
>> +stream_index = get_nth_codec_stream_index(s, codec_type, num);
>>
>> if (stream_index >= 0 && nb_streams < vs->nb_streams) {
>> for (i = 0; nb_streams > 0 && i < nb_streams; i++) {
>> -- 
>> 2.20.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".
> 
> LGTM
> 
> 
> Thanks
> 
> Steven Liu
> 
> 
> 
Applied. Thanks.

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

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

[FFmpeg-devel] [PATCH] avformat/hlsenc: Don't segfault on uncommon names

2020-05-06 Thread Andreas Rheinhardt
The parsing process of the AVOpt-enabled string controlling the mapping
of input streams to variant streams is roughly as follows: Space and tab
separate variant stream group maps while the entries in each variant
stream group map are separated by ','.

The parsing process of each variant stream group proceeded as follows:
At first the number of occurences of "a:", "v:" and "s:" in each variant
stream group is calculated so that one can can allocate an array of
streams with this number of entries. Then the string is split along ','
and each substring is parsed. If such a substring starts with "a:", "s:"
or "v:" it is treated as stream specifier and (if there is a correct
number after ':') a stream of the variant stream is mapped to one of the
actual input streams.

Nothing actually guarantees that the number of streams allocated initially
equals the number of streams that are mapped to an actual input stream.
These numbers can differ if e.g. the name, the sgroup, agroup or ccgroup
of the variant stream contain "a:", "s:" or "v:".

The problem hereby is that the rest of the code presumes these numbers
to be equal and segfaults if it isn't (because the corresponding input
stream is NULL).

This commit fixes this by modifying the initial counting process to only
count occurences of "a:", "s:" or "v:" that are at the beginning or that
immediately follow a ','.

Signed-off-by: Andreas Rheinhardt 
---
Alternatively, one could error out if these two counts differed (in
which case one can conclude that one of the other values must have
contained "a:", "s:" or "v:"). I have not done so, because using these
doesn't seem to be forbidden at all and there might even be usecases
(think of "name:The_Lord_of_the_Rings:_The_Two_Towers" or "Avengers:").

Furthermore modifying the check has the advantage of not allocating to
much and it also allows to introduce keys that end with 'a', 's' or 'v'.

 libavformat/hlsenc.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 5695c6cc95..a381ca3e9e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1951,10 +1951,13 @@ static int 
parse_variant_stream_mapstring(AVFormatContext *s)
 return AVERROR(EINVAL);
 
 q = varstr;
-while (q < varstr + strlen(varstr)) {
+while (1) {
 if (!av_strncasecmp(q, "a:", 2) || !av_strncasecmp(q, "v:", 2) ||
 !av_strncasecmp(q, "s:", 2))
 vs->nb_streams++;
+q = strchr(q, ',');
+if (!q)
+break;
 q++;
 }
 vs->streams = av_mallocz(sizeof(AVStream *) * vs->nb_streams);
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH] avformat/dashdec: compute the segment size use current pos minus offset plus one

2020-05-06 Thread Steven Liu
because the offset should use one byte

Reported-by: Zhao Jun >
Signed-off-by: Steven Liu 
---
 libavformat/dashdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 5ba7feb245..04a1baea15 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -590,7 +590,7 @@ static struct fragment * get_Fragment(char *range)
 char *str_end_offset;
 char *str_offset = av_strtok(range, "-", _end_offset);
 seg->url_offset = strtoll(str_offset, NULL, 10);
-seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset;
+seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset + 1;
 }
 
 return seg;
-- 
2.25.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".