Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-19 Thread lance . lmwang
On Thu, May 19, 2022 at 11:12:58AM +0200, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2022-05-11 15:30:37)
> > On Wed, May 11, 2022 at 02:00:10PM +0200, Anton Khirnov wrote:
> > > Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> > > > From: Limin Wang 
> > > > 
> > > > some samples include both A53 and SCTE20 data. Before the commit, both
> > > > of the will be exported, so the CC data will be repeated or garbarge
> > > 
> > > Why would it be garbage? That sounds like a bug.
> > > Why can't we just export both?
> > for A53/SCTE20/DVDCC are exprted by A53_CC side data and they're sharing
> > the same a53_buf_ref to store the data, so if stream contains CC wrapped
> > as ATSC A53 packets + the same data wrapped as SCTE-20 packets, the CC
> > data will repeated. We can consider to add a new side data type if 
> > necessary,
> > but it's preferable to export A53_CC even it's SCTE20, so we can't export
> > both by A53_CC still.
> 
> Does this apply to anything other than mpeg2? If not, it should be a
> codec-private option rather than a new global flag.

Yes, it's for mpeg2 only. At first, I think export_side_data option is 
proper place to use. But if export_side_data are considered to use for
global, then I'll consider to add a mpeg2-private option for it.

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

-- 
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 1/2] avfilter/src_movie: add dec_opts for the opened file

2022-05-19 Thread lance . lmwang
On Wed, May 18, 2022 at 10:50:58PM +0800, "zhilizhao(赵志立)" wrote:
> 
> 
> > On May 8, 2022, at 3:17 PM, lance.lmw...@gmail.com wrote:
> > 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > doc/filters.texi| 9 +
> > libavfilter/src_movie.c | 5 -
> > 2 files changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 367614d2f8..6775cf43ba 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -29652,6 +29652,15 @@ shows how to add protocol_whitelist and 
> > protocol_blacklist options:
> > ffplay -f lavfi
> > "movie=filename='1.sdp':format_opts='protocol_whitelist=file,rtp,udp\:protocol_blacklist=http'"
> > @end example
> > +
> > +@item dec_opts
> > +Specify decode options for the opened file. Format options can be specified
> > +as a list of @var{key}=@var{value} pairs separated by ':'. The following 
> > example
> > +shows how to add export_side_data options:
> 
> Looks like ‘Format options’ is copy-paste error from format_opts.

Yes, will fix it, thanks.

> 
> > +@example
> > +./ffmpeg -y  -f lavfi
> > +-i "movie=./input.ts:dec_opts=export_side_data=scte20cc[out0+subcc]" 
> > out.srt
> > +@end example
> > @end table
> > 
> > It allows overlaying a second video on top of the main input of
> > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
> > index 711854c23c..c7dbd90aa9 100644
> > --- a/libavfilter/src_movie.c
> > +++ b/libavfilter/src_movie.c
> > @@ -70,6 +70,7 @@ typedef struct MovieContext {
> > int64_t discontinuity_threshold;
> > int64_t ts_offset;
> > int dec_threads;
> > +AVDictionary *dec_opts;
> > 
> > AVFormatContext *format_ctx;
> > 
> > @@ -96,6 +97,7 @@ static const AVOption movie_options[]= {
> > { "discontinuity", "set discontinuity threshold", 
> > OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 
> > INT64_MAX, FLAGS },
> > { "dec_threads",  "set the number of threads for decoding", 
> > OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 =  0}, 0, INT_MAX, FLAGS },
> > { "format_opts",  "set format options for the opened file", 
> > OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
> > +{ "dec_opts", "set decode options for the opened file", 
> > OFFSET(dec_opts),AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
> > { NULL },
> > };
> > 
> > @@ -158,6 +160,7 @@ static AVStream *find_stream(void *log, AVFormatContext 
> > *avf, const char *spec)
> > 
> > static int open_stream(AVFilterContext *ctx, MovieStream *st, int 
> > dec_threads)
> > {
> > +MovieContext *movie = ctx->priv;
> > const AVCodec *codec;
> > int ret;
> > 
> > @@ -179,7 +182,7 @@ static int open_stream(AVFilterContext *ctx, 
> > MovieStream *st, int dec_threads)
> > dec_threads = ff_filter_get_nb_threads(ctx);
> > st->codec_ctx->thread_count = dec_threads;
> > 
> > -if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
> > +if ((ret = avcodec_open2(st->codec_ctx, codec, >dec_opts)) < 0) 
> > {
> > av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
> > return ret;
> > }
> > -- 
> > 2.35.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".
> 

-- 
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 1/2] avfilter/src_movie: add dec_opts for the opened file

2022-05-18 Thread lance . lmwang
On Sun, May 08, 2022 at 03:17:00PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  doc/filters.texi| 9 +
>  libavfilter/src_movie.c | 5 -
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 367614d2f8..6775cf43ba 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -29652,6 +29652,15 @@ shows how to add protocol_whitelist and 
> protocol_blacklist options:
>  ffplay -f lavfi
>  
> "movie=filename='1.sdp':format_opts='protocol_whitelist=file,rtp,udp\:protocol_blacklist=http'"
>  @end example
> +
> +@item dec_opts
> +Specify decode options for the opened file. Format options can be specified
> +as a list of @var{key}=@var{value} pairs separated by ':'. The following 
> example
> +shows how to add export_side_data options:
> +@example
> +./ffmpeg -y  -f lavfi
> +-i "movie=./input.ts:dec_opts=export_side_data=scte20cc[out0+subcc]" out.srt
> +@end example
>  @end table
>  
>  It allows overlaying a second video on top of the main input of
> diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
> index 711854c23c..c7dbd90aa9 100644
> --- a/libavfilter/src_movie.c
> +++ b/libavfilter/src_movie.c
> @@ -70,6 +70,7 @@ typedef struct MovieContext {
>  int64_t discontinuity_threshold;
>  int64_t ts_offset;
>  int dec_threads;
> +AVDictionary *dec_opts;
>  
>  AVFormatContext *format_ctx;
>  
> @@ -96,6 +97,7 @@ static const AVOption movie_options[]= {
>  { "discontinuity", "set discontinuity threshold", 
> OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 
> INT64_MAX, FLAGS },
>  { "dec_threads",  "set the number of threads for decoding", 
> OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 =  0}, 0, INT_MAX, FLAGS },
>  { "format_opts",  "set format options for the opened file", 
> OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
> +{ "dec_opts", "set decode options for the opened file", 
> OFFSET(dec_opts),AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
>  { NULL },
>  };
>  
> @@ -158,6 +160,7 @@ static AVStream *find_stream(void *log, AVFormatContext 
> *avf, const char *spec)
>  
>  static int open_stream(AVFilterContext *ctx, MovieStream *st, int 
> dec_threads)
>  {
> +MovieContext *movie = ctx->priv;
>  const AVCodec *codec;
>  int ret;
>  
> @@ -179,7 +182,7 @@ static int open_stream(AVFilterContext *ctx, MovieStream 
> *st, int dec_threads)
>  dec_threads = ff_filter_get_nb_threads(ctx);
>  st->codec_ctx->thread_count = dec_threads;
>  
> -if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
> +if ((ret = avcodec_open2(st->codec_ctx, codec, >dec_opts)) < 0) {
>  av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
>  return ret;
>  }
> -- 
> 2.35.1
> 

will apply the patchset tomorrow if no other comments or objection.

-- 
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 4/4] avcodec/dvdsubenc: return error if canvas_size is too small for subtitle render

2022-05-18 Thread lance . lmwang
On Wed, May 11, 2022 at 10:48:18PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/dvdsubenc.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
> index fc3b7d1816..d29db7d49c 100644
> --- a/libavcodec/dvdsubenc.c
> +++ b/libavcodec/dvdsubenc.c
> @@ -376,6 +376,12 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
>  x2 = vrect.x + vrect.w - 1;
>  y2 = vrect.y + vrect.h - 1;
>  
> +if (x2 > avctx->width || y2 > avctx->height) {
> +av_log(avctx, AV_LOG_ERROR, "canvas_size(%d:%d) is too small(%d:%d) 
> for render\n",
> +   avctx->width, avctx->height, x2, y2);
> +ret = AVERROR(EINVAL);;
> +goto fail;
> +}
>  *q++ = 0x05;
>  // x1 x2 -> 6 nibbles
>  *q++ = vrect.x >> 4;
> -- 
> 2.35.1
> 
will apply the patchset 1,3,4 tomorrow if no other comments.

-- 
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 2/4] avcodec/ccaption_dec: check the length of packet and return used length

2022-05-12 Thread lance . lmwang
On Thu, May 12, 2022 at 06:29:51PM +0200, Andreas Rheinhardt wrote:
> Andreas Rheinhardt:
> > lance.lmw...@gmail.com:
> >> On Thu, May 12, 2022 at 08:25:29AM +0200, Paul B Mahol wrote:
> >>> On Thu, May 12, 2022 at 1:39 AM  wrote:
> >>>
>  On Wed, May 11, 2022 at 09:47:52PM +0200, Paul B Mahol wrote:
> > why?
> 
>  assuming the len is 1, the following code will access the next 3
>  array anymore, I think it's better to check the i with len -2.
> 
>  for (i = 0; i < len; i += 3) {
>  to
>  for (i = 0; i < len - 2; i += 3) {
> 
>  for the return, I think it's correct to return the used length,
>  if it's error, have return already. right?
> >>>
> >>>
> >>> I doubt so.
> >>
> >> maybe I'm misunderstand it, but from the comments, the API claims that:
> >> libavcodec/codec_internal.h
> >> 175  * @return amount of bytes read from the packet on success,
> >> 176  * negative error code on failure
> >> 177  */
> >> 178 int (*decode)(struct AVCodecContext *avctx, struct AVFrame 
> >> *frame,
> >> 179   int *got_frame_ptr, struct AVPacket *avpkt);
> >> 180 /**
> >> 181  * Decode subtitle data to an AVSubtitle.
> >> 182  * cb is in this state if cb_type is 
> >> FF_CODEC_CB_TYPE_DECODE_SUB.
> >> 183  *
> >> 184  * Apart from that this is like the decode callback.
> >> 185  */
> >> 186 int (*decode_sub)(struct AVCodecContext *avctx, struct 
> >> AVSubtitle *sub,
> >> 187   int *got_frame_ptr, const struct AVPacket 
> >> *avpkt);
> >>
> > 
> > This is correct. It is not only the internal API which claims that, but
> > the public API, too. And this just not honoured, in particular not in
> > case of subtitle recoding. See
> > https://github.com/mkver/FFmpeg/commit/ba1564c532654888015d67b70bf73d117c2d9f75
> > 
> 
> It seems like there really are people who call this in a loop until all
> the input is exhausted (as the documentation leads you to believe (The
> internal uses of avcodec_decode_subtitle2 don't do this.)):
> https://github.com/HandBrake/HandBrake/blob/a40fb6bce6755209461166140f131f26a2857eb9/libhb/decavsub.c#L335
> I wonder if they ever got something meaningful the second time they
> called it with the same packet (presuming there was a second time).

At first, I thought it was an unintentional return as all other subtitle decode
return packet size always. If the code don't support for that as claims by 
document,
then I prefer to fix the document. If not, we need to fix the code.


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

-- 
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 2/4] avcodec/ccaption_dec: check the length of packet and return used length

2022-05-12 Thread lance . lmwang
On Thu, May 12, 2022 at 08:25:29AM +0200, Paul B Mahol wrote:
> On Thu, May 12, 2022 at 1:39 AM  wrote:
> 
> > On Wed, May 11, 2022 at 09:47:52PM +0200, Paul B Mahol wrote:
> > > why?
> >
> > assuming the len is 1, the following code will access the next 3
> > array anymore, I think it's better to check the i with len -2.
> >
> > for (i = 0; i < len; i += 3) {
> > to
> > for (i = 0; i < len - 2; i += 3) {
> >
> > for the return, I think it's correct to return the used length,
> > if it's error, have return already. right?
> 
> 
> I doubt so.

maybe I'm misunderstand it, but from the comments, the API claims that:
libavcodec/codec_internal.h
175  * @return amount of bytes read from the packet on success,
176  * negative error code on failure
177  */
178 int (*decode)(struct AVCodecContext *avctx, struct AVFrame *frame,
179   int *got_frame_ptr, struct AVPacket *avpkt);
180 /**
181  * Decode subtitle data to an AVSubtitle.
182  * cb is in this state if cb_type is FF_CODEC_CB_TYPE_DECODE_SUB.
183  *
184  * Apart from that this is like the decode callback.
185  */
186 int (*decode_sub)(struct AVCodecContext *avctx, struct AVSubtitle 
*sub,
187   int *got_frame_ptr, const struct AVPacket *avpkt);

> >
> >
> > --
> > 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] [PATCH 2/4] avcodec/ccaption_dec: check the length of packet and return used length

2022-05-11 Thread lance . lmwang
On Wed, May 11, 2022 at 09:47:52PM +0200, Paul B Mahol wrote:
> why?

assuming the len is 1, the following code will access the next 3
array anymore, I think it's better to check the i with len -2.

for (i = 0; i < len; i += 3) {
to 
for (i = 0; i < len - 2; i += 3) {

for the return, I think it's correct to return the used length,
if it's error, have return already. right? 

-- 
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 4/4] avcodec/dvdsubenc: return error if canvas_size is too small for subtitle render

2022-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/dvdsubenc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
index fc3b7d1816..d29db7d49c 100644
--- a/libavcodec/dvdsubenc.c
+++ b/libavcodec/dvdsubenc.c
@@ -376,6 +376,12 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
 x2 = vrect.x + vrect.w - 1;
 y2 = vrect.y + vrect.h - 1;
 
+if (x2 > avctx->width || y2 > avctx->height) {
+av_log(avctx, AV_LOG_ERROR, "canvas_size(%d:%d) is too small(%d:%d) 
for render\n",
+   avctx->width, avctx->height, x2, y2);
+ret = AVERROR(EINVAL);;
+goto fail;
+}
 *q++ = 0x05;
 // x1 x2 -> 6 nibbles
 *q++ = vrect.x >> 4;
-- 
2.35.1

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

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


[FFmpeg-devel] [PATCH 3/4] avformat/sccenc: avoid potential invalid access

2022-05-11 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavformat/sccenc.c b/libavformat/sccenc.c
index c8c4d097e4..2b924ba6e7 100644
--- a/libavformat/sccenc.c
+++ b/libavformat/sccenc.c
@@ -72,11 +72,11 @@ static int scc_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 s = (int)(pts /  1000) % 60;
 f = (int)(pts %  1000) / 33;
 
-for (i = 0; i < pkt->size; i+=3) {
+for (i = 0; i < pkt->size - 2; i+=3) {
 if (pkt->data[i] == 0xfc && ((pkt->data[i + 1] != 0x80 || pkt->data[i 
+ 2] != 0x80)))
 break;
 }
-if (i >= pkt->size)
+if (i >= pkt->size - 2)
 return 0;
 
 if (!scc->inside && (scc->prev_h != h || scc->prev_m != m || scc->prev_s 
!= s || scc->prev_f != f)) {
-- 
2.35.1

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

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


[FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: check the length of packet and return used length

2022-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/ccaption_dec.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 34f0513b1a..8f61e8aa03 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -852,6 +852,11 @@ static int decode(AVCodecContext *avctx, AVSubtitle *sub,
 int i;
 unsigned nb_rect_allocated = 0;
 
+if (len < 3) {
+ff_dlog(avctx, "incomplete or broken packet");
+return len;
+}
+
 for (i = 0; i < len; i += 3) {
 uint8_t hi, cc_type = bptr[i] & 1;
 
@@ -922,7 +927,7 @@ static int decode(AVCodecContext *avctx, AVSubtitle *sub,
 }
 
 *got_sub = sub->num_rects > 0;
-return ret;
+return len;
 }
 
 #define OFFSET(x) offsetof(CCaptionSubContext, x)
-- 
2.35.1

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

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


[FFmpeg-devel] [PATCH 1/4] remove sccenc dependency on subtitles

2022-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3b9995a9d3..8e612b6cc7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -514,7 +514,7 @@ OBJS-$(CONFIG_SBC_DEMUXER)   += sbcdec.o 
rawdec.o
 OBJS-$(CONFIG_SBC_MUXER) += rawenc.o
 OBJS-$(CONFIG_SBG_DEMUXER)   += sbgdec.o
 OBJS-$(CONFIG_SCC_DEMUXER)   += sccdec.o subtitles.o
-OBJS-$(CONFIG_SCC_MUXER) += sccenc.o subtitles.o
+OBJS-$(CONFIG_SCC_MUXER) += sccenc.o
 OBJS-$(CONFIG_SCD_DEMUXER)   += scd.o
 OBJS-$(CONFIG_SDP_DEMUXER)   += rtsp.o
 OBJS-$(CONFIG_SDR2_DEMUXER)  += sdr2.o
-- 
2.35.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 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-11 Thread lance . lmwang
On Wed, May 11, 2022 at 02:00:10PM +0200, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> > From: Limin Wang 
> > 
> > some samples include both A53 and SCTE20 data. Before the commit, both
> > of the will be exported, so the CC data will be repeated or garbarge
> 
> Why would it be garbage? That sounds like a bug.
> Why can't we just export both?
for A53/SCTE20/DVDCC are exprted by A53_CC side data and they're sharing
the same a53_buf_ref to store the data, so if stream contains CC wrapped
as ATSC A53 packets + the same data wrapped as SCTE-20 packets, the CC
data will repeated. We can consider to add a new side data type if necessary,
but it's preferable to export A53_CC even it's SCTE20, so we can't export
both by A53_CC still.

related topic for it:
https://trac.ffmpeg.org/ticket/9724
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220427084949.73931-1-4ru...@gmail.com/
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20180306222512.20124-1-ffm...@tmm1.net/


> 
> -- 
> Anton Khirnov

-- 
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 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-08 Thread lance . lmwang
From: Limin Wang 

some samples include both A53 and SCTE20 data. Before the commit, both
of the will be exported, so the CC data will be repeated or garbarge
as they're using the same frame side data. If you know your samples include
only one of them, You can export by +a53cc+scte20.

After the commit, the default will not export MPEG2 A53/SCTE20/DVD CC side data,
please export on demand.

Signed-off-by: Limin Wang 
---
 doc/codecs.texi| 10 ++
 libavcodec/avcodec.h   | 16 +++-
 libavcodec/mpeg12dec.c |  6 +++---
 libavcodec/options_table.h |  3 +++
 libavcodec/version.h   |  2 +-
 tests/fate/ffmpeg.mak  |  2 +-
 tests/fate/subtitles.mak   |  6 +++---
 7 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 5e10020900..4cced983b9 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -662,6 +662,16 @@ for codecs that support it. At present, those are H.264 
and VP9.
 @item film_grain
 Export film grain parameters through frame side data (see 
@code{AV_FRAME_DATA_FILM_GRAIN_PARAMS}).
 Supported at present by AV1 decoders.
+@item a53cc
+Export A53 CC through frame side data (see @code{AV_FRAME_DATA_A53_CC})
+for codecs that support it.
+@item scte20cc
+Export SCTE20 CC through frame side data (see @code{AV_FRAME_DATA_A53_CC})
+for codecs that support it.
+@item dvdcc
+Export DVD CC through frame side data (see @code{AV_FRAME_DATA_A53_CC})
+for codecs that support it.
+
 @end table
 
 @item threads @var{integer} (@emph{decoding/encoding,video})
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4dae23d06e..25fd4de2fe 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -360,7 +360,21 @@ typedef struct RcOverride{
  * Do not apply film grain, export it instead.
  */
 #define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)
-
+/**
+ * Decoding only.
+ * Export A53 CC through frame side data
+ */
+#define AV_CODEC_EXPORT_DATA_A53_CC (1 << 4)
+/**
+ * Decoding only.
+ * Export SCTE20 CC through frame side data
+ */
+#define AV_CODEC_EXPORT_DATA_SCTE20_CC (1 << 5)
+/**
+ * Decoding only.
+ * Export DVD CC through frame side data
+ */
+#define AV_CODEC_EXPORT_DATA_DVD_CC (1 << 6)
 /**
  * The decoder will keep a reference to the frame and may reuse it later.
  */
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index e9bde48f7a..032cb8f9b1 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2203,7 +2203,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 {
 Mpeg1Context *s1 = avctx->priv_data;
 
-if (buf_size >= 6 &&
+if (buf_size >= 6 && (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_A53_CC) &&
 p[0] == 'G' && p[1] == 'A' && p[2] == '9' && p[3] == '4' &&
 p[4] == 3 && (p[5] & 0x40)) {
 /* extract A53 Part 4 CC data */
@@ -2224,7 +2224,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 return 1;
-} else if (buf_size >= 2 &&
+} else if (buf_size >= 2 && (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_SCTE20_CC) &&
p[0] == 0x03 && (p[1]&0x7f) == 0x01) {
 /* extract SCTE-20 CC data */
 GetBitContext gb;
@@ -2269,7 +2269,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 return 1;
-} else if (buf_size >= 11 &&
+} else if (buf_size >= 11 && (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_DVD_CC) &&
p[0] == 'C' && p[1] == 'C' && p[2] == 0x01 && p[3] == 0xf8) {
 /* extract DVD CC data
  *
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index e72b4d12b6..3c6db07459 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -88,6 +88,9 @@ static const AVOption avcodec_options[] = {
 {"prft", "export Producer Reference Time through packet side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, 
A|V|S|E, "export_side_data"},
 {"venc_params", "export video encoding parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, 
INT_MAX, V|D, "export_side_data"},
 {"film_grain", "export film grain parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_FILM_GRAIN}, INT_MIN, INT_MAX, 
V|D, "export_side_data"},
+{"a53cc", "export A53 CC through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 
= AV_CODEC_EXPORT_DATA_A53_CC}, INT_MIN, INT_MAX, V|D, "export_side_data"},
+{"scte20cc", "export SCTE20 CC through frame side data", 0, AV_OPT_TYPE_CONST, 
{.i64 = AV_CODEC_EXPORT_DATA_SCTE20_CC}, INT_MIN, INT_MAX, V|D, 
"export_side_data"},
+{"dvdcc", "export DVD CC through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 
= AV_CODEC_EXPORT_DATA_DVD_CC}, INT_MIN, INT_MAX, V|D, "export_side_data"},
 {"time_base", NULL, OFFSET(time_base), 

[FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: add dec_opts for the opened file

2022-05-08 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/filters.texi| 9 +
 libavfilter/src_movie.c | 5 -
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 367614d2f8..6775cf43ba 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -29652,6 +29652,15 @@ shows how to add protocol_whitelist and 
protocol_blacklist options:
 ffplay -f lavfi
 
"movie=filename='1.sdp':format_opts='protocol_whitelist=file,rtp,udp\:protocol_blacklist=http'"
 @end example
+
+@item dec_opts
+Specify decode options for the opened file. Format options can be specified
+as a list of @var{key}=@var{value} pairs separated by ':'. The following 
example
+shows how to add export_side_data options:
+@example
+./ffmpeg -y  -f lavfi
+-i "movie=./input.ts:dec_opts=export_side_data=scte20cc[out0+subcc]" out.srt
+@end example
 @end table
 
 It allows overlaying a second video on top of the main input of
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 711854c23c..c7dbd90aa9 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -70,6 +70,7 @@ typedef struct MovieContext {
 int64_t discontinuity_threshold;
 int64_t ts_offset;
 int dec_threads;
+AVDictionary *dec_opts;
 
 AVFormatContext *format_ctx;
 
@@ -96,6 +97,7 @@ static const AVOption movie_options[]= {
 { "discontinuity", "set discontinuity threshold", 
OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 
INT64_MAX, FLAGS },
 { "dec_threads",  "set the number of threads for decoding", 
OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 =  0}, 0, INT_MAX, FLAGS },
 { "format_opts",  "set format options for the opened file", 
OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
+{ "dec_opts", "set decode options for the opened file", 
OFFSET(dec_opts),AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
 { NULL },
 };
 
@@ -158,6 +160,7 @@ static AVStream *find_stream(void *log, AVFormatContext 
*avf, const char *spec)
 
 static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
 {
+MovieContext *movie = ctx->priv;
 const AVCodec *codec;
 int ret;
 
@@ -179,7 +182,7 @@ static int open_stream(AVFilterContext *ctx, MovieStream 
*st, int dec_threads)
 dec_threads = ff_filter_get_nb_threads(ctx);
 st->codec_ctx->thread_count = dec_threads;
 
-if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
+if ((ret = avcodec_open2(st->codec_ctx, codec, >dec_opts)) < 0) {
 av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
 return ret;
 }
-- 
2.35.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] libavcodec/mpeg12dec: extract embedded CC of particular type only

2022-05-07 Thread lance . lmwang
On Wed, Apr 27, 2022 at 03:49:49PM +0700, Ivan Baykalov wrote:
> Some streams contain closed caption data embedded using several wrapping
> types. For example stream can contain CC wrapped as ATSC A53 packets +
> the same data wrapped as SCTE-20 packets. Prior to the patch CC data was
> extracted from both types of packets, so it gave duplicated character
> pairs on the output.
> 
> Now we calculate some statistics which CC types appear more often in the
> stream and extract the data from a single type only. If at some point
> the other CC type becomes more active, we switch to this new type.

It's better to export them on demand instead of autodetect. I'll post the 
patchset
which fixed my local branch for review.

> 
> Fixes ticket #9724.
> ---
>  libavcodec/mpeg12dec.c | 44 ++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> index e9bde48f7a..f7e54ef0a9 100644
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -58,6 +58,14 @@
>  
>  #define A53_MAX_CC_COUNT 2000
>  
> +typedef enum CcType {
> +CC_TYPE_UNKNOWN = -1,
> +CC_TYPE_A53 = 0,
> +CC_TYPE_SCTE20,
> +CC_TYPE_DVD,
> +CC_TYPE_COUNT
> +} CcType;
> +
>  typedef struct Mpeg1Context {
>  MpegEncContext mpeg_enc_ctx;
>  int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
> @@ -81,6 +89,7 @@ typedef struct Mpeg1Context {
>  int first_slice;
>  int extradata_decoded;
>  int64_t timecode_frame_start;  /*< GOP timecode frame start number, in 
> non drop frame format */
> +int cc_packet_count[CC_TYPE_COUNT];
>  } Mpeg1Context;
>  
>  #define MB_TYPE_ZERO_MV   0x2000
> @@ -2198,6 +2207,32 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
>  return 0;
>  }
>  
> +static int cc_type_is_selected(Mpeg1Context *s1, CcType type)
> +{
> +int max = 0;
> +int max_index = -1;
> +int sum = 0;
> +av_assert0(type >= 0 && type < CC_TYPE_COUNT);
> +s1->cc_packet_count[type]++;
> +
> +for (int i = 0; i < CC_TYPE_COUNT; i++) {
> +if (s1->cc_packet_count[i] > max) {
> +max = s1->cc_packet_count[i];
> +max_index = i;
> +}
> +sum += s1->cc_packet_count[i];
> +}
> +
> +if (sum < 2 || sum > 20) {
> +// reset statistics, but give some advantage to the current selection
> +// to avoid frequent switching between the types
> +memset(s1->cc_packet_count, 0, sizeof(s1->cc_packet_count));
> +s1->cc_packet_count[max_index] = 2;
> +}
> +
> +return type == max_index;
> +}
> +
>  static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>const uint8_t *p, int buf_size)
>  {
> @@ -2217,6 +2252,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>  if (new_size > 3*A53_MAX_CC_COUNT)
>  return AVERROR(EINVAL);
>  
> +if (!cc_type_is_selected(s1, CC_TYPE_A53))
> +return 0;
> +
>  ret = av_buffer_realloc(>a53_buf_ref, new_size);
>  if (ret >= 0)
>  memcpy(s1->a53_buf_ref->data + old_size, p + 7, cc_count * 
> UINT64_C(3));
> @@ -2240,6 +2278,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>  if (new_size > 3*A53_MAX_CC_COUNT)
>  return AVERROR(EINVAL);
>  
> +if (!cc_type_is_selected(s1, CC_TYPE_SCTE20))
> +return 0;
> +
>  ret = av_buffer_realloc(>a53_buf_ref, new_size);
>  if (ret >= 0) {
>  uint8_t field, cc1, cc2;
> @@ -2310,6 +2351,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>  if (new_size > 3*A53_MAX_CC_COUNT)
>  return AVERROR(EINVAL);
>  
> +if (!cc_type_is_selected(s1, CC_TYPE_DVD))
> +return 0;
> +
>  ret = av_buffer_realloc(>a53_buf_ref, new_size);
>  if (ret >= 0) {
>  uint8_t field1 = !!(p[4] & 0x80);
> -- 
> 2.35.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".

-- 
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] Sponsoring R12L Decklink out

2022-04-06 Thread lance . lmwang
On Tue, Apr 05, 2022 at 10:22:54AM -0700, Alan Latteri wrote:
> Hello,
> 
> I am interesting in sponsoring the addition of R12L format  output via 
> Decklink.   Currently Decklink can only output up to v210 which is a 10bit 
> YUV 4:2:2 which is not full range video nor color accurate.  
> 
> bmdFormat12BitRGB= (* 'R12B' *) 
> $52313242;// Big-endian RGB 12-bit per component with full range 
> (0-4095). Packed as 12-bit per component

I can consider providing support, please clarify how much the sponsorship fee 
is and how it will be paid.


thanks.

> 
> Thank you.
> Alan
> 
> 
> ___
> 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 v3 1/5] avutil: add ambient viewing environment metadata side data

2022-04-05 Thread lance . lmwang
On Tue, Apr 05, 2022 at 05:32:12PM +0200, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavutil/frame.c  |  1 +
> >  libavutil/frame.h  |  6 +
> >  libavutil/mastering_display_metadata.c | 23 +
> >  libavutil/mastering_display_metadata.h | 45 
> > ++
> >  libavutil/version.h|  2 +-
> >  5 files changed, 76 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index fbb869f..8882da2 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -815,6 +815,7 @@ const char *av_frame_side_data_name(enum 
> > AVFrameSideDataType type)
> >  case AV_FRAME_DATA_DETECTION_BBOXES:return "Bounding boxes 
> > for object detection and classification";
> >  case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision 
> > RPU Data";
> >  case AV_FRAME_DATA_DOVI_METADATA:   return "Dolby Vision 
> > Metadata";
> > +case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: return "Ambient 
> > Viewing Environment";
> >  }
> >  return NULL;
> >  }
> > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > index 33fac20..92413c9 100644
> > --- a/libavutil/frame.h
> > +++ b/libavutil/frame.h
> > @@ -209,6 +209,12 @@ enum AVFrameSideDataType {
> >   * volume transform - CUVA 005.1-2021.
> >   */
> >  AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
> > +
> > +/**
> > + * ambient viewing environment for a video frame, as described by
> > + * the AVAmbientViewingEnv
> > + */
> > +AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
> >  };
> >  
> >  enum AVActiveFormatDescription {
> > diff --git a/libavutil/mastering_display_metadata.c 
> > b/libavutil/mastering_display_metadata.c
> > index 6069347..f094eab 100644
> > --- a/libavutil/mastering_display_metadata.c
> > +++ b/libavutil/mastering_display_metadata.c
> > @@ -64,3 +64,26 @@ AVContentLightMetadata 
> > *av_content_light_metadata_create_side_data(AVFrame *fram
> >  
> >  return (AVContentLightMetadata *)side_data->data;
> >  }
> > +
> > +AVAmbientViewingEnv *av_ambient_viewing_env_alloc(size_t *size)
> > +{
> > +AVAmbientViewingEnv *metadata = av_mallocz(sizeof(*metadata));
> > +
> > +if (size)
> > +*size = sizeof(*metadata);
> > +
> > +return metadata;
> > +}
> > +
> > +AVAmbientViewingEnv *av_ambient_viewing_env_create_side_data(AVFrame 
> > *frame)
> > +{
> > +AVFrameSideData *side_data = av_frame_new_side_data(frame,
> > +AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
> > +sizeof(AVAmbientViewingEnv));
> > +if (!side_data)
> > +return NULL;
> > +
> > +memset(side_data->data, 0, sizeof(AVAmbientViewingEnv));
> > +
> > +return (AVAmbientViewingEnv *)side_data->data;
> > +}
> > diff --git a/libavutil/mastering_display_metadata.h 
> > b/libavutil/mastering_display_metadata.h
> > index c23b07c..c1ba659 100644
> > --- a/libavutil/mastering_display_metadata.h
> > +++ b/libavutil/mastering_display_metadata.h
> > @@ -125,4 +125,49 @@ AVContentLightMetadata 
> > *av_content_light_metadata_alloc(size_t *size);
> >   */
> >  AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame 
> > *frame);
> >  
> > +/**
> > + * The characteristics of the nominal ambient viewing environment for
> > + * the display of the associated video content.
> > + * To be used as payload of a AVFrameSideData the appropriate type.
> > + *
> > + * @note The struct should be allocated with av_ambient_viewing_env_alloc()
> > + *   and its size is not a part of the public ABI.
> > + */
> > +typedef struct AVAmbientViewingEnv {
> > +/**
> > + * specifies the environmental illuminance of the ambient viewing
> > + * environment in units of 0.0001 lux.
> > + * ambient_illuminance shall not be equal to 0.
> > + */
> > +uint32_t ambient_illuminance;
> > +/**
> > + * specify the normalized x and y chromaticity coordinates, 
> > respectively,
> > + * of the environmental ambient light in the nominal viewing 
> > environment,
> > + * according to the CIE 1931 definition of x and y as specified in ISO
> > + * 11664-1 (see also ISO 11664-3 and CIE 15), in normalized increments 
> > of
> > + * 0.2. The values of ambient_light_x and ambient_light_y shall be 
> > in
> > + * the range of 0 to 5
> > + */
> > +uint16_t ambient_light_x;
> > +uint16_t ambient_light_y;
> > +} AVAmbientViewingEnv;
> > +
> > +/**
> > + * Allocate an AVAmbientViewingEnv structure and set its fields to
> > + * default values. The resulting struct can be freed using av_freep().
> > + *
> > + * @return An AVAmbientViewingEnv filled with default values or NULL
> > + * on failure.
> > + */
> > +AVAmbientViewingEnv *av_ambient_viewing_env_alloc(size_t *size);
> > +
> > +/**
> > + * Allocate a complete 

[FFmpeg-devel] [PATCH v3 5/5] avfilter/vf_showinfo: fix unknown side data type for DOVI_RPU_BUFFER

2022-04-05 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 1e81d26..18ddf12 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -824,6 +824,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_AMBIENT_VIEWING_ENV:
  dump_ambient_viewing_env(ctx, sd);
 break;
+case AV_FRAME_DATA_DOVI_RPU_BUFFER:
+av_log(ctx, AV_LOG_INFO, "DOVI RPU raw data "
+"(%"SIZE_SPECIFIER" bytes)", sd->size);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d "
"(%"SIZE_SPECIFIER" bytes)\n", 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] [PATCH v3 4/5] fftools/ffprobe: add support for ambient viewing environment metadata

2022-04-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 fftools/ffprobe.c  | 5 +
 tests/ref/fate/hevc-dv-rpu | 6 ++
 2 files changed, 11 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 05c167e..a13b93e 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2605,6 +2605,11 @@ static void show_frame(WriterContext *w, AVFrame *frame, 
AVStream *stream,
 AVContentLightMetadata *metadata = (AVContentLightMetadata 
*)sd->data;
 print_int("max_content", metadata->MaxCLL);
 print_int("max_average", metadata->MaxFALL);
+} else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENV) {
+AVAmbientViewingEnv *metadata = (AVAmbientViewingEnv 
*)sd->data;
+print_int("ambient_illuminance", 
metadata->ambient_illuminance);
+print_int("ambient_light_x", metadata->ambient_light_x);
+print_int("ambient_light_y", metadata->ambient_light_y);
 } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
 const AVDictionaryEntry *tag = av_dict_get(sd->metadata, 
"name", NULL, AV_DICT_MATCH_CASE);
 if (tag)
diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
index 6879f71..4ad5436 100644
--- a/tests/ref/fate/hevc-dv-rpu
+++ b/tests/ref/fate/hevc-dv-rpu
@@ -119,6 +119,9 @@ source_diagonal=42
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Ambient Viewing Environment
+ambient_illuminance=314
+ambient_light_x=15635
+ambient_light_y=16450
 [/SIDE_DATA]
 [/FRAME]
 [FRAME]
@@ -239,5 +242,8 @@ source_diagonal=42
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Ambient Viewing Environment
+ambient_illuminance=314
+ambient_light_x=15635
+ambient_light_y=16450
 [/SIDE_DATA]
 [/FRAME]
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v3 3/5] avfilter/vf_showinfo: add support for ambient viewing environment metadata

2022-04-05 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 12d3931..1e81d26 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -651,6 +651,15 @@ static void dump_color_property(AVFilterContext *ctx, 
AVFrame *frame)
 av_log(ctx, AV_LOG_INFO, "\n");
 }
 
+static void dump_ambient_viewing_env(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+const AVAmbientViewingEnv *metadata = (const AVAmbientViewingEnv 
*)sd->data;
+
+av_log(ctx, AV_LOG_INFO, "Ambient Viewing Environment: \n");
+av_log(ctx, AV_LOG_INFO, "ambient_illuminance=%d, ambient_light_x=%d, 
ambient_light_y=%d",
+   metadata->ambient_illuminance, metadata->ambient_light_x, 
metadata->ambient_light_y);
+}
+
 static void update_sample_stats_8(const uint8_t *src, int len, int64_t *sum, 
int64_t *sum2)
 {
 int i;
@@ -812,6 +821,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_DOVI_METADATA:
 dump_dovi_metadata(ctx, sd);
 break;
+case AV_FRAME_DATA_AMBIENT_VIEWING_ENV:
+ dump_ambient_viewing_env(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d "
"(%"SIZE_SPECIFIER" bytes)\n", 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] [PATCH v3 2/5] avcodec: add support for hevc ambient viewing environment SEI message

2022-04-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/hevc_sei.c  | 19 +++
 libavcodec/hevc_sei.h  |  8 
 libavcodec/hevcdec.c   | 10 ++
 tests/ref/fate/hevc-dv-rpu |  6 ++
 4 files changed, 43 insertions(+)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index ec3036f..8c6daf5 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -497,6 +497,23 @@ static int 
decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h,
 return 0;
 }
 
+static int decode_ambient_viewing_env(HEVCSEIAmbientViewingEnvironment *s, 
GetBitContext *gb, int size)
+{
+if (size < 8)
+return AVERROR_INVALIDDATA;
+
+s->ambient_illuminance  = get_bits_long(gb, 32);
+s->ambient_light_x  = get_bits(gb, 16);
+s->ambient_light_y  = get_bits(gb, 16);
+size -= 8;
+
+s->present = 1;
+
+skip_bits_long(gb, 8 * size);
+return  0;
+}
+
+
 static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
  const HEVCParamSets *ps, int type, int size)
 {
@@ -525,6 +542,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEI *s,
 return decode_nal_sei_timecode(>timecode, gb);
 case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
 return 
decode_film_grain_characteristics(>film_grain_characteristics, gb);
+case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT:
+return decode_ambient_viewing_env(>ambient_viewing_env, gb, size);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits_long(gb, 8 * size);
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index f198402..c7623f5 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -134,6 +134,13 @@ typedef struct HEVCSEIFilmGrainCharacteristics {
 int persistence_flag;
 } HEVCSEIFilmGrainCharacteristics;
 
+typedef struct HEVCSEIAmbientViewingEnvironment {
+int present;
+uint32_t ambient_illuminance;
+uint16_t ambient_light_x;
+uint16_t ambient_light_y;
+} HEVCSEIAmbientViewingEnvironment;
+
 typedef struct HEVCSEI {
 HEVCSEIPictureHash picture_hash;
 HEVCSEIFramePacking frame_packing;
@@ -149,6 +156,7 @@ typedef struct HEVCSEI {
 HEVCSEIAlternativeTransfer alternative_transfer;
 HEVCSEITimeCode timecode;
 HEVCSEIFilmGrainCharacteristics film_grain_characteristics;
+HEVCSEIAmbientViewingEnvironment ambient_viewing_env;
 } HEVCSEI;
 
 struct HEVCParamSets;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 09c07ac..21ed579 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2998,6 +2998,15 @@ static int set_side_data(HEVCContext *s)
 }
 }
 
+if (s->sei.ambient_viewing_env.present > 0) {
+AVAmbientViewingEnv *metadata = 
av_ambient_viewing_env_create_side_data(out);
+if (!metadata)
+return AVERROR(ENOMEM);
+metadata->ambient_illuminance = 
s->sei.ambient_viewing_env.ambient_illuminance;
+metadata->ambient_light_x = s->sei.ambient_viewing_env.ambient_light_x;
+metadata->ambient_light_y = s->sei.ambient_viewing_env.ambient_light_y;
+}
+
 return 0;
 }
 
@@ -3800,6 +3809,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 s->sei.mastering_display= s0->sei.mastering_display;
 s->sei.content_light= s0->sei.content_light;
 s->sei.alternative_transfer = s0->sei.alternative_transfer;
+s->sei.ambient_viewing_env  = s0->sei.ambient_viewing_env;
 
 ret = export_stream_params_from_sei(s);
 if (ret < 0)
diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
index 1980ab1..6879f71 100644
--- a/tests/ref/fate/hevc-dv-rpu
+++ b/tests/ref/fate/hevc-dv-rpu
@@ -117,6 +117,9 @@ source_min_pq=0
 source_max_pq=3079
 source_diagonal=42
 [/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Ambient Viewing Environment
+[/SIDE_DATA]
 [/FRAME]
 [FRAME]
 [SIDE_DATA]
@@ -234,4 +237,7 @@ source_min_pq=0
 source_max_pq=3079
 source_diagonal=42
 [/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Ambient Viewing Environment
+[/SIDE_DATA]
 [/FRAME]
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v3 1/5] avutil: add ambient viewing environment metadata side data

2022-04-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavutil/frame.c  |  1 +
 libavutil/frame.h  |  6 +
 libavutil/mastering_display_metadata.c | 23 +
 libavutil/mastering_display_metadata.h | 45 ++
 libavutil/version.h|  2 +-
 5 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index fbb869f..8882da2 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -815,6 +815,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_DETECTION_BBOXES:return "Bounding boxes for 
object detection and classification";
 case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU 
Data";
 case AV_FRAME_DATA_DOVI_METADATA:   return "Dolby Vision 
Metadata";
+case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: return "Ambient Viewing 
Environment";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 33fac20..92413c9 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -209,6 +209,12 @@ enum AVFrameSideDataType {
  * volume transform - CUVA 005.1-2021.
  */
 AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
+
+/**
+ * ambient viewing environment for a video frame, as described by
+ * the AVAmbientViewingEnv
+ */
+AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/mastering_display_metadata.c 
b/libavutil/mastering_display_metadata.c
index 6069347..f094eab 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -64,3 +64,26 @@ AVContentLightMetadata 
*av_content_light_metadata_create_side_data(AVFrame *fram
 
 return (AVContentLightMetadata *)side_data->data;
 }
+
+AVAmbientViewingEnv *av_ambient_viewing_env_alloc(size_t *size)
+{
+AVAmbientViewingEnv *metadata = av_mallocz(sizeof(*metadata));
+
+if (size)
+*size = sizeof(*metadata);
+
+return metadata;
+}
+
+AVAmbientViewingEnv *av_ambient_viewing_env_create_side_data(AVFrame *frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
+sizeof(AVAmbientViewingEnv));
+if (!side_data)
+return NULL;
+
+memset(side_data->data, 0, sizeof(AVAmbientViewingEnv));
+
+return (AVAmbientViewingEnv *)side_data->data;
+}
diff --git a/libavutil/mastering_display_metadata.h 
b/libavutil/mastering_display_metadata.h
index c23b07c..c1ba659 100644
--- a/libavutil/mastering_display_metadata.h
+++ b/libavutil/mastering_display_metadata.h
@@ -125,4 +125,49 @@ AVContentLightMetadata 
*av_content_light_metadata_alloc(size_t *size);
  */
 AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame 
*frame);
 
+/**
+ * The characteristics of the nominal ambient viewing environment for
+ * the display of the associated video content.
+ * To be used as payload of a AVFrameSideData the appropriate type.
+ *
+ * @note The struct should be allocated with av_ambient_viewing_env_alloc()
+ *   and its size is not a part of the public ABI.
+ */
+typedef struct AVAmbientViewingEnv {
+/**
+ * specifies the environmental illuminance of the ambient viewing
+ * environment in units of 0.0001 lux.
+ * ambient_illuminance shall not be equal to 0.
+ */
+uint32_t ambient_illuminance;
+/**
+ * specify the normalized x and y chromaticity coordinates, respectively,
+ * of the environmental ambient light in the nominal viewing environment,
+ * according to the CIE 1931 definition of x and y as specified in ISO
+ * 11664-1 (see also ISO 11664-3 and CIE 15), in normalized increments of
+ * 0.2. The values of ambient_light_x and ambient_light_y shall be in
+ * the range of 0 to 5
+ */
+uint16_t ambient_light_x;
+uint16_t ambient_light_y;
+} AVAmbientViewingEnv;
+
+/**
+ * Allocate an AVAmbientViewingEnv structure and set its fields to
+ * default values. The resulting struct can be freed using av_freep().
+ *
+ * @return An AVAmbientViewingEnv filled with default values or NULL
+ * on failure.
+ */
+AVAmbientViewingEnv *av_ambient_viewing_env_alloc(size_t *size);
+
+/**
+ * Allocate a complete AVAmbientViewingEnv and add it to the frame.
+ *
+ * @param frame The frame which side data is added to.
+ *
+ * @return The AVAmbientViewingEnv structure to be filled by caller.
+ */
+AVAmbientViewingEnv *av_ambient_viewing_env_create_side_data(AVFrame *frame);
+
 #endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 6735c20..998202f 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR  24
+#define LIBAVUTIL_VERSION_MINOR  25
 #define LIBAVUTIL_VERSION_MICRO 101
 
 #define 

Re: [FFmpeg-devel] [PATCH v2 1/4] avutil: add ambient viewing environment metadata side data

2022-04-05 Thread lance . lmwang
On Tue, Apr 05, 2022 at 11:13:12AM +0200, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2022-03-28 14:41:08)
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavutil/frame.c  |  1 +
> >  libavutil/frame.h  |  6 +
> >  libavutil/mastering_display_metadata.c | 23 +
> >  libavutil/mastering_display_metadata.h | 45 
> > ++
> >  4 files changed, 75 insertions(+)
> > 
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index fbb869f..8882da2 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -815,6 +815,7 @@ const char *av_frame_side_data_name(enum 
> > AVFrameSideDataType type)
> >  case AV_FRAME_DATA_DETECTION_BBOXES:return "Bounding boxes 
> > for object detection and classification";
> >  case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision 
> > RPU Data";
> >  case AV_FRAME_DATA_DOVI_METADATA:   return "Dolby Vision 
> > Metadata";
> > +case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: return "Ambient 
> > Viewing Environment";
> >  }
> >  return NULL;
> >  }
> > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > index 33fac20..f7b1d4e 100644
> > --- a/libavutil/frame.h
> > +++ b/libavutil/frame.h
> > @@ -209,6 +209,12 @@ enum AVFrameSideDataType {
> >   * volume transform - CUVA 005.1-2021.
> >   */
> >  AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
> > +
> > +/**
> > + * ambient viewing environment for a video frame, as described by
> > + * the AVAmbientViewingEnvMetadata.
> > + */
> > +AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
> >  };
> >  
> >  enum AVActiveFormatDescription {
> > diff --git a/libavutil/mastering_display_metadata.c 
> > b/libavutil/mastering_display_metadata.c
> > index 6069347..ba1c80f 100644
> > --- a/libavutil/mastering_display_metadata.c
> > +++ b/libavutil/mastering_display_metadata.c
> > @@ -64,3 +64,26 @@ AVContentLightMetadata 
> > *av_content_light_metadata_create_side_data(AVFrame *fram
> >  
> >  return (AVContentLightMetadata *)side_data->data;
> >  }
> > +
> > +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t 
> > *size)
> > +{
> > +AVAmbientViewingEnvMetadata *metadata = av_mallocz(sizeof(*metadata));
> > +
> > +if (size)
> > +*size = sizeof(*metadata);
> > +
> > +return metadata;
> > +}
> > +
> > +AVAmbientViewingEnvMetadata 
> > *av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame)
> > +{
> > +AVFrameSideData *side_data = av_frame_new_side_data(frame,
> > +AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
> > +sizeof(AVAmbientViewingEnvMetadata));
> > +if (!side_data)
> > +return NULL;
> > +
> > +memset(side_data->data, 0, sizeof(AVAmbientViewingEnvMetadata));
> > +
> > +return (AVAmbientViewingEnvMetadata *)side_data->data;
> > +}
> > diff --git a/libavutil/mastering_display_metadata.h 
> > b/libavutil/mastering_display_metadata.h
> > index c23b07c..d7598c1 100644
> > --- a/libavutil/mastering_display_metadata.h
> > +++ b/libavutil/mastering_display_metadata.h
> > @@ -125,4 +125,49 @@ AVContentLightMetadata 
> > *av_content_light_metadata_alloc(size_t *size);
> >   */
> >  AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame 
> > *frame);
> 
> The names are horribly long. I would suggest dropping 'metadata' from
> the struct and function names, they'd be shorter and no information is
> really lost.

I'm OK with the suggestion, will update the patch, thanks. 

> 
> -- 
> Anton Khirnov

-- 
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 v2 1/4] avutil: add ambient viewing environment metadata side data

2022-04-05 Thread lance . lmwang
On Mon, Mar 28, 2022 at 08:41:08PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavutil/frame.c  |  1 +
>  libavutil/frame.h  |  6 +
>  libavutil/mastering_display_metadata.c | 23 +
>  libavutil/mastering_display_metadata.h | 45 
> ++
>  4 files changed, 75 insertions(+)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index fbb869f..8882da2 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -815,6 +815,7 @@ const char *av_frame_side_data_name(enum 
> AVFrameSideDataType type)
>  case AV_FRAME_DATA_DETECTION_BBOXES:return "Bounding boxes 
> for object detection and classification";
>  case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU 
> Data";
>  case AV_FRAME_DATA_DOVI_METADATA:   return "Dolby Vision 
> Metadata";
> +case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: return "Ambient Viewing 
> Environment";
>  }
>  return NULL;
>  }
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 33fac20..f7b1d4e 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -209,6 +209,12 @@ enum AVFrameSideDataType {
>   * volume transform - CUVA 005.1-2021.
>   */
>  AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
> +
> +/**
> + * ambient viewing environment for a video frame, as described by
> + * the AVAmbientViewingEnvMetadata.
> + */
> +AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
>  };
>  
>  enum AVActiveFormatDescription {
> diff --git a/libavutil/mastering_display_metadata.c 
> b/libavutil/mastering_display_metadata.c
> index 6069347..ba1c80f 100644
> --- a/libavutil/mastering_display_metadata.c
> +++ b/libavutil/mastering_display_metadata.c
> @@ -64,3 +64,26 @@ AVContentLightMetadata 
> *av_content_light_metadata_create_side_data(AVFrame *fram
>  
>  return (AVContentLightMetadata *)side_data->data;
>  }
> +
> +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t 
> *size)
> +{
> +AVAmbientViewingEnvMetadata *metadata = av_mallocz(sizeof(*metadata));
> +
> +if (size)
> +*size = sizeof(*metadata);
> +
> +return metadata;
> +}
> +
> +AVAmbientViewingEnvMetadata 
> *av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame)
> +{
> +AVFrameSideData *side_data = av_frame_new_side_data(frame,
> +AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
> +sizeof(AVAmbientViewingEnvMetadata));
> +if (!side_data)
> +return NULL;
> +
> +memset(side_data->data, 0, sizeof(AVAmbientViewingEnvMetadata));
> +
> +return (AVAmbientViewingEnvMetadata *)side_data->data;
> +}
> diff --git a/libavutil/mastering_display_metadata.h 
> b/libavutil/mastering_display_metadata.h
> index c23b07c..d7598c1 100644
> --- a/libavutil/mastering_display_metadata.h
> +++ b/libavutil/mastering_display_metadata.h
> @@ -125,4 +125,49 @@ AVContentLightMetadata 
> *av_content_light_metadata_alloc(size_t *size);
>   */
>  AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame 
> *frame);
>  
> +/**
> + * The characteristics of the nominal ambient viewing environment for
> + * the display of the associated video content.
> + * To be used as payload of a AVFrameSideData the appropriate type.
> + *
> + * @note The struct should be allocated with 
> av_ambient_viewing_env_metadata_alloc()
> + *   and its size is not a part of the public ABI.
> + */
> +typedef struct AVAmbientViewingEnvMetadata {
> +/**
> + * specifies the environmental illuminance of the ambient viewing
> + * environment in units of 0.0001 lux.
> + * ambient_illuminance shall not be equal to 0.
> + */
> +uint32_t ambient_illuminance;
> +/**
> + * specify the normalized x and y chromaticity coordinates, respectively,
> + * of the environmental ambient light in the nominal viewing environment,
> + * according to the CIE 1931 definition of x and y as specified in ISO
> + * 11664-1 (see also ISO 11664-3 and CIE 15), in normalized increments of
> + * 0.2. The values of ambient_light_x and ambient_light_y shall be in
> + * the range of 0 to 5
> + */
> +uint16_t ambient_light_x;
> +uint16_t ambient_light_y;
> +} AVAmbientViewingEnvMetadata;
> +
> +/**
> + * Allocate an AVAmbientViewingEnvMetadata structure and set its fields to
> + * default values. The resulting struct can be freed using av_freep().
> + *
> + * @return An AVAmbientViewingEnvMetadata filled with default values or NULL
> + * on failure.
> + */
> +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t 
> *size);
> +
> +/**
> + * Allocate a complete AVAmbientViewingEnvMetadata and add it to the frame.
> + *
> + * @param frame The frame which side data is added to.
> + *
> + * @return The AVAmbientViewingEnvMetadata structure to be filled by caller.
> + */
> 

Re: [FFmpeg-devel] [PATCH] MAINTAINERS: add myself as maintainer for libsrt protocol

2022-03-31 Thread lance . lmwang
On Wed, Mar 30, 2022 at 09:44:08PM +0200, Marton Balint wrote:
> 
> 
> On Fri, 25 Mar 2022, Zhao Zhili wrote:
> 
> > Signed-off-by: Zhao Zhili 
> > ---
> > MAINTAINERS | 1 +
> > 1 file changed, 1 insertion(+)
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 931cf4bd2c..5daa6f8e03 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -516,6 +516,7 @@ Protocols:
> >   bluray.c  Petri Hintukainen
> >   ftp.c Lukasz Marek
> >   http.cRonald S. Bultje
> > +  libsrt.c  Zhao Zhili
> >   libssh.c  Lukasz Marek
> >   libzmq.c  Andriy Gelman
> >   mms*.cRonald S. Bultje
> 
> LGTM, thanks.

Applied, 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".

-- 
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] doc/bitstream_filters: fix for the syntax of code

2022-03-30 Thread lance . lmwang
On Wed, Mar 30, 2022 at 08:11:11PM +0530, Gyan Doshi wrote:
> 
> 
> On 2022-03-30 07:21 pm, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >   doc/bitstream_filters.texi | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> > index 0b354fd..fc2c71f 100644
> > --- a/doc/bitstream_filters.texi
> > +++ b/doc/bitstream_filters.texi
> > @@ -328,7 +328,7 @@ See H.264 section D.1.27 and D.2.27 for syntax and 
> > semantics.
> >   Default is pass.
> > -Insert mode works in conjunction with @code {rotate} and @code{flip} 
> > options.
> > +Insert mode works in conjunction with @code{rotate} and @code{flip} 
> > options.
> 
> The space doesn't lead to a rendering error. LGTM, anyway.

Yes, it's for My build system have several warning message when make.

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

-- 
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] doc/bitstream_filters: fix for the syntax of code

2022-03-30 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/bitstream_filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 0b354fd..fc2c71f 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -328,7 +328,7 @@ See H.264 section D.1.27 and D.2.27 for syntax and 
semantics.
 
 Default is pass.
 
-Insert mode works in conjunction with @code {rotate} and @code{flip} options.
+Insert mode works in conjunction with @code{rotate} and @code{flip} options.
 Any pre-existing Display orientation messages will be removed in insert or 
remove mode.
 Extract mode attaches the display matrix to the packet as side data.
 
-- 
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] MAINTAINERS: add myself as maintainer for libsrt protocol

2022-03-30 Thread lance . lmwang
On Fri, Mar 25, 2022 at 03:40:33PM +0800, Zhao Zhili wrote:
> Signed-off-by: Zhao Zhili 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 931cf4bd2c..5daa6f8e03 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -516,6 +516,7 @@ Protocols:
>bluray.c  Petri Hintukainen
>ftp.c Lukasz Marek
>http.cRonald S. Bultje
> +  libsrt.c  Zhao Zhili
>libssh.c  Lukasz Marek
>libzmq.c  Andriy Gelman
>mms*.cRonald S. Bultje
> -- 
> 2.31.1
> 
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".

-- 
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] avformat/libsrt: fix deprecated warning

2022-03-29 Thread lance . lmwang
On Fri, Mar 25, 2022 at 03:39:04PM +0800, Zhao Zhili wrote:
> srt_socket was deprecated after 1.4.1.
> ---
>  libavformat/libsrt.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
> index 19b9cb9895..1610ce8318 100644
> --- a/libavformat/libsrt.c
> +++ b/libavformat/libsrt.c
> @@ -429,7 +429,11 @@ static int libsrt_setup(URLContext *h, const char *uri, 
> int flags)
>  
>   restart:
>  
> +#if SRT_VERSION_VALUE >= 0x010401
> +fd = srt_create_socket();
> +#else
>  fd = srt_socket(cur_ai->ai_family, cur_ai->ai_socktype, 0);
> +#endif
>  if (fd < 0) {
>  ret = libsrt_neterrno(h);
>  goto fail;
> -- 
> 2.31.1

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

-- 
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 2/2] avcodec/libsvtav1: clean up unconditional override of avctx bit rate

2022-03-29 Thread lance . lmwang
On Sun, Mar 27, 2022 at 09:02:11PM +0300, Jan Ekström wrote:
> This value is only documented to be utilized if rate control is
> set to one of the bit rate based modes. These modes are not the
> default and thus the wrapper itself configures a bit rate according
> to the avctx if bit rate based encoding is requested, making the
> relevant value already be set when relevant.
> ---
>  libavcodec/libsvtav1.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
> index d89fefdf4c..fe0d100beb 100644
> --- a/libavcodec/libsvtav1.c
> +++ b/libavcodec/libsvtav1.c
> @@ -271,7 +271,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> *param,
>  param->frame_rate_denominator = avctx->time_base.num * 
> avctx->ticks_per_frame;
>  }
>  
> -avctx->bit_rate = param->target_bit_rate;
>  if (avctx->bit_rate) {
>  param->max_qp_allowed   = avctx->qmax;
>  param->min_qp_allowed   = avctx->qmin;
> -- 
> 2.35.1

The patch set is 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".

-- 
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 v2 2/4] avcodec: add support for hevc ambient viewing environment SEI message

2022-03-28 Thread lance . lmwang
On Mon, Mar 28, 2022 at 04:30:49PM +0200, Michael Niedermayer wrote:
> On Mon, Mar 28, 2022 at 08:41:09PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/hevc_sei.c  | 19 +++
> >  libavcodec/hevc_sei.h  |  8 
> >  libavcodec/hevcdec.c   | 10 ++
> >  tests/ref/fate/hevc-dv-rpu |  6 ++
> >  4 files changed, 43 insertions(+)
> > 
> > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
> > index ec3036f..d94df4e 100644
> > --- a/libavcodec/hevc_sei.c
> > +++ b/libavcodec/hevc_sei.c
> > @@ -497,6 +497,23 @@ static int 
> > decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h,
> >  return 0;
> >  }
> >  
> > +static int decode_ambient_viewing_env(HEVCSEIAmbientViewingEnvironment *s, 
> > GetBitContext *gb, int size)
> > +{
> > +if (size < 8)
> > +return AVERROR_INVALIDDATA;
> > +
> > +s->ambient_illuminance  = get_bits(gb, 32);
> 
> get_bits_long

thanks, fixed it locally.

> 
> thx
> 
> [...]
> 
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Its not that you shouldnt use gotos but rather that you should write
> readable code and code with gotos often but not always is less readable



> ___
> 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 4/4] fftools/ffprobe: add support for ambient viewing environment metadata

2022-03-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 fftools/ffprobe.c  | 5 +
 tests/ref/fate/hevc-dv-rpu | 6 ++
 2 files changed, 11 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 05c167e..39773c4 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2605,6 +2605,11 @@ static void show_frame(WriterContext *w, AVFrame *frame, 
AVStream *stream,
 AVContentLightMetadata *metadata = (AVContentLightMetadata 
*)sd->data;
 print_int("max_content", metadata->MaxCLL);
 print_int("max_average", metadata->MaxFALL);
+} else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENV) {
+AVAmbientViewingEnvMetadata *metadata = 
(AVAmbientViewingEnvMetadata *)sd->data;
+print_int("ambient_illuminance", 
metadata->ambient_illuminance);
+print_int("ambient_light_x", metadata->ambient_light_x);
+print_int("ambient_light_y", metadata->ambient_light_y);
 } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
 const AVDictionaryEntry *tag = av_dict_get(sd->metadata, 
"name", NULL, AV_DICT_MATCH_CASE);
 if (tag)
diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
index 6879f71..4ad5436 100644
--- a/tests/ref/fate/hevc-dv-rpu
+++ b/tests/ref/fate/hevc-dv-rpu
@@ -119,6 +119,9 @@ source_diagonal=42
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Ambient Viewing Environment
+ambient_illuminance=314
+ambient_light_x=15635
+ambient_light_y=16450
 [/SIDE_DATA]
 [/FRAME]
 [FRAME]
@@ -239,5 +242,8 @@ source_diagonal=42
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Ambient Viewing Environment
+ambient_illuminance=314
+ambient_light_x=15635
+ambient_light_y=16450
 [/SIDE_DATA]
 [/FRAME]
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 3/4] avfilter/vf_showinfo: add support for ambient viewing environment metadata

2022-03-28 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 12d3931..f11b3d9 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -651,6 +651,15 @@ static void dump_color_property(AVFilterContext *ctx, 
AVFrame *frame)
 av_log(ctx, AV_LOG_INFO, "\n");
 }
 
+static void dump_ambient_viewing_env_metadata(AVFilterContext *ctx, 
AVFrameSideData *sd)
+{
+const AVAmbientViewingEnvMetadata *metadata = (const 
AVAmbientViewingEnvMetadata *)sd->data;
+
+av_log(ctx, AV_LOG_INFO, "Ambient Viewing Environment metadata: \n");
+av_log(ctx, AV_LOG_INFO, "ambient_illuminance=%d, ambient_light_x=%d, 
ambient_light_y=%d",
+   metadata->ambient_illuminance, metadata->ambient_light_x, 
metadata->ambient_light_y);
+}
+
 static void update_sample_stats_8(const uint8_t *src, int len, int64_t *sum, 
int64_t *sum2)
 {
 int i;
@@ -812,6 +821,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_DOVI_METADATA:
 dump_dovi_metadata(ctx, sd);
 break;
+case AV_FRAME_DATA_AMBIENT_VIEWING_ENV:
+ dump_ambient_viewing_env_metadata(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d "
"(%"SIZE_SPECIFIER" bytes)\n", 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] [PATCH v2 2/4] avcodec: add support for hevc ambient viewing environment SEI message

2022-03-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/hevc_sei.c  | 19 +++
 libavcodec/hevc_sei.h  |  8 
 libavcodec/hevcdec.c   | 10 ++
 tests/ref/fate/hevc-dv-rpu |  6 ++
 4 files changed, 43 insertions(+)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index ec3036f..d94df4e 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -497,6 +497,23 @@ static int 
decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h,
 return 0;
 }
 
+static int decode_ambient_viewing_env(HEVCSEIAmbientViewingEnvironment *s, 
GetBitContext *gb, int size)
+{
+if (size < 8)
+return AVERROR_INVALIDDATA;
+
+s->ambient_illuminance  = get_bits(gb, 32);
+s->ambient_light_x  = get_bits(gb, 16);
+s->ambient_light_y  = get_bits(gb, 16);
+size -= 8;
+
+s->present = 1;
+
+skip_bits_long(gb, 8 * size);
+return  0;
+}
+
+
 static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
  const HEVCParamSets *ps, int type, int size)
 {
@@ -525,6 +542,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEI *s,
 return decode_nal_sei_timecode(>timecode, gb);
 case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
 return 
decode_film_grain_characteristics(>film_grain_characteristics, gb);
+case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT:
+return decode_ambient_viewing_env(>ambient_viewing_env, gb, size);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits_long(gb, 8 * size);
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index f198402..c7623f5 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -134,6 +134,13 @@ typedef struct HEVCSEIFilmGrainCharacteristics {
 int persistence_flag;
 } HEVCSEIFilmGrainCharacteristics;
 
+typedef struct HEVCSEIAmbientViewingEnvironment {
+int present;
+uint32_t ambient_illuminance;
+uint16_t ambient_light_x;
+uint16_t ambient_light_y;
+} HEVCSEIAmbientViewingEnvironment;
+
 typedef struct HEVCSEI {
 HEVCSEIPictureHash picture_hash;
 HEVCSEIFramePacking frame_packing;
@@ -149,6 +156,7 @@ typedef struct HEVCSEI {
 HEVCSEIAlternativeTransfer alternative_transfer;
 HEVCSEITimeCode timecode;
 HEVCSEIFilmGrainCharacteristics film_grain_characteristics;
+HEVCSEIAmbientViewingEnvironment ambient_viewing_env;
 } HEVCSEI;
 
 struct HEVCParamSets;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 09c07ac..13c6642 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2998,6 +2998,15 @@ static int set_side_data(HEVCContext *s)
 }
 }
 
+if (s->sei.ambient_viewing_env.present > 0) {
+AVAmbientViewingEnvMetadata *metadata = 
av_ambient_viewing_env_metadata_create_side_data(out);
+if (!metadata)
+return AVERROR(ENOMEM);
+metadata->ambient_illuminance = 
s->sei.ambient_viewing_env.ambient_illuminance;
+metadata->ambient_light_x = s->sei.ambient_viewing_env.ambient_light_x;
+metadata->ambient_light_y = s->sei.ambient_viewing_env.ambient_light_y;
+}
+
 return 0;
 }
 
@@ -3800,6 +3809,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 s->sei.mastering_display= s0->sei.mastering_display;
 s->sei.content_light= s0->sei.content_light;
 s->sei.alternative_transfer = s0->sei.alternative_transfer;
+s->sei.ambient_viewing_env  = s0->sei.ambient_viewing_env;
 
 ret = export_stream_params_from_sei(s);
 if (ret < 0)
diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
index 1980ab1..6879f71 100644
--- a/tests/ref/fate/hevc-dv-rpu
+++ b/tests/ref/fate/hevc-dv-rpu
@@ -117,6 +117,9 @@ source_min_pq=0
 source_max_pq=3079
 source_diagonal=42
 [/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Ambient Viewing Environment
+[/SIDE_DATA]
 [/FRAME]
 [FRAME]
 [SIDE_DATA]
@@ -234,4 +237,7 @@ source_min_pq=0
 source_max_pq=3079
 source_diagonal=42
 [/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Ambient Viewing Environment
+[/SIDE_DATA]
 [/FRAME]
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 1/4] avutil: add ambient viewing environment metadata side data

2022-03-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavutil/frame.c  |  1 +
 libavutil/frame.h  |  6 +
 libavutil/mastering_display_metadata.c | 23 +
 libavutil/mastering_display_metadata.h | 45 ++
 4 files changed, 75 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index fbb869f..8882da2 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -815,6 +815,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_DETECTION_BBOXES:return "Bounding boxes for 
object detection and classification";
 case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU 
Data";
 case AV_FRAME_DATA_DOVI_METADATA:   return "Dolby Vision 
Metadata";
+case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: return "Ambient Viewing 
Environment";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 33fac20..f7b1d4e 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -209,6 +209,12 @@ enum AVFrameSideDataType {
  * volume transform - CUVA 005.1-2021.
  */
 AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
+
+/**
+ * ambient viewing environment for a video frame, as described by
+ * the AVAmbientViewingEnvMetadata.
+ */
+AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/mastering_display_metadata.c 
b/libavutil/mastering_display_metadata.c
index 6069347..ba1c80f 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -64,3 +64,26 @@ AVContentLightMetadata 
*av_content_light_metadata_create_side_data(AVFrame *fram
 
 return (AVContentLightMetadata *)side_data->data;
 }
+
+AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t 
*size)
+{
+AVAmbientViewingEnvMetadata *metadata = av_mallocz(sizeof(*metadata));
+
+if (size)
+*size = sizeof(*metadata);
+
+return metadata;
+}
+
+AVAmbientViewingEnvMetadata 
*av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
+sizeof(AVAmbientViewingEnvMetadata));
+if (!side_data)
+return NULL;
+
+memset(side_data->data, 0, sizeof(AVAmbientViewingEnvMetadata));
+
+return (AVAmbientViewingEnvMetadata *)side_data->data;
+}
diff --git a/libavutil/mastering_display_metadata.h 
b/libavutil/mastering_display_metadata.h
index c23b07c..d7598c1 100644
--- a/libavutil/mastering_display_metadata.h
+++ b/libavutil/mastering_display_metadata.h
@@ -125,4 +125,49 @@ AVContentLightMetadata 
*av_content_light_metadata_alloc(size_t *size);
  */
 AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame 
*frame);
 
+/**
+ * The characteristics of the nominal ambient viewing environment for
+ * the display of the associated video content.
+ * To be used as payload of a AVFrameSideData the appropriate type.
+ *
+ * @note The struct should be allocated with 
av_ambient_viewing_env_metadata_alloc()
+ *   and its size is not a part of the public ABI.
+ */
+typedef struct AVAmbientViewingEnvMetadata {
+/**
+ * specifies the environmental illuminance of the ambient viewing
+ * environment in units of 0.0001 lux.
+ * ambient_illuminance shall not be equal to 0.
+ */
+uint32_t ambient_illuminance;
+/**
+ * specify the normalized x and y chromaticity coordinates, respectively,
+ * of the environmental ambient light in the nominal viewing environment,
+ * according to the CIE 1931 definition of x and y as specified in ISO
+ * 11664-1 (see also ISO 11664-3 and CIE 15), in normalized increments of
+ * 0.2. The values of ambient_light_x and ambient_light_y shall be in
+ * the range of 0 to 5
+ */
+uint16_t ambient_light_x;
+uint16_t ambient_light_y;
+} AVAmbientViewingEnvMetadata;
+
+/**
+ * Allocate an AVAmbientViewingEnvMetadata structure and set its fields to
+ * default values. The resulting struct can be freed using av_freep().
+ *
+ * @return An AVAmbientViewingEnvMetadata filled with default values or NULL
+ * on failure.
+ */
+AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t 
*size);
+
+/**
+ * Allocate a complete AVAmbientViewingEnvMetadata and add it to the frame.
+ *
+ * @param frame The frame which side data is added to.
+ *
+ * @return The AVAmbientViewingEnvMetadata structure to be filled by caller.
+ */
+AVAmbientViewingEnvMetadata 
*av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame);
+
 #endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */
-- 
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

Re: [FFmpeg-devel] [PATCH 1/4] avutil: add ambient viewing environment metadata side data

2022-03-27 Thread lance . lmwang
On Sun, Mar 27, 2022 at 08:30:30PM -0300, James Almer wrote:
> 
> 
> On 3/27/2022 8:25 PM, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >   libavutil/Makefile   |  2 +
> >   libavutil/ambient_viewing_env_metadata.c | 47 +
> >   libavutil/ambient_viewing_env_metadata.h | 72 
> > 
> >   libavutil/frame.c|  1 +
> >   libavutil/frame.h|  6 +++
> >   5 files changed, 128 insertions(+)
> >   create mode 100644 libavutil/ambient_viewing_env_metadata.c
> >   create mode 100644 libavutil/ambient_viewing_env_metadata.h
> > 
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index 81df3b0..e388d33 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -26,6 +26,7 @@ HEADERS = adler32.h   
> >   \
> > display.h \
> > dovi_meta.h   \
> > downmix_info.h\
> > +  ambient_viewing_env_metadata.h\
> > encryption_info.h \
> > error.h   \
> > eval.h\
> > @@ -119,6 +120,7 @@ OBJS = adler32.o
> > \
> >  display.o\
> >  dovi_meta.o  \
> >  downmix_info.o   \
> > +   ambient_viewing_env_metadata.o   \
> >  encryption_info.o\
> >  error.o  \
> >  eval.o   \
> > diff --git a/libavutil/ambient_viewing_env_metadata.c 
> > b/libavutil/ambient_viewing_env_metadata.c
> > new file mode 100644
> > index 000..7006b64
> > --- /dev/null
> > +++ b/libavutil/ambient_viewing_env_metadata.c
> > @@ -0,0 +1,47 @@
> > +/**
> > + * Copyright (c) 2022 Limin Wang 
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU Lesser General Public
> > + * License as published by the Free Software Foundation; either
> > + * version 2.1 of the License, or (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > + * Lesser General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU Lesser General Public
> > + * License along with FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
> > 02110-1301 USA
> > + */
> > +
> > +#include 
> > +#include 
> > +#include "ambient_viewing_env_metadata.h"
> > +#include "mem.h"
> > +
> > +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t 
> > *size)
> > +{
> > +AVAmbientViewingEnvMetadata *metadata = av_mallocz(sizeof(*metadata));
> > +
> > +if (size)
> > +*size = sizeof(*metadata);
> > +
> > +return metadata;
> > +}
> > +
> > +AVAmbientViewingEnvMetadata 
> > *av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame)
> > +{
> > +AVFrameSideData *side_data = av_frame_new_side_data(frame,
> > +AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
> > +sizeof(AVAmbientViewingEnvMetadata));
> > +if (!side_data)
> > +return NULL;
> > +
> > +memset(side_data->data, 0, sizeof(AVAmbientViewingEnvMetadata));
> > +
> > +return (AVAmbientViewingEnvMetadata *)side_data->data;
> > +}
> > diff --git a/libavutil/ambient_viewing_env_metadata.h 
> > b/libavutil/ambient_viewing_env_metadata.h
> > new file mode 100644
> > index 000..b0fbcd0
> > --- /dev/null
> > +++ b/libavutil/ambient_viewing_env_metadata.h
> > @@ -0,0 +1,72 @@
> > +/*
> > + * Copyright (c) 2022 Limin Wang 
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU Lesser General Public
> > + * License as published by the Free Software Foundation; either
> > + * version 2.1 of the License, or (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY 

[FFmpeg-devel] [PATCH 4/4] fftools/ffprobe: add support for ambient viewing environment metadata

2022-03-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 fftools/ffprobe.c  | 6 ++
 tests/ref/fate/hevc-dv-rpu | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 05c167e..5abe496 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -52,6 +52,7 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/timecode.h"
 #include "libavutil/timestamp.h"
+#include "libavutil/ambient_viewing_env_metadata.h"
 #include "libavdevice/avdevice.h"
 #include "libavdevice/version.h"
 #include "libswscale/swscale.h"
@@ -2605,6 +2606,11 @@ static void show_frame(WriterContext *w, AVFrame *frame, 
AVStream *stream,
 AVContentLightMetadata *metadata = (AVContentLightMetadata 
*)sd->data;
 print_int("max_content", metadata->MaxCLL);
 print_int("max_average", metadata->MaxFALL);
+} else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENV) {
+AVAmbientViewingEnvMetadata *metadata = 
(AVAmbientViewingEnvMetadata *)sd->data;
+print_int("ambient_illuminance", 
metadata->ambient_illuminance);
+print_int("ambient_light_x", metadata->ambient_light_x);
+print_int("ambient_light_y", metadata->ambient_light_y);
 } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
 const AVDictionaryEntry *tag = av_dict_get(sd->metadata, 
"name", NULL, AV_DICT_MATCH_CASE);
 if (tag)
diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
index 6879f71..4ad5436 100644
--- a/tests/ref/fate/hevc-dv-rpu
+++ b/tests/ref/fate/hevc-dv-rpu
@@ -119,6 +119,9 @@ source_diagonal=42
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Ambient Viewing Environment
+ambient_illuminance=314
+ambient_light_x=15635
+ambient_light_y=16450
 [/SIDE_DATA]
 [/FRAME]
 [FRAME]
@@ -239,5 +242,8 @@ source_diagonal=42
 [/SIDE_DATA]
 [SIDE_DATA]
 side_data_type=Ambient Viewing Environment
+ambient_illuminance=314
+ambient_light_x=15635
+ambient_light_y=16450
 [/SIDE_DATA]
 [/FRAME]
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH 3/4] avfilter/vf_showinfo: add support for ambient viewing environment metadata

2022-03-27 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 12d3931..ad86251 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -42,6 +42,7 @@
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/video_enc_params.h"
 #include "libavutil/detection_bbox.h"
+#include "libavutil/ambient_viewing_env_metadata.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -651,6 +652,15 @@ static void dump_color_property(AVFilterContext *ctx, 
AVFrame *frame)
 av_log(ctx, AV_LOG_INFO, "\n");
 }
 
+static void dump_ambient_viewing_env_metadata(AVFilterContext *ctx, 
AVFrameSideData *sd)
+{
+const AVAmbientViewingEnvMetadata *metadata = (const 
AVAmbientViewingEnvMetadata *)sd->data;
+
+av_log(ctx, AV_LOG_INFO, "Ambient Viewing Environment metadata: \n");
+av_log(ctx, AV_LOG_INFO, "ambient_illuminance=%d, ambient_light_x=%d, 
ambient_light_y=%d",
+   metadata->ambient_illuminance, metadata->ambient_light_x, 
metadata->ambient_light_y);
+}
+
 static void update_sample_stats_8(const uint8_t *src, int len, int64_t *sum, 
int64_t *sum2)
 {
 int i;
@@ -812,6 +822,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_DOVI_METADATA:
 dump_dovi_metadata(ctx, sd);
 break;
+case AV_FRAME_DATA_AMBIENT_VIEWING_ENV:
+ dump_ambient_viewing_env_metadata(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d "
"(%"SIZE_SPECIFIER" bytes)\n", 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] [PATCH 2/4] avcodec: add support for hevc ambient viewing environment SEI message

2022-03-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/hevc_sei.c  | 19 +++
 libavcodec/hevc_sei.h  |  8 
 libavcodec/hevcdec.c   | 11 +++
 tests/ref/fate/hevc-dv-rpu |  6 ++
 4 files changed, 44 insertions(+)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index ec3036f..d94df4e 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -497,6 +497,23 @@ static int 
decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h,
 return 0;
 }
 
+static int decode_ambient_viewing_env(HEVCSEIAmbientViewingEnvironment *s, 
GetBitContext *gb, int size)
+{
+if (size < 8)
+return AVERROR_INVALIDDATA;
+
+s->ambient_illuminance  = get_bits(gb, 32);
+s->ambient_light_x  = get_bits(gb, 16);
+s->ambient_light_y  = get_bits(gb, 16);
+size -= 8;
+
+s->present = 1;
+
+skip_bits_long(gb, 8 * size);
+return  0;
+}
+
+
 static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
  const HEVCParamSets *ps, int type, int size)
 {
@@ -525,6 +542,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEI *s,
 return decode_nal_sei_timecode(>timecode, gb);
 case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
 return 
decode_film_grain_characteristics(>film_grain_characteristics, gb);
+case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT:
+return decode_ambient_viewing_env(>ambient_viewing_env, gb, size);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits_long(gb, 8 * size);
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index f198402..c7623f5 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -134,6 +134,13 @@ typedef struct HEVCSEIFilmGrainCharacteristics {
 int persistence_flag;
 } HEVCSEIFilmGrainCharacteristics;
 
+typedef struct HEVCSEIAmbientViewingEnvironment {
+int present;
+uint32_t ambient_illuminance;
+uint16_t ambient_light_x;
+uint16_t ambient_light_y;
+} HEVCSEIAmbientViewingEnvironment;
+
 typedef struct HEVCSEI {
 HEVCSEIPictureHash picture_hash;
 HEVCSEIFramePacking frame_packing;
@@ -149,6 +156,7 @@ typedef struct HEVCSEI {
 HEVCSEIAlternativeTransfer alternative_transfer;
 HEVCSEITimeCode timecode;
 HEVCSEIFilmGrainCharacteristics film_grain_characteristics;
+HEVCSEIAmbientViewingEnvironment ambient_viewing_env;
 } HEVCSEI;
 
 struct HEVCParamSets;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 09c07ac..9be366e 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -36,6 +36,7 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
+#include "libavutil/ambient_viewing_env_metadata.h"
 
 #include "bswapdsp.h"
 #include "bytestream.h"
@@ -2998,6 +2999,15 @@ static int set_side_data(HEVCContext *s)
 }
 }
 
+if (s->sei.ambient_viewing_env.present > 0) {
+AVAmbientViewingEnvMetadata *metadata = 
av_ambient_viewing_env_metadata_create_side_data(out);
+if (!metadata)
+return AVERROR(ENOMEM);
+metadata->ambient_illuminance = 
s->sei.ambient_viewing_env.ambient_illuminance;
+metadata->ambient_light_x = s->sei.ambient_viewing_env.ambient_light_x;
+metadata->ambient_light_y = s->sei.ambient_viewing_env.ambient_light_y;
+}
+
 return 0;
 }
 
@@ -3800,6 +3810,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 s->sei.mastering_display= s0->sei.mastering_display;
 s->sei.content_light= s0->sei.content_light;
 s->sei.alternative_transfer = s0->sei.alternative_transfer;
+s->sei.ambient_viewing_env  = s0->sei.ambient_viewing_env;
 
 ret = export_stream_params_from_sei(s);
 if (ret < 0)
diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
index 1980ab1..6879f71 100644
--- a/tests/ref/fate/hevc-dv-rpu
+++ b/tests/ref/fate/hevc-dv-rpu
@@ -117,6 +117,9 @@ source_min_pq=0
 source_max_pq=3079
 source_diagonal=42
 [/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Ambient Viewing Environment
+[/SIDE_DATA]
 [/FRAME]
 [FRAME]
 [SIDE_DATA]
@@ -234,4 +237,7 @@ source_min_pq=0
 source_max_pq=3079
 source_diagonal=42
 [/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Ambient Viewing Environment
+[/SIDE_DATA]
 [/FRAME]
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH 1/4] avutil: add ambient viewing environment metadata side data

2022-03-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavutil/Makefile   |  2 +
 libavutil/ambient_viewing_env_metadata.c | 47 +
 libavutil/ambient_viewing_env_metadata.h | 72 
 libavutil/frame.c|  1 +
 libavutil/frame.h|  6 +++
 5 files changed, 128 insertions(+)
 create mode 100644 libavutil/ambient_viewing_env_metadata.c
 create mode 100644 libavutil/ambient_viewing_env_metadata.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 81df3b0..e388d33 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -26,6 +26,7 @@ HEADERS = adler32.h   
  \
   display.h \
   dovi_meta.h   \
   downmix_info.h\
+  ambient_viewing_env_metadata.h\
   encryption_info.h \
   error.h   \
   eval.h\
@@ -119,6 +120,7 @@ OBJS = adler32.o
\
display.o\
dovi_meta.o  \
downmix_info.o   \
+   ambient_viewing_env_metadata.o   \
encryption_info.o\
error.o  \
eval.o   \
diff --git a/libavutil/ambient_viewing_env_metadata.c 
b/libavutil/ambient_viewing_env_metadata.c
new file mode 100644
index 000..7006b64
--- /dev/null
+++ b/libavutil/ambient_viewing_env_metadata.c
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2022 Limin Wang 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include "ambient_viewing_env_metadata.h"
+#include "mem.h"
+
+AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t 
*size)
+{
+AVAmbientViewingEnvMetadata *metadata = av_mallocz(sizeof(*metadata));
+
+if (size)
+*size = sizeof(*metadata);
+
+return metadata;
+}
+
+AVAmbientViewingEnvMetadata 
*av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+AV_FRAME_DATA_AMBIENT_VIEWING_ENV,
+sizeof(AVAmbientViewingEnvMetadata));
+if (!side_data)
+return NULL;
+
+memset(side_data->data, 0, sizeof(AVAmbientViewingEnvMetadata));
+
+return (AVAmbientViewingEnvMetadata *)side_data->data;
+}
diff --git a/libavutil/ambient_viewing_env_metadata.h 
b/libavutil/ambient_viewing_env_metadata.h
new file mode 100644
index 000..b0fbcd0
--- /dev/null
+++ b/libavutil/ambient_viewing_env_metadata.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2022 Limin Wang 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_AMBIENT_VIEWING_ENV_METADATA_H
+#define AVUTIL_AMBIENT_VIEWING_ENV_METADATA_H
+
+#include "frame.h"
+
+
+/**
+ * The characteristics of the nominal ambient viewing environment for
+ * the display of the associated video content.
+ * To be used as 

Re: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: initialize pts/dts/duration of timecode packet

2022-03-22 Thread lance . lmwang
On Tue, Mar 22, 2022 at 02:28:10PM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > On Fri, Mar 11, 2022 at 05:16:09PM +0100, Andreas Rheinhardt wrote:
> >> lance.lmw...@gmail.com:
> >>> On Fri, Mar 11, 2022 at 03:04:32PM +0100, Andreas Rheinhardt wrote:
>  lance.lmw...@gmail.com:
> > On Wed, Mar 02, 2022 at 09:58:31PM +0800, lance.lmw...@gmail.com wrote:
> >> From: Limin Wang 
> >>
> >> Fix below error message when timecode packet is written.
> >> "Application provided duration: -9223372036854775808 / timestamp: 
> >> -9223372036854775808 is out of range for mov/mp4 format"
> >>
> >> try to reproduce by:
> >> ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 
> >> test.mov
> >>
> >> Note although error message is printed, the timecode packet will be 
> >> written anyway. So
> >> the patch 2/2 will try to change the log level to warning.
> >>
> >> The first two test case of fate-lavf-ismv have timecode setting, so 
> >> the crc of ref data is different.
> >> Fixes ticket #9488
> >>
> >> Signed-off-by: Limin Wang 
> >> ---
> >>  libavformat/movenc.c | 2 ++
> >>  tests/ref/lavf/ismv  | 4 ++--
> >>  2 files changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> >> index 4c86891..74b94cd 100644
> >> --- a/libavformat/movenc.c
> >> +++ b/libavformat/movenc.c
> >> @@ -6383,6 +6383,8 @@ static int 
> >> mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
> >>  pkt->data = data;
> >>  pkt->stream_index = index;
> >>  pkt->flags = AV_PKT_FLAG_KEY;
> >> +pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
> >> (AVRational){1,mov->movie_timescale});
> >> +pkt->duration = av_rescale_q(1, av_inv_q(rate), 
> >> (AVRational){1,mov->movie_timescale});
> >>  pkt->size = 4;
> >>  AV_WB32(pkt->data, tc.start);
> >>  ret = ff_mov_write_packet(s, pkt);
> >> diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
> >> index ac7f72b..723b432 100644
> >> --- a/tests/ref/lavf/ismv
> >> +++ b/tests/ref/lavf/ismv
> >> @@ -1,7 +1,7 @@
> >> -48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
> >> +7a24b73c096ec0f13f0f7a2d9101c4c1 *tests/data/lavf/lavf.ismv
> >>  313169 tests/data/lavf/lavf.ismv
> >>  tests/data/lavf/lavf.ismv CRC=0x9d9a638a
> >> -d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
> >> +79646383fd099d45ad0d0c2791c601dd *tests/data/lavf/lavf.ismv
> >>  322075 tests/data/lavf/lavf.ismv
> >>  tests/data/lavf/lavf.ismv CRC=0xe8130120
> >>  3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
> >> -- 
> >> 1.8.3.1
> >>
> >
> > will apply the patch set tomorrow unless there are any objections.
> >
> 
>  You have not really answered whether the current files or the new files
>  are spec-incompliant; you have just reported that one byte is different.
> >>>
> >>> Sorry, I think I have said both current and new file is spec-compliant in 
> >>> the last
> >>> email. 
> >>>
> >>
> >> You stated that you think that both files are valid, but you also said
> >> that you don't even know what this byte that is different actually means.
> >>
> >>> By Quicktime file format specs:
> >>> Section Timecode Sample Description, all tmcd field isn't used pts/dts.
> >>>
> >>> As for where is the different for one byte, it's caused by pkt->duration. 
> >>> The
> >>> old is 0(uninitialized), after the patch it's 33(1 frame duration).  
> >>>
> >>
> >> The text about Timecode Sample Description reads as follows: "Frame
> >> duration: A 32-bit integer that indicates how long each frame lasts in
> >> real time." This implies that only one of the two files can be
> >> spec-compliant. I am not a mov/ISOBMFF expert, but it seems to me that
> >> the current way of doing things is wrong. But I wonder about whether
> >> your patch is correct for vfr content. Doesn't the property of being vfr
> >> need to be reflected in the timecodes somehow (with different durations
> >> for different packets)?
> > 
> > Andreas, I have updated the patch and remove the fate difference which is
> > caused by duration, do you have any other comments for v2 patch?
> > 
> 
> No.

Thanks, then will apply the v2 patchsetet.

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

-- 
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 

Re: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: initialize pts/dts/duration of timecode packet

2022-03-22 Thread lance . lmwang
On Fri, Mar 11, 2022 at 05:16:09PM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > On Fri, Mar 11, 2022 at 03:04:32PM +0100, Andreas Rheinhardt wrote:
> >> lance.lmw...@gmail.com:
> >>> On Wed, Mar 02, 2022 at 09:58:31PM +0800, lance.lmw...@gmail.com wrote:
>  From: Limin Wang 
> 
>  Fix below error message when timecode packet is written.
>  "Application provided duration: -9223372036854775808 / timestamp: 
>  -9223372036854775808 is out of range for mov/mp4 format"
> 
>  try to reproduce by:
>  ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 
>  test.mov
> 
>  Note although error message is printed, the timecode packet will be 
>  written anyway. So
>  the patch 2/2 will try to change the log level to warning.
> 
>  The first two test case of fate-lavf-ismv have timecode setting, so the 
>  crc of ref data is different.
>  Fixes ticket #9488
> 
>  Signed-off-by: Limin Wang 
>  ---
>   libavformat/movenc.c | 2 ++
>   tests/ref/lavf/ismv  | 4 ++--
>   2 files changed, 4 insertions(+), 2 deletions(-)
> 
>  diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>  index 4c86891..74b94cd 100644
>  --- a/libavformat/movenc.c
>  +++ b/libavformat/movenc.c
>  @@ -6383,6 +6383,8 @@ static int 
>  mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
>   pkt->data = data;
>   pkt->stream_index = index;
>   pkt->flags = AV_PKT_FLAG_KEY;
>  +pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
>  (AVRational){1,mov->movie_timescale});
>  +pkt->duration = av_rescale_q(1, av_inv_q(rate), 
>  (AVRational){1,mov->movie_timescale});
>   pkt->size = 4;
>   AV_WB32(pkt->data, tc.start);
>   ret = ff_mov_write_packet(s, pkt);
>  diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
>  index ac7f72b..723b432 100644
>  --- a/tests/ref/lavf/ismv
>  +++ b/tests/ref/lavf/ismv
>  @@ -1,7 +1,7 @@
>  -48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
>  +7a24b73c096ec0f13f0f7a2d9101c4c1 *tests/data/lavf/lavf.ismv
>   313169 tests/data/lavf/lavf.ismv
>   tests/data/lavf/lavf.ismv CRC=0x9d9a638a
>  -d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
>  +79646383fd099d45ad0d0c2791c601dd *tests/data/lavf/lavf.ismv
>   322075 tests/data/lavf/lavf.ismv
>   tests/data/lavf/lavf.ismv CRC=0xe8130120
>   3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
>  -- 
>  1.8.3.1
> 
> >>>
> >>> will apply the patch set tomorrow unless there are any objections.
> >>>
> >>
> >> You have not really answered whether the current files or the new files
> >> are spec-incompliant; you have just reported that one byte is different.
> > 
> > Sorry, I think I have said both current and new file is spec-compliant in 
> > the last
> > email. 
> > 
> 
> You stated that you think that both files are valid, but you also said
> that you don't even know what this byte that is different actually means.
> 
> > By Quicktime file format specs:
> > Section Timecode Sample Description, all tmcd field isn't used pts/dts.
> > 
> > As for where is the different for one byte, it's caused by pkt->duration. 
> > The
> > old is 0(uninitialized), after the patch it's 33(1 frame duration).  
> > 
> 
> The text about Timecode Sample Description reads as follows: "Frame
> duration: A 32-bit integer that indicates how long each frame lasts in
> real time." This implies that only one of the two files can be
> spec-compliant. I am not a mov/ISOBMFF expert, but it seems to me that
> the current way of doing things is wrong. But I wonder about whether
> your patch is correct for vfr content. Doesn't the property of being vfr
> need to be reflected in the timecodes somehow (with different durations
> for different packets)?

Andreas, I have updated the patch and remove the fate difference which is
caused by duration, do you have any other comments for v2 patch?

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

-- 
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] avfilter/vf_showinfo: fix unknown side data type for DOVI_RPU_BUFFER

2022-03-22 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 12d3931..aa95341 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -812,6 +812,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_DOVI_METADATA:
 dump_dovi_metadata(ctx, sd);
 break;
+case AV_FRAME_DATA_DOVI_RPU_BUFFER:
+av_log(ctx, AV_LOG_INFO, "DOVI RPU raw data "
+   "(%"SIZE_SPECIFIER" bytes)", sd->size);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d "
"(%"SIZE_SPECIFIER" bytes)\n", 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] [PATCH v2 2/2] avformat/movenc: use warning log level and small adjustment for the log

2022-03-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/movenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 436ceb8..d0072f5 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5638,9 +5638,8 @@ static int check_pkt(AVFormatContext *s, AVPacket *pkt)
 
 duration = pkt->dts - ref;
 if (pkt->dts < ref || duration >= INT_MAX) {
-av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / 
timestamp: %"PRId64" is out of range for mov/mp4 format\n",
-duration, pkt->dts
-);
+av_log(s, AV_LOG_WARNING, "Packet duration: %"PRId64" / dts: %"PRId64" 
is out of range\n",
+   duration, pkt->dts);
 
 pkt->dts = ref + 1;
 pkt->pts = AV_NOPTS_VALUE;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 1/2] avformat/movenc: initialize pts/dts of timecode packet

2022-03-14 Thread lance . lmwang
From: Limin Wang 

Fix below error message when timecode packet is written.
"Application provided duration: -9223372036854775808 / timestamp: 
-9223372036854775808 is out of range for mov/mp4 format"

try to reproduce by:
ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 test.mov

Note although error message is printed, the timecode packet will be written 
anyway. So
the patch 2/2 will try to change the log level to warning.

Fixes ticket #9488

Signed-off-by: Limin Wang 
---
 libavformat/movenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ee1629d..436ceb8 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6356,6 +6356,7 @@ static int mov_create_timecode_track(AVFormatContext *s, 
int index, int src_inde
 pkt->data = data;
 pkt->stream_index = index;
 pkt->flags = AV_PKT_FLAG_KEY;
+pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
(AVRational){1,mov->movie_timescale});
 pkt->size = 4;
 AV_WB32(pkt->data, tc.start);
 ret = ff_mov_write_packet(s, pkt);
-- 
1.8.3.1

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: initialize pts/dts/duration of timecode packet

2022-03-11 Thread lance . lmwang
On Fri, Mar 11, 2022 at 05:16:09PM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > On Fri, Mar 11, 2022 at 03:04:32PM +0100, Andreas Rheinhardt wrote:
> >> lance.lmw...@gmail.com:
> >>> On Wed, Mar 02, 2022 at 09:58:31PM +0800, lance.lmw...@gmail.com wrote:
>  From: Limin Wang 
> 
>  Fix below error message when timecode packet is written.
>  "Application provided duration: -9223372036854775808 / timestamp: 
>  -9223372036854775808 is out of range for mov/mp4 format"
> 
>  try to reproduce by:
>  ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 
>  test.mov
> 
>  Note although error message is printed, the timecode packet will be 
>  written anyway. So
>  the patch 2/2 will try to change the log level to warning.
> 
>  The first two test case of fate-lavf-ismv have timecode setting, so the 
>  crc of ref data is different.
>  Fixes ticket #9488
> 
>  Signed-off-by: Limin Wang 
>  ---
>   libavformat/movenc.c | 2 ++
>   tests/ref/lavf/ismv  | 4 ++--
>   2 files changed, 4 insertions(+), 2 deletions(-)
> 
>  diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>  index 4c86891..74b94cd 100644
>  --- a/libavformat/movenc.c
>  +++ b/libavformat/movenc.c
>  @@ -6383,6 +6383,8 @@ static int 
>  mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
>   pkt->data = data;
>   pkt->stream_index = index;
>   pkt->flags = AV_PKT_FLAG_KEY;
>  +pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
>  (AVRational){1,mov->movie_timescale});
>  +pkt->duration = av_rescale_q(1, av_inv_q(rate), 
>  (AVRational){1,mov->movie_timescale});
>   pkt->size = 4;
>   AV_WB32(pkt->data, tc.start);
>   ret = ff_mov_write_packet(s, pkt);
>  diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
>  index ac7f72b..723b432 100644
>  --- a/tests/ref/lavf/ismv
>  +++ b/tests/ref/lavf/ismv
>  @@ -1,7 +1,7 @@
>  -48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
>  +7a24b73c096ec0f13f0f7a2d9101c4c1 *tests/data/lavf/lavf.ismv
>   313169 tests/data/lavf/lavf.ismv
>   tests/data/lavf/lavf.ismv CRC=0x9d9a638a
>  -d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
>  +79646383fd099d45ad0d0c2791c601dd *tests/data/lavf/lavf.ismv
>   322075 tests/data/lavf/lavf.ismv
>   tests/data/lavf/lavf.ismv CRC=0xe8130120
>   3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
>  -- 
>  1.8.3.1
> 
> >>>
> >>> will apply the patch set tomorrow unless there are any objections.
> >>>
> >>
> >> You have not really answered whether the current files or the new files
> >> are spec-incompliant; you have just reported that one byte is different.
> > 
> > Sorry, I think I have said both current and new file is spec-compliant in 
> > the last
> > email. 
> > 
> 
> You stated that you think that both files are valid, but you also said
> that you don't even know what this byte that is different actually means.
> 
> > By Quicktime file format specs:
> > Section Timecode Sample Description, all tmcd field isn't used pts/dts.
> > 
> > As for where is the different for one byte, it's caused by pkt->duration. 
> > The
> > old is 0(uninitialized), after the patch it's 33(1 frame duration).  
> > 
> 
> The text about Timecode Sample Description reads as follows: "Frame
> duration: A 32-bit integer that indicates how long each frame lasts in
> real time." This implies that only one of the two files can be
> spec-compliant. I am not a mov/ISOBMFF expert, but it seems to me that
> the current way of doing things is wrong. But I wonder about whether
> your patch is correct for vfr content. Doesn't the property of being vfr
> need to be reflected in the timecodes somehow (with different durations
> for different packets)?

No, it's packet duration, not tmcd frame duration, my patch have do nothing 
for that.(see movenc.c:2348). In addition, for timecode, I don't think vfr is
supported.

The tmcd track just contains one packet with the frame number(4byte), so the
packet data is used by start of timecode. So I set the dts/pts is avoid the
following code think it's invalid packet. If you wonder the patch will change
something, I can update the patch keep packet duration to default zero, then
we can the fate data untouched, for the following track_duration will use it
and make the crc of output is different.


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

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: initialize pts/dts/duration of timecode packet

2022-03-11 Thread lance . lmwang
On Fri, Mar 11, 2022 at 03:04:32PM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > On Wed, Mar 02, 2022 at 09:58:31PM +0800, lance.lmw...@gmail.com wrote:
> >> From: Limin Wang 
> >>
> >> Fix below error message when timecode packet is written.
> >> "Application provided duration: -9223372036854775808 / timestamp: 
> >> -9223372036854775808 is out of range for mov/mp4 format"
> >>
> >> try to reproduce by:
> >> ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 test.mov
> >>
> >> Note although error message is printed, the timecode packet will be 
> >> written anyway. So
> >> the patch 2/2 will try to change the log level to warning.
> >>
> >> The first two test case of fate-lavf-ismv have timecode setting, so the 
> >> crc of ref data is different.
> >> Fixes ticket #9488
> >>
> >> Signed-off-by: Limin Wang 
> >> ---
> >>  libavformat/movenc.c | 2 ++
> >>  tests/ref/lavf/ismv  | 4 ++--
> >>  2 files changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> >> index 4c86891..74b94cd 100644
> >> --- a/libavformat/movenc.c
> >> +++ b/libavformat/movenc.c
> >> @@ -6383,6 +6383,8 @@ static int mov_create_timecode_track(AVFormatContext 
> >> *s, int index, int src_inde
> >>  pkt->data = data;
> >>  pkt->stream_index = index;
> >>  pkt->flags = AV_PKT_FLAG_KEY;
> >> +pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
> >> (AVRational){1,mov->movie_timescale});
> >> +pkt->duration = av_rescale_q(1, av_inv_q(rate), 
> >> (AVRational){1,mov->movie_timescale});
> >>  pkt->size = 4;
> >>  AV_WB32(pkt->data, tc.start);
> >>  ret = ff_mov_write_packet(s, pkt);
> >> diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
> >> index ac7f72b..723b432 100644
> >> --- a/tests/ref/lavf/ismv
> >> +++ b/tests/ref/lavf/ismv
> >> @@ -1,7 +1,7 @@
> >> -48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
> >> +7a24b73c096ec0f13f0f7a2d9101c4c1 *tests/data/lavf/lavf.ismv
> >>  313169 tests/data/lavf/lavf.ismv
> >>  tests/data/lavf/lavf.ismv CRC=0x9d9a638a
> >> -d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
> >> +79646383fd099d45ad0d0c2791c601dd *tests/data/lavf/lavf.ismv
> >>  322075 tests/data/lavf/lavf.ismv
> >>  tests/data/lavf/lavf.ismv CRC=0xe8130120
> >>  3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
> >> -- 
> >> 1.8.3.1
> >>
> > 
> > will apply the patch set tomorrow unless there are any objections.
> > 
> 
> You have not really answered whether the current files or the new files
> are spec-incompliant; you have just reported that one byte is different.

Sorry, I think I have said both current and new file is spec-compliant in the 
last
email. 

By Quicktime file format specs:
Section Timecode Sample Description, all tmcd field isn't used pts/dts.

As for where is the different for one byte, it's caused by pkt->duration. The
old is 0(uninitialized), after the patch it's 33(1 frame duration).  

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

-- 
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 1/2] avformat/movenc: initialize pts/dts/duration of timecode packet

2022-03-11 Thread lance . lmwang
On Wed, Mar 02, 2022 at 09:58:31PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Fix below error message when timecode packet is written.
> "Application provided duration: -9223372036854775808 / timestamp: 
> -9223372036854775808 is out of range for mov/mp4 format"
> 
> try to reproduce by:
> ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 test.mov
> 
> Note although error message is printed, the timecode packet will be written 
> anyway. So
> the patch 2/2 will try to change the log level to warning.
> 
> The first two test case of fate-lavf-ismv have timecode setting, so the crc 
> of ref data is different.
> Fixes ticket #9488
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/movenc.c | 2 ++
>  tests/ref/lavf/ismv  | 4 ++--
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 4c86891..74b94cd 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -6383,6 +6383,8 @@ static int mov_create_timecode_track(AVFormatContext 
> *s, int index, int src_inde
>  pkt->data = data;
>  pkt->stream_index = index;
>  pkt->flags = AV_PKT_FLAG_KEY;
> +pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
> (AVRational){1,mov->movie_timescale});
> +pkt->duration = av_rescale_q(1, av_inv_q(rate), 
> (AVRational){1,mov->movie_timescale});
>  pkt->size = 4;
>  AV_WB32(pkt->data, tc.start);
>  ret = ff_mov_write_packet(s, pkt);
> diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
> index ac7f72b..723b432 100644
> --- a/tests/ref/lavf/ismv
> +++ b/tests/ref/lavf/ismv
> @@ -1,7 +1,7 @@
> -48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
> +7a24b73c096ec0f13f0f7a2d9101c4c1 *tests/data/lavf/lavf.ismv
>  313169 tests/data/lavf/lavf.ismv
>  tests/data/lavf/lavf.ismv CRC=0x9d9a638a
> -d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
> +79646383fd099d45ad0d0c2791c601dd *tests/data/lavf/lavf.ismv
>  322075 tests/data/lavf/lavf.ismv
>  tests/data/lavf/lavf.ismv CRC=0xe8130120
>  3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
> -- 
> 1.8.3.1
> 

will apply the patch set tomorrow unless there are any objections.

-- 
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] fate: add a test for HDR Vivid metadata in HEVC

2022-03-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
Please help to upload below sample to fate-suite/hevc/
https://streams.videolan.org/ffmpeg/incoming/hdr_vivid_h265_sample.hevc

 tests/fate/hevc.mak|  3 ++
 tests/ref/fate/hevc-hdr-vivid-metadata | 78 ++
 2 files changed, 81 insertions(+)
 create mode 100644 tests/ref/fate/hevc-hdr-vivid-metadata

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index f294cff..3adee59 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -273,6 +273,9 @@ FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += 
fate-hevc-monochrome-crop
 fate-hevc-hdr10-plus-metadata: CMD = probeframes -show_entries 
frame=side_data_list $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc
 FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-hdr10-plus-metadata
 
+fate-hevc-hdr-vivid-metadata: CMD = probeframes -show_entries 
frame=side_data_list $(TARGET_SAMPLES)/hevc/hdr_vivid_h265_sample.hevc
+FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-hdr-vivid-metadata
+
 fate-hevc-dv-rpu: CMD = probeframes -show_entries frame=side_data_list 
-select_streams 0 -read_intervals "%+\#2" $(TARGET_SAMPLES)/hevc/dv84.mov
 FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-dv-rpu
 
diff --git a/tests/ref/fate/hevc-hdr-vivid-metadata 
b/tests/ref/fate/hevc-hdr-vivid-metadata
new file mode 100644
index 000..5f69973
--- /dev/null
+++ b/tests/ref/fate/hevc-hdr-vivid-metadata
@@ -0,0 +1,78 @@
+[FRAME]
+[SIDE_DATA]
+side_data_type=Mastering display metadata
+red_x=34000/5
+red_y=16000/5
+green_x=13250/5
+green_y=34500/5
+blue_x=7500/5
+blue_y=3000/5
+white_point_x=15635/5
+white_point_y=16450/5
+min_luminance=50/1
+max_luminance=4000/1
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=Content light level metadata
+max_content=0
+max_average=0
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=H.26[45] User Data Unregistered SEI message
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=HDR Dynamic Metadata CUVA 005.1 2021 (Vivid)
+system_start_code=1
+num_windows=1
+minimum_maxrgb=0/4095
+average_maxrgb=3046/4095
+variance_maxrgb=1535/4095
+maximum_maxrgb=4095/4095
+tone_mapping_mode_flag=1
+tone_mapping_param_num=2
+targeted_system_display_maximum_luminance=2770/4095
+base_enable_flag=1
+base_param_m_p=5734/16383
+base_param_m_m=24/10
+base_param_m_a=563/1023
+base_param_m_b=0/1023
+base_param_m_n=10/10
+base_param_k1=1
+base_param_k2=1
+base_param_k3=1
+base_param_Delta_enable_mode=0
+base_param_Delta=0/127
+3Spline_enable_flag=1
+3Spline_num=1
+3Spline_TH_mode=0
+3Spline_TH_enable_MB=224/255
+3Spline_TH_enable=0/4095
+3Spline_TH_Delta1=511/1023
+3Spline_TH_Delta2=511/1023
+3Spline_enable_Strength=127/255
+targeted_system_display_maximum_luminance=2080/4095
+base_enable_flag=1
+base_param_m_p=5734/16383
+base_param_m_m=24/10
+base_param_m_a=563/1023
+base_param_m_b=0/1023
+base_param_m_n=10/10
+base_param_k1=1
+base_param_k2=1
+base_param_k3=1
+base_param_Delta_enable_mode=0
+base_param_Delta=0/127
+3Spline_enable_flag=1
+3Spline_num=1
+3Spline_TH_mode=0
+3Spline_TH_enable_MB=224/255
+3Spline_TH_enable=0/4095
+3Spline_TH_Delta1=511/1023
+3Spline_TH_Delta2=511/1023
+3Spline_enable_Strength=127/255
+color_saturation_mapping_flag=1
+color_saturation_num=2
+color_saturation_gain=38/128
+color_saturation_gain=25/128
+[/SIDE_DATA]
+[/FRAME]
-- 
1.8.3.1

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: initialize pts/dts/duration of timecode packet

2022-03-02 Thread lance . lmwang
On Thu, Mar 03, 2022 at 02:55:23AM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Fix below error message when timecode packet is written.
> > "Application provided duration: -9223372036854775808 / timestamp: 
> > -9223372036854775808 is out of range for mov/mp4 format"
> > 
> > try to reproduce by:
> > ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 test.mov
> > 
> > Note although error message is printed, the timecode packet will be written 
> > anyway. So
> > the patch 2/2 will try to change the log level to warning.
> > 
> > The first two test case of fate-lavf-ismv have timecode setting, so the crc 
> > of ref data is different.
> > Fixes ticket #9488
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/movenc.c | 2 ++
> >  tests/ref/lavf/ismv  | 4 ++--
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > index 4c86891..74b94cd 100644
> > --- a/libavformat/movenc.c
> > +++ b/libavformat/movenc.c
> > @@ -6383,6 +6383,8 @@ static int mov_create_timecode_track(AVFormatContext 
> > *s, int index, int src_inde
> >  pkt->data = data;
> >  pkt->stream_index = index;
> >  pkt->flags = AV_PKT_FLAG_KEY;
> > +pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
> > (AVRational){1,mov->movie_timescale});
> > +pkt->duration = av_rescale_q(1, av_inv_q(rate), 
> > (AVRational){1,mov->movie_timescale});
> >  pkt->size = 4;
> >  AV_WB32(pkt->data, tc.start);
> >  ret = ff_mov_write_packet(s, pkt);
> > diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
> > index ac7f72b..723b432 100644
> > --- a/tests/ref/lavf/ismv
> > +++ b/tests/ref/lavf/ismv
> > @@ -1,7 +1,7 @@
> > -48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
> > +7a24b73c096ec0f13f0f7a2d9101c4c1 *tests/data/lavf/lavf.ismv
> >  313169 tests/data/lavf/lavf.ismv
> >  tests/data/lavf/lavf.ismv CRC=0x9d9a638a
> > -d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
> > +79646383fd099d45ad0d0c2791c601dd *tests/data/lavf/lavf.ismv
> >  322075 tests/data/lavf/lavf.ismv
> >  tests/data/lavf/lavf.ismv CRC=0xe8130120
> >  3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
> 
> Are the currently created files spec-incompliant? Or will the files
> created with this patch be spec-incompliant?

I think both the currently created files and after are spec-compliant as the
pts/dts isn't used by tmcd track I think.

The currently code will trigger below condition as the pts/dts isn't 
initialized:
[ismv @ 0x56c8c40] Application provided duration: -9223372036854775808 / 
timestamp: -9223372036854775808 is out of range for mov/mp4 format

so the dts and pts will try to set them as the following code:
5640 if (pkt->dts < ref || duration >= INT_MAX) {
5641 av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" 
/ timestamp: %"PRId64" is out of range for mov/mp4 format\n",
5642 duration, pkt->dts
5643 );
5644
5645 pkt->dts = ref + 1;
5646 pkt->pts = AV_NOPTS_VALUE;
5647 }

By the comparing hex string by before and after, one byte is different, but I 
haven't figured
out where is it yet, but it's related pts and dts value.

[ffmpeg.git]$ hexdump lavf_before.ismv > lavf_before.log
[ffmpeg.git]$ hexdump lavf_after.ismv > lavf_after.log
[ffmpeg.git]$ diff lavf_before.log lavf_after.log
8974c8974
< 00230d0     6d0c 6164 0074 0804
---
> 00230d0   0028  6d0c 6164 0074 0804


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

-- 
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 2/2] avformat/movenc: use warning log level and small adjustment for the log

2022-03-02 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/movenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 74b94cd..8b038c1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5638,9 +5638,8 @@ static int check_pkt(AVFormatContext *s, AVPacket *pkt)
 
 duration = pkt->dts - ref;
 if (pkt->dts < ref || duration >= INT_MAX) {
-av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / 
timestamp: %"PRId64" is out of range for mov/mp4 format\n",
-duration, pkt->dts
-);
+av_log(s, AV_LOG_WARNING, "Packet duration: %"PRId64" / dts: %"PRId64" 
is out of range\n",
+   duration, pkt->dts);
 
 pkt->dts = ref + 1;
 pkt->pts = AV_NOPTS_VALUE;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH 1/2] avformat/movenc: initialize pts/dts/duration of timecode packet

2022-03-02 Thread lance . lmwang
From: Limin Wang 

Fix below error message when timecode packet is written.
"Application provided duration: -9223372036854775808 / timestamp: 
-9223372036854775808 is out of range for mov/mp4 format"

try to reproduce by:
ffmpeg -y -f lavfi -i color -metadata "timecode=00:00:00:00" -t 1 test.mov

Note although error message is printed, the timecode packet will be written 
anyway. So
the patch 2/2 will try to change the log level to warning.

The first two test case of fate-lavf-ismv have timecode setting, so the crc of 
ref data is different.
Fixes ticket #9488

Signed-off-by: Limin Wang 
---
 libavformat/movenc.c | 2 ++
 tests/ref/lavf/ismv  | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c86891..74b94cd 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6383,6 +6383,8 @@ static int mov_create_timecode_track(AVFormatContext *s, 
int index, int src_inde
 pkt->data = data;
 pkt->stream_index = index;
 pkt->flags = AV_PKT_FLAG_KEY;
+pkt->pts = pkt->dts = av_rescale_q(tc.start, av_inv_q(rate), 
(AVRational){1,mov->movie_timescale});
+pkt->duration = av_rescale_q(1, av_inv_q(rate), 
(AVRational){1,mov->movie_timescale});
 pkt->size = 4;
 AV_WB32(pkt->data, tc.start);
 ret = ff_mov_write_packet(s, pkt);
diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
index ac7f72b..723b432 100644
--- a/tests/ref/lavf/ismv
+++ b/tests/ref/lavf/ismv
@@ -1,7 +1,7 @@
-48fb8d7a5d19bd60f3a49ccf4b7d6593 *tests/data/lavf/lavf.ismv
+7a24b73c096ec0f13f0f7a2d9101c4c1 *tests/data/lavf/lavf.ismv
 313169 tests/data/lavf/lavf.ismv
 tests/data/lavf/lavf.ismv CRC=0x9d9a638a
-d19cd8e310a2e94fe0a0d11c5dc29217 *tests/data/lavf/lavf.ismv
+79646383fd099d45ad0d0c2791c601dd *tests/data/lavf/lavf.ismv
 322075 tests/data/lavf/lavf.ismv
 tests/data/lavf/lavf.ismv CRC=0xe8130120
 3b6023766845b51b075aed474c00f73c *tests/data/lavf/lavf.ismv
-- 
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] AVS3: add support for AVS3 High profile - same syntax as AVS3 Main profile

2022-02-26 Thread lance . lmwang
On Sat, Feb 26, 2022 at 07:48:24AM +, Paul Higgs wrote:
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > lance.lmw...@gmail.com
> > Sent: 26 February 2022 07:18
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH] AVS3: add support for AVS3 High profile
> > - same syntax as AVS3 Main profile
> > 
> > On Sat, Feb 26, 2022 at 05:50:39AM +, Paul Higgs wrote:
> > > This patch adds high level syntax support for parsing AVS3 High profile
> > bitstreams.
> > > Latest AVS3 specification including High profile is available at
> > > http://www.avs.org.cn/AVS3_download/en_index.asp
> > >
> > > Signed-off-by: Paul Higgs 
> > > ---
> > >  libavcodec/avs3.h| 2 ++
> > >  libavcodec/avs3_parser.c | 8 
> > >  libavformat/avs3dec.c| 2 +-
> > >  3 files changed, 7 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h index
> > > 4189d9b583..c8caa58b0a 100644
> > > --- a/libavcodec/avs3.h
> > > +++ b/libavcodec/avs3.h
> > > @@ -35,6 +35,8 @@
> > >  #define AVS3_FIRST_SLICE_START_CODE  0x00
> > >  #define AVS3_PROFILE_BASELINE_MAIN   0x20
> > >  #define AVS3_PROFILE_BASELINE_MAIN10 0x22
> > > +#define AVS3_PROFILE_BASELINE_HIGH   0x30
> > > +#define AVS3_PROFILE_BASELINE_HIGH10 0x32
> > >
> > >  #define AVS3_ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) ==
> > > AVS3_INTER_PIC_START_CODE)  #define AVS3_ISUNIT(x) ((x) ==
> > > AVS3_SEQ_START_CODE || AVS3_ISPIC(x)) diff --git
> > > a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c index
> > > d04d96a03a..483b38fe76 100644
> > > --- a/libavcodec/avs3_parser.c
> > > +++ b/libavcodec/avs3_parser.c
> > > @@ -91,11 +91,11 @@ static void
> > parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
> > >  //sampe_precision(3)
> > >  skip_bits(, 47);
> > >
> > > -if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
> > > -int sample_precision = get_bits(, 3);
> > > -if (sample_precision == 1) {
> > > +if (profile == AVS3_PROFILE_BASELINE_MAIN10 || profile ==
> > AVS3_PROFILE_BASELINE_HIGH10) {
> > > +int encoding_precision = get_bits(, 3);
> > > +if (encoding_precision == 1) {
> > 
> > Please keep sample_precision name, it's unrelated cosmetic change in this
> > patch.
> > 
> Changed this because the three bits read in get_bits(,3) are for the 
> encoding precision. sample_precision syntax element was 
> Skipped previously

then I think it's better to fix this in another patch instead of mixed changed.


> > >  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> > > -} else if (sample_precision == 2) {
> > > +} else if (encoding_precision == 2) {
> > >  avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
> > >  } else {
> > >  avctx->pix_fmt = AV_PIX_FMT_NONE; diff --git
> > > a/libavformat/avs3dec.c b/libavformat/avs3dec.c index
> > > 2395df171b..335b5409f5 100644
> > > --- a/libavformat/avs3dec.c
> > > +++ b/libavformat/avs3dec.c
> > > @@ -47,7 +47,7 @@ static int avs3video_probe(const AVProbeData *p)
> > >  }
> > >  if (state == AVS3_SEQ_START_CODE) {
> > >  seq++;
> > > -if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr !=
> > AVS3_PROFILE_BASELINE_MAIN10)
> > > +if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr !=
> > > + AVS3_PROFILE_BASELINE_MAIN10 && *ptr !=
> > AVS3_PROFILE_BASELINE_HIGH
> > > + && *ptr != AVS3_PROFILE_BASELINE_HIGH10)
> > 
> > The line is too long.
> Ok, will wrap before 80 characters
> > 
> > >  return 0;
> > >  } else if (AVS3_ISPIC(state)) {
> > >  pic++;
> > > --
> > > 2.30.0.windows.2
> > >
> > > ___
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > > To unsubscribe, visit link above, or email
> > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> > 
> > --
> > 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] [PATCH] AVS3: add support for AVS3 High profile - same syntax as AVS3 Main profile

2022-02-25 Thread lance . lmwang
On Sat, Feb 26, 2022 at 05:50:39AM +, Paul Higgs wrote:
> This patch adds high level syntax support for parsing AVS3 High profile 
> bitstreams. 
> Latest AVS3 specification including High profile is available at 
> http://www.avs.org.cn/AVS3_download/en_index.asp
> 
> Signed-off-by: Paul Higgs 
> ---
>  libavcodec/avs3.h| 2 ++
>  libavcodec/avs3_parser.c | 8 
>  libavformat/avs3dec.c| 2 +-
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
> index 4189d9b583..c8caa58b0a 100644
> --- a/libavcodec/avs3.h
> +++ b/libavcodec/avs3.h
> @@ -35,6 +35,8 @@
>  #define AVS3_FIRST_SLICE_START_CODE  0x00
>  #define AVS3_PROFILE_BASELINE_MAIN   0x20
>  #define AVS3_PROFILE_BASELINE_MAIN10 0x22
> +#define AVS3_PROFILE_BASELINE_HIGH   0x30
> +#define AVS3_PROFILE_BASELINE_HIGH10 0x32
>  
>  #define AVS3_ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) == 
> AVS3_INTER_PIC_START_CODE)
>  #define AVS3_ISUNIT(x) ((x) == AVS3_SEQ_START_CODE || AVS3_ISPIC(x))
> diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
> index d04d96a03a..483b38fe76 100644
> --- a/libavcodec/avs3_parser.c
> +++ b/libavcodec/avs3_parser.c
> @@ -91,11 +91,11 @@ static void parse_avs3_nal_units(AVCodecParserContext *s, 
> const uint8_t *buf,
>  //sampe_precision(3)
>  skip_bits(, 47);
>  
> -if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
> -int sample_precision = get_bits(, 3);
> -if (sample_precision == 1) {
> +if (profile == AVS3_PROFILE_BASELINE_MAIN10 || profile == 
> AVS3_PROFILE_BASELINE_HIGH10) {
> +int encoding_precision = get_bits(, 3);
> +if (encoding_precision == 1) {

Please keep sample_precision name, it's unrelated cosmetic change in this 
patch. 

>  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> -} else if (sample_precision == 2) {
> +} else if (encoding_precision == 2) {
>  avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
>  } else {
>  avctx->pix_fmt = AV_PIX_FMT_NONE;
> diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
> index 2395df171b..335b5409f5 100644
> --- a/libavformat/avs3dec.c
> +++ b/libavformat/avs3dec.c
> @@ -47,7 +47,7 @@ static int avs3video_probe(const AVProbeData *p)
>  }
>  if (state == AVS3_SEQ_START_CODE) {
>  seq++;
> -if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
> AVS3_PROFILE_BASELINE_MAIN10)
> +if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
> AVS3_PROFILE_BASELINE_MAIN10 && *ptr != AVS3_PROFILE_BASELINE_HIGH && *ptr != 
> AVS3_PROFILE_BASELINE_HIGH10)

The line is too long. 

>  return 0;
>  } else if (AVS3_ISPIC(state)) {
>  pic++;
> -- 
> 2.30.0.windows.2
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
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 1/4] avutil: add support for CUVA HDR Vivid metadata

2022-02-25 Thread lance . lmwang
On Tue, Feb 15, 2022 at 08:08:51AM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavutil/Makefile |   2 +
> >  libavutil/frame.c  |   1 +
> >  libavutil/frame.h  |   7 +
> >  libavutil/hdr_dynamic_vivid_metadata.c |  47 ++
> >  libavutil/hdr_dynamic_vivid_metadata.h | 285 
> > +
> >  libavutil/version.h|   2 +-
> >  6 files changed, 343 insertions(+), 1 deletion(-)
> >  create mode 100644 libavutil/hdr_dynamic_vivid_metadata.c
> >  create mode 100644 libavutil/hdr_dynamic_vivid_metadata.h
> > 
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index d17876d..a8d7587 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -34,6 +34,7 @@ HEADERS = adler32.h   
> >   \
> >frame.h   \
> >hash.h\
> >hdr_dynamic_metadata.h\
> > +  hdr_dynamic_vivid_metadata.h  \
> >hmac.h\
> >hwcontext.h   \
> >hwcontext_cuda.h  \
> > @@ -130,6 +131,7 @@ OBJS = adler32.o
> > \
> > frame.o  \
> > hash.o   \
> > hdr_dynamic_metadata.o   \
> > +   hdr_dynamic_vivid_metadata.o \
> > hmac.o   \
> > hwcontext.o  \
> > imgutils.o   \
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index 8997c85..b035e28 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -723,6 +723,7 @@ const char *av_frame_side_data_name(enum 
> > AVFrameSideDataType type)
> >  case AV_FRAME_DATA_SPHERICAL:   return "Spherical 
> > Mapping";
> >  case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile";
> >  case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
> > SMPTE2094-40 (HDR10+)";
> > +case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata 
> > CUVA 005.1 2021 (Vivid)";
> >  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";
> > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > index 18e239f..32cde3c 100644
> > --- a/libavutil/frame.h
> > +++ b/libavutil/frame.h
> > @@ -158,6 +158,13 @@ enum AVFrameSideDataType {
> >  AV_FRAME_DATA_DYNAMIC_HDR_PLUS,
> >  
> >  /**
> > + * HDR Vivid dynamic metadata associated with a video frame. The 
> > payload is
> > + * an AVDynamicHDRVivid type and contains information for color
> > + * volume transform - CUVA 005.1-2021.
> > + */
> > +AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
> > +
> 
> Always add at the end. You are breaking ABI otherwise.

plan to push the patchset(including of moving the type at the end) in the next 
two day if no other more comments 

> 
> > +/**
> >   * Regions Of Interest, the data is an array of AVRegionOfInterest 
> > type, the number of
> >   * array element is implied by AVFrameSideData.size / 
> > AVRegionOfInterest.self_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 1/4] avutil: add support for CUVA HDR Vivid metadata

2022-02-14 Thread lance . lmwang
On Tue, Feb 15, 2022 at 08:08:51AM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavutil/Makefile |   2 +
> >  libavutil/frame.c  |   1 +
> >  libavutil/frame.h  |   7 +
> >  libavutil/hdr_dynamic_vivid_metadata.c |  47 ++
> >  libavutil/hdr_dynamic_vivid_metadata.h | 285 
> > +
> >  libavutil/version.h|   2 +-
> >  6 files changed, 343 insertions(+), 1 deletion(-)
> >  create mode 100644 libavutil/hdr_dynamic_vivid_metadata.c
> >  create mode 100644 libavutil/hdr_dynamic_vivid_metadata.h
> > 
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index d17876d..a8d7587 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -34,6 +34,7 @@ HEADERS = adler32.h   
> >   \
> >frame.h   \
> >hash.h\
> >hdr_dynamic_metadata.h\
> > +  hdr_dynamic_vivid_metadata.h  \
> >hmac.h\
> >hwcontext.h   \
> >hwcontext_cuda.h  \
> > @@ -130,6 +131,7 @@ OBJS = adler32.o
> > \
> > frame.o  \
> > hash.o   \
> > hdr_dynamic_metadata.o   \
> > +   hdr_dynamic_vivid_metadata.o \
> > hmac.o   \
> > hwcontext.o  \
> > imgutils.o   \
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index 8997c85..b035e28 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -723,6 +723,7 @@ const char *av_frame_side_data_name(enum 
> > AVFrameSideDataType type)
> >  case AV_FRAME_DATA_SPHERICAL:   return "Spherical 
> > Mapping";
> >  case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile";
> >  case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
> > SMPTE2094-40 (HDR10+)";
> > +case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata 
> > CUVA 005.1 2021 (Vivid)";
> >  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";
> > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > index 18e239f..32cde3c 100644
> > --- a/libavutil/frame.h
> > +++ b/libavutil/frame.h
> > @@ -158,6 +158,13 @@ enum AVFrameSideDataType {
> >  AV_FRAME_DATA_DYNAMIC_HDR_PLUS,
> >  
> >  /**
> > + * HDR Vivid dynamic metadata associated with a video frame. The 
> > payload is
> > + * an AVDynamicHDRVivid type and contains information for color
> > + * volume transform - CUVA 005.1-2021.
> > + */
> > +AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
> > +
> 
> Always add at the end. You are breaking ABI otherwise.

Thanks for the comments, will fix it in the next version.

> 
> > +/**
> >   * Regions Of Interest, the data is an array of AVRegionOfInterest 
> > type, the number of
> >   * array element is implied by AVFrameSideData.size / 
> > AVRegionOfInterest.self_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 4/4] fftool/ffprobe: support for CUVA HDR Vivid metadata

2022-02-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 fftools/ffprobe.c | 70 +++
 1 file changed, 70 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 8a8e3de..0e8f1d5 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -38,6 +38,7 @@
 #include "libavutil/hash.h"
 #include "libavutil/hdr_dynamic_metadata.h"
 #include "libavutil/mastering_display_metadata.h"
+#include "libavutil/hdr_dynamic_vivid_metadata.h"
 #include "libavutil/dovi_meta.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -2118,6 +2119,72 @@ static void print_dynamic_hdr10_plus(WriterContext *w, 
const AVDynamicHDRPlus *m
 }
 }
 
+static void print_dynamic_hdr_vivid(WriterContext *w, const AVDynamicHDRVivid 
*metadata)
+{
+if (!metadata)
+return;
+print_int("system_start_code", metadata->system_start_code);
+print_int("num_windows", metadata->num_windows);
+
+for (int n = 0; n < metadata->num_windows; n++) {
+const AVHDRVividColorTransformParams *params = >params[n];
+
+print_q("minimum_maxrgb", params->minimum_maxrgb, '/');
+print_q("average_maxrgb", params->average_maxrgb, '/');
+print_q("variance_maxrgb", params->variance_maxrgb, '/');
+print_q("maximum_maxrgb", params->maximum_maxrgb, '/');
+}
+
+for (int n = 0; n < metadata->num_windows; n++) {
+const AVHDRVividColorTransformParams *params = >params[n];
+
+print_int("tone_mapping_mode_flag", params->tone_mapping_mode_flag);
+print_int("tone_mapping_param_num", params->tone_mapping_param_num);
+if (params->tone_mapping_mode_flag) {
+for (int i = 0; i < params->tone_mapping_param_num; i++) {
+const AVHDRVividColorToneMappingParams *tm_params = 
>tm_params[i];
+
+print_q("targeted_system_display_maximum_luminance",
+tm_params->targeted_system_display_maximum_luminance, 
'/');
+if (tm_params->base_enable_flag) {
+print_q("base_param_m_p", tm_params->base_param_m_p, '/');
+print_q("base_param_m_m", tm_params->base_param_m_m, '/');
+print_q("base_param_m_a", tm_params->base_param_m_a, '/');
+print_q("base_param_m_b", tm_params->base_param_m_b, '/');
+print_q("base_param_m_n", tm_params->base_param_m_n, '/');
+
+print_int("base_param_k1", tm_params->base_param_k1);
+print_int("base_param_k2", tm_params->base_param_k2);
+print_int("base_param_k3", tm_params->base_param_k3);
+print_int("base_param_Delta_enable_mode",
+  tm_params->base_param_Delta_enable_mode);
+print_q("base_param_Delta", tm_params->base_param_Delta, 
'/');
+}
+if (tm_params->three_Spline_flag) {
+print_int("3Spline_num", tm_params->three_Spline_num);
+print_int("3Spline_TH_mode", 
tm_params->three_Spline_TH_mode);
+
+for (int j = 0; j < tm_params->three_Spline_num; j++) {
+print_q("3Spline_TH_enable_MB", 
tm_params->three_Spline_TH_enable_MB, '/');
+print_q("3Spline_TH", tm_params->three_Spline_TH, '/');
+print_q("3Spline_TH_Delta1", 
tm_params->three_Spline_TH_Delta1, '/');
+print_q("3Spline_TH_Delta2", 
tm_params->three_Spline_TH_Delta2, '/');
+print_q("3Spline_enable_Strength", 
tm_params->three_Spline_enable_Strength, '/');
+}
+}
+}
+}
+
+print_int("color_saturation_mapping_flag", 
params->color_saturation_mapping_flag);
+if (params->color_saturation_mapping_flag) {
+print_int("color_saturation_num", params->color_saturation_num);
+for (int i = 0; i < params->color_saturation_num; i++) {
+print_q("color_saturation_gain", 
params->color_saturation_gain[i], '/');
+}
+}
+}
+}
+
 static void print_pkt_side_data(WriterContext *w,
 AVCodecParameters *par,
 const AVPacketSideData *side_data,
@@ -2537,6 +2604,9 @@ static void show_frame(WriterContext *w, AVFrame *frame, 
AVStream *stream,
 print_int("size", sd->size);
 } else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) {
 print_dovi_metadata(w, (const AVDOVIMetadata *)sd->data);
+} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
+AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
+print_dynamic_hdr_vivid(w, metadata);
 }
 writer_print_section_footer(w);
 }
-- 
1.8.3.1

___
ffmpeg-devel mailing 

[FFmpeg-devel] [PATCH 3/4] avfilter: support for CUVA HDR Vivid metadata

2022-02-14 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 71728bc..bee84b2 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -32,6 +32,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/film_grain_params.h"
 #include "libavutil/hdr_dynamic_metadata.h"
+#include "libavutil/hdr_dynamic_vivid_metadata.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/spherical.h"
@@ -307,6 +308,88 @@ static void dump_dynamic_hdr_plus(AVFilterContext *ctx, 
AVFrameSideData *sd)
 }
 }
 
+static void dump_dynamic_hdr_vivid(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+AVDynamicHDRVivid *hdr_vivid;
+
+av_log(ctx, AV_LOG_INFO, "HDR Vivid metadata: ");
+if (sd->size < sizeof(*hdr_vivid)) {
+av_log(ctx, AV_LOG_ERROR, "invalid hdr vivid data\n");
+return;
+}
+
+hdr_vivid = (AVDynamicHDRVivid *)sd->data;
+av_log(ctx, AV_LOG_INFO, "system_start_code: %d, ", 
hdr_vivid->system_start_code);
+av_log(ctx, AV_LOG_INFO, "num_windows: %d, ", hdr_vivid->num_windows);
+for (int w = 0; w < hdr_vivid->num_windows; w++) {
+const AVHDRVividColorTransformParams *params = _vivid->params[w];
+
+av_log(ctx, AV_LOG_INFO, "minimum_maxrgb[%d]: %.4f, ", w, 
av_q2d(params->minimum_maxrgb));
+av_log(ctx, AV_LOG_INFO, "average_maxrgb[%d]: %.4f, ", w, 
av_q2d(params->average_maxrgb));
+av_log(ctx, AV_LOG_INFO, "variance_maxrgb[%d]:%.4f, ", w, 
av_q2d(params->variance_maxrgb));
+av_log(ctx, AV_LOG_INFO, "maximum_maxrgb[%d]: %.4f, ", w, 
av_q2d(params->maximum_maxrgb));
+}
+
+for (int w = 0; w < hdr_vivid->num_windows; w++) {
+const AVHDRVividColorTransformParams *params = _vivid->params[w];
+
+av_log(ctx, AV_LOG_INFO, "tone_mapping_mode_flag[%d]: %d, ", w, 
params->tone_mapping_mode_flag);
+av_log(ctx, AV_LOG_INFO, "tone_mapping_param_num[%d]: %d, ", w, 
params->tone_mapping_param_num);
+if (params->tone_mapping_mode_flag) {
+for (int i = 0; i < params->tone_mapping_param_num; i++) {
+const AVHDRVividColorToneMappingParams *tm_params = 
>tm_params[i];
+
+av_log(ctx, AV_LOG_INFO, 
"targeted_system_display_maximum_luminance[%d][%d]: %.4f, ",
+   w, i, 
av_q2d(tm_params->targeted_system_display_maximum_luminance));
+av_log(ctx, AV_LOG_INFO, "base_enable_flag[%d][%d]: %d, ",
+   w, i, tm_params->base_enable_flag);
+if (tm_params->base_enable_flag) {
+av_log(ctx, AV_LOG_INFO, "base_param_m_p[%d][%d]: %.4f, ", 
w, i, av_q2d(tm_params->base_param_m_p));
+av_log(ctx, AV_LOG_INFO, "base_param_m_m[%d][%d]: %.4f, ", 
w, i, av_q2d(tm_params->base_param_m_m));
+av_log(ctx, AV_LOG_INFO, "base_param_m_a[%d][%d]: %.4f, ", 
w, i, av_q2d(tm_params->base_param_m_a));
+av_log(ctx, AV_LOG_INFO, "base_param_m_b[%d][%d]: %.4f, ", 
w, i, av_q2d(tm_params->base_param_m_b));
+av_log(ctx, AV_LOG_INFO, "base_param_m_n[%d][%d]: %.4f, ", 
w, i, av_q2d(tm_params->base_param_m_n));
+av_log(ctx, AV_LOG_INFO, "base_param_k1[%d][%d]:  %d, ", 
w, i, tm_params->base_param_k1);
+av_log(ctx, AV_LOG_INFO, "base_param_k2[%d][%d]:  %d, ", 
w, i, tm_params->base_param_k2);
+av_log(ctx, AV_LOG_INFO, "base_param_k3[%d][%d]:  %d, ", 
w, i, tm_params->base_param_k3);
+av_log(ctx, AV_LOG_INFO, 
"base_param_Delta_enable_mode[%d][%d]: %d, ", w, i,
+   tm_params->base_param_Delta_enable_mode);
+av_log(ctx, AV_LOG_INFO, "base_param_Delta[%d][%d]: %.4f, 
", w, i, av_q2d(tm_params->base_param_Delta));
+}
+if (tm_params->three_Spline_flag) {
+av_log(ctx, AV_LOG_INFO, "3Spline_flag[%d][%d]:  %d, ", w, 
i, tm_params->three_Spline_flag);
+av_log(ctx, AV_LOG_INFO, "3Spline_TH_mode[%d][%d]:  %d, ", 
w, i, tm_params->three_Spline_TH_mode);
+
+for (int j = 0; j < tm_params->three_Spline_num; j++) {
+av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_enable_MB[%d][%d][%d]: %.4f, ",
+w, i, j, 
av_q2d(tm_params->three_Spline_TH_enable_MB));
+av_log(ctx, AV_LOG_INFO, "3Spline_TH[%d][%d][%d]: 
%.4f, ",
+w, i, j, av_q2d(tm_params->three_Spline_TH));
+av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_Delta1[%d][%d][%d]: %.4f, ",
+w, i, j, 
av_q2d(tm_params->three_Spline_TH_Delta1));
+av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_Delta2[%d][%d][%d]: %.4f, ",
+   

[FFmpeg-devel] [PATCH 2/4] avcodec: support for CUVA HDR Vivid metadata

2022-02-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/Makefile|   2 +-
 libavcodec/dynamic_hdr_vivid.c | 139 +
 libavcodec/dynamic_hdr_vivid.h |  35 +++
 libavcodec/hevc_sei.c  |  48 +-
 libavcodec/hevc_sei.h  |   5 ++
 libavcodec/hevcdec.c   |  15 +
 6 files changed, 241 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/dynamic_hdr_vivid.c
 create mode 100644 libavcodec/dynamic_hdr_vivid.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cfc70a3..1910137 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -96,7 +96,7 @@ OBJS-$(CONFIG_H264PARSE)   += h264_parse.o 
h2645_parse.o h264_ps.o
 OBJS-$(CONFIG_H264PRED)+= h264pred.o
 OBJS-$(CONFIG_H264QPEL)+= h264qpel.o
 OBJS-$(CONFIG_HEVCPARSE)   += hevc_parse.o h2645_parse.o hevc_ps.o 
hevc_sei.o hevc_data.o \
-  dynamic_hdr10_plus.o
+  dynamic_hdr10_plus.o 
dynamic_hdr_vivid.o
 OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
 OBJS-$(CONFIG_HUFFMAN) += huffman.o
 OBJS-$(CONFIG_HUFFYUVDSP)  += huffyuvdsp.o
diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
new file mode 100644
index 000..7d0bd43
--- /dev/null
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -0,0 +1,139 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "dynamic_hdr_vivid.h"
+#include "get_bits.h"
+
+static const int32_t maxrgb_den = 4095;
+static const int32_t color_saturation_gain_den = 128;
+static const int32_t maximum_luminance_den = 4095;
+static const int32_t base_param_m_p_den = 16383;
+static const int32_t base_param_m_m_den = 10;
+static const int32_t base_param_m_a_den = 1023;
+static const int32_t base_param_m_b_den = 1023;
+static const int32_t base_param_m_n_den = 10;
+static const int32_t base_param_Delta_den = 127;
+
+int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const 
uint8_t *data,
+ int size)
+{
+GetBitContext gbc, *gb = 
+int ret;
+
+if (!s)
+return AVERROR(ENOMEM);
+
+ret = init_get_bits8(gb, data, size);
+if (ret < 0)
+return ret;
+
+if (get_bits_left(gb) < 8)
+return AVERROR_INVALIDDATA;
+
+s->system_start_code = get_bits(gb, 8);
+if (s->system_start_code == 0x01) {
+s->num_windows = 1;
+
+if (get_bits_left(gb) < 12 * 4 * s->num_windows)
+return AVERROR_INVALIDDATA;
+for (int w = 0; w < s->num_windows; w++) {
+AVHDRVividColorTransformParams *params = >params[w];
+
+params->minimum_maxrgb  = (AVRational){get_bits(gb, 12), 
maxrgb_den};
+params->average_maxrgb  = (AVRational){get_bits(gb, 12), 
maxrgb_den};
+params->variance_maxrgb = (AVRational){get_bits(gb, 12), 
maxrgb_den};
+params->maximum_maxrgb  = (AVRational){get_bits(gb, 12), 
maxrgb_den};
+}
+
+if (get_bits_left(gb) < 2 * s->num_windows)
+return AVERROR_INVALIDDATA;
+for (int w = 0; w < s->num_windows; w++) {
+AVHDRVividColorTransformParams *params = >params[w];
+
+params->tone_mapping_mode_flag = get_bits(gb, 1);
+if (params->tone_mapping_mode_flag) {
+if (get_bits_left(gb) < 1 )
+return AVERROR_INVALIDDATA;
+params->tone_mapping_param_num = get_bits(gb, 1) + 1;
+for (int i = 0; i < params->tone_mapping_param_num; i++) {
+AVHDRVividColorToneMappingParams *tm_params = 
>tm_params[i];
+
+if (get_bits_left(gb) < 13)
+return AVERROR_INVALIDDATA;
+tm_params->targeted_system_display_maximum_luminance = 
(AVRational){get_bits(gb, 12), maximum_luminance_den};
+tm_params->base_enable_flag = get_bits(gb, 1);
+if (tm_params->base_enable_flag) {
+if (get_bits_left(gb) < (14 + 6 + 10 + 10 + 6 + 8 + 
10))
+return AVERROR_INVALIDDATA;
+  

[FFmpeg-devel] [PATCH 1/4] avutil: add support for CUVA HDR Vivid metadata

2022-02-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavutil/Makefile |   2 +
 libavutil/frame.c  |   1 +
 libavutil/frame.h  |   7 +
 libavutil/hdr_dynamic_vivid_metadata.c |  47 ++
 libavutil/hdr_dynamic_vivid_metadata.h | 285 +
 libavutil/version.h|   2 +-
 6 files changed, 343 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/hdr_dynamic_vivid_metadata.c
 create mode 100644 libavutil/hdr_dynamic_vivid_metadata.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index d17876d..a8d7587 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -34,6 +34,7 @@ HEADERS = adler32.h   
  \
   frame.h   \
   hash.h\
   hdr_dynamic_metadata.h\
+  hdr_dynamic_vivid_metadata.h  \
   hmac.h\
   hwcontext.h   \
   hwcontext_cuda.h  \
@@ -130,6 +131,7 @@ OBJS = adler32.o
\
frame.o  \
hash.o   \
hdr_dynamic_metadata.o   \
+   hdr_dynamic_vivid_metadata.o \
hmac.o   \
hwcontext.o  \
imgutils.o   \
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 8997c85..b035e28 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -723,6 +723,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_SPHERICAL:   return "Spherical Mapping";
 case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile";
 case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
SMPTE2094-40 (HDR10+)";
+case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata CUVA 
005.1 2021 (Vivid)";
 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";
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 18e239f..32cde3c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -158,6 +158,13 @@ enum AVFrameSideDataType {
 AV_FRAME_DATA_DYNAMIC_HDR_PLUS,
 
 /**
+ * HDR Vivid dynamic metadata associated with a video frame. The payload is
+ * an AVDynamicHDRVivid type and contains information for color
+ * volume transform - CUVA 005.1-2021.
+ */
+AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
+
+/**
  * Regions Of Interest, the data is an array of AVRegionOfInterest type, 
the number of
  * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
  */
diff --git a/libavutil/hdr_dynamic_vivid_metadata.c 
b/libavutil/hdr_dynamic_vivid_metadata.c
new file mode 100644
index 000..32da01f
--- /dev/null
+++ b/libavutil/hdr_dynamic_vivid_metadata.c
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2021 Limin Wang 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "hdr_dynamic_vivid_metadata.h"
+#include "mem.h"
+
+AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size)
+{
+AVDynamicHDRVivid *hdr_vivid = av_mallocz(sizeof(AVDynamicHDRVivid));
+if (!hdr_vivid)
+return NULL;
+
+if (size)
+*size = sizeof(*hdr_vivid);
+
+return hdr_vivid;
+}
+
+AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+

Re: [FFmpeg-devel] [patch] libavcodec/videotoolbox.c : fix missing AVCodecInternal

2022-02-14 Thread lance . lmwang
On Mon, Feb 14, 2022 at 11:05:58AM +0100, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > On Mon, Feb 14, 2022 at 08:27:39AM +0100, Pascal Massimino wrote:
> >> attached. Just a missing include.
> > 
> > I have submit a patch for it already, if you think it's OK, I can push it 
> > soon.
> > 
> 
> I have already pushed your patch.

yeah, haven't notice that, 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".

-- 
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] libavcodec/videotoolbox.c : fix missing AVCodecInternal

2022-02-14 Thread lance . lmwang
On Mon, Feb 14, 2022 at 08:27:39AM +0100, Pascal Massimino wrote:
> attached. Just a missing include.

I have submit a patch for it already, if you think it's OK, I can push it soon.

> 
> skal/


> ___
> 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] avcodec/videotoolbox: add internal.h for header depenedency

2022-02-13 Thread lance . lmwang
From: Limin Wang 

Fixes build failures for videotoolbox

Signed-off-by: Limin Wang 
---
 libavcodec/videotoolbox.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 51d4eac..29c781c 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -29,6 +29,7 @@
 #include "libavutil/pixdesc.h"
 #include "bytestream.h"
 #include "decode.h"
+#include "internal.h"
 #include "h264dec.h"
 #include "hevcdec.h"
 #include "mpegvideo.h"
-- 
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 v3 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-11 Thread lance . lmwang
On Fri, Feb 11, 2022 at 10:05:19PM +0100, Marton Balint wrote:
> 
> 
> On Sat, 5 Feb 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Suggested by zhilizhao, vlc project has solved the compatibility by
> > the same way, so I borrowed the comments from vlc project.
> > 
> > Fix #ticket9449
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/udp.c | 15 +--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 8178d0e..1871acf 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> > {
> > int protocol, cmd;
> > 
> > +/* There is some confusion in the world whether IP_MULTICAST_TTL
> > + * takes a byte or an int as an argument.
> > + * BSD seems to indicate byte so we are going with that and use
> > + * int and fall back to byte to be safe */
> > switch (addr->sa_family) {
> > #ifdef IP_MULTICAST_TTL
> > case AF_INET:
> > @@ -182,8 +186,15 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> > }
> > 
> > if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) 
> > {
> > -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 
> > MULTICAST TTL)");
> > -return ff_neterrno();
> > +/* BSD compatibility */
> > +unsigned char ttl;
> > +
> > +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 
> > MULTICAST TTL)");
> > +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
> 
> I guess this limit check here is no longer needed after the range checking
> patches, so just remove. Otherwise LGTM.

Yes, I have replied to Chad Fraleigh in another email and have removed the 
check already.

> 
> Thanks,
> Marton
> 
> > +if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
> > +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 
> > MULTICAST TTL)");
> > +return ff_neterrno();
> > +}
> > }
> > 
> > return 0;
> > -- 
> > 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 v3 1/3] avformat/udp: use one setsockopt for ipv4/ipv6

2022-02-10 Thread lance . lmwang
On Sat, Feb 05, 2022 at 08:31:46PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/udp.c | 32 
>  1 file changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 83c042d..8178d0e 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -162,22 +162,30 @@ static int udp_set_multicast_ttl(int sockfd, int 
> mcastTTL,
>   struct sockaddr *addr,
>   void *logctx)
>  {
> +int protocol, cmd;
> +
> +switch (addr->sa_family) {
>  #ifdef IP_MULTICAST_TTL
> -if (addr->sa_family == AF_INET) {
> -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> sizeof(mcastTTL)) < 0) {
> -ff_log_net_error(logctx, AV_LOG_ERROR, 
> "setsockopt(IP_MULTICAST_TTL)");
> -return ff_neterrno();
> -}
> -}
> +case AF_INET:
> +protocol = IPPROTO_IP;
> +cmd  = IP_MULTICAST_TTL;
> +break;
>  #endif
>  #if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
> -if (addr->sa_family == AF_INET6) {
> -if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, , 
> sizeof(mcastTTL)) < 0) {
> -ff_log_net_error(logctx, AV_LOG_ERROR, 
> "setsockopt(IPV6_MULTICAST_HOPS)");
> -return ff_neterrno();
> -}
> -}
> +case AF_INET6:
> +protocol = IPPROTO_IPV6;
> +cmd  = IPV6_MULTICAST_HOPS;
> +break;
>  #endif
> +default:
> +return 0;
> +}
> +
> +if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) {
> +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 
> MULTICAST TTL)");
> +return ff_neterrno();
> +}
> +
>  return 0;
>  }
>  
> -- 
> 1.8.3.1
> 

will apply tomorrow with one pending ttl range check patch if no further 
comments.

-- 
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] avformat/udp: properly check for valid ttl in url

2022-02-07 Thread lance . lmwang
From: Limin Wang 

Zhao Zhili added a ttl upper bound in commit 9daac85da8,
but the check for ttl in url is missing still.

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index da56c8e..401d9b6 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -674,6 +674,11 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 }
 if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
 s->ttl = strtol(buf, NULL, 10);
+if (s->ttl < 0 || s->ttl > 255) {
+av_log(h, AV_LOG_ERROR, "ttl(%d) should be in range 
[0,255]\n", s->ttl);
+ret = AVERROR(EINVAL);
+goto fail;
+}
 }
 if (av_find_info_tag(buf, sizeof(buf), "udplite_coverage", p)) {
 s->udplite_coverage = strtol(buf, NULL, 10);
-- 
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 v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-06 Thread lance . lmwang
On Sun, Feb 06, 2022 at 02:27:09PM -0800, Chad Fraleigh wrote:
> 
> On 2/5/2022 6:09 PM, lance.lmw...@gmail.com wrote:
> > On Sat, Feb 05, 2022 at 01:26:18PM -0800, Chad Fraleigh wrote:
> >> Since any [valid] value over 255 is impossible in the IPv4 protocol (the 
> >> TTL field is only 8-bits), it should always be capped at 255 (for 
> >> consistency) or return an invalid value error (the one I would suggest).
> >>
> > 
> > zhilizhao have submit a patch to limit the range of ttl from option. Do you 
> > want
> > to return an invalid error here still?
> 
> If it can never be called with an invalid value, not even programmatically if 
> someone links against the ffmpeg libs, then checking it is unneeded. But also 
> checking it to limit the unsigned char value would be redundant, so only the 
> value cast would be needed, i.e.:
> 
>ttl = (unsigned char) mcastTTL;

Yes, checking is unneeded anymore, I'll remove it locally.

> 
> 
> If however, it could be called without being first limited, then returning an 
> error would be best to avoid silently having unexpected results. Also, 
> checking that it isn't negative should be done in that case. Not counting 
> pending patches, I only see udp_open() calls it, so if it's already bound in 
> there, no extra checks are needed.

Sure, the patch will be applied after the pending patches for limit anyway if
nobody have other comments.

> 
> Of course, these are only suggestions, since I'm a nobody. =)
> 
> 
> >> Despite VLC's reversed comment, using an int seems to be the exception to 
> >> the rule (i.e. only linux and windows seem to use it [as-documented]), 
> >> perhaps doing the unsigned char first and using the int as the fallback 
> >> would be better? It's not really just a BSD thing, unless you also count 
> >> LWIP and Solaris as BSD. Unless VLC's code history shows them doing it 
> >> this way at one time and swapping it (but forgetting the comment) to fix a 
> >> known bug?
> >>
> > 
> > I have blamed vlc code and sure the code doing it this way at one 
> > time(104938796a3). 
> > For the mismatch of code and comments, I prefer to code always as code were 
> > build 
> > and used by all kinds of system which vlc is supported already. 
> > 
> > As for use BSD, I prefer to count LWIP and Solaris into BSD category which 
> > using
> > rule of byte. If you still prefer to add them into comments, I'm OK also. 
> > 
> >>
> >> On 2/4/2022 9:28 PM, lance.lmw...@gmail.com wrote:
> >>> From: Limin Wang 
> >>>
> >>> Suggested by zhilizhao, vlc project has solved the compatibility by
> >>> the same way, so I borrowed the comments from vlc project.
> >>>
> >>> Fix #ticket9449
> >>>
> >>> Signed-off-by: Limin Wang 
> >>> ---
> >>>  libavformat/udp.c | 15 +--
> >>>  1 file changed, 13 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/libavformat/udp.c b/libavformat/udp.c
> >>> index 3dc79eb..34488d6 100644
> >>> --- a/libavformat/udp.c
> >>> +++ b/libavformat/udp.c
> >>> @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int 
> >>> mcastTTL,
> >>>  {
> >>>  int protocol, cmd;
> >>>  
> >>> +/* There is some confusion in the world whether IP_MULTICAST_TTL
> >>> + * takes a byte or an int as an argument.
> >>> + * BSD seems to indicate byte so we are going with that and use
> >>> + * int as a fallback to be safe */
> >>>  switch (addr->sa_family) {
> >>>  #ifdef IP_MULTICAST_TTL
> >>>  case AF_INET:
> >>> @@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int 
> >>> mcastTTL,
> >>>  }
> >>>  
> >>>  if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 
> >>> 0) {
> >>> -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> >>> -return ff_neterrno();
> >>> +/* BSD compatibility */
> >>> +unsigned char ttl;
> >>> +
> >>> +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt");
> >>> +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
> >>> +if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
> >>> +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> >>> +return ff_neterrno();
> >>> +}
> >>>  }
> >>>  
> >>>  return 0;
> >> ___
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> > 
> ___
> ffmpeg-devel 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 

Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-05 Thread lance . lmwang
On Sat, Feb 05, 2022 at 01:26:18PM -0800, Chad Fraleigh wrote:
> Since any [valid] value over 255 is impossible in the IPv4 protocol (the TTL 
> field is only 8-bits), it should always be capped at 255 (for consistency) or 
> return an invalid value error (the one I would suggest).
> 

zhilizhao have submit a patch to limit the range of ttl from option. Do you want
to return an invalid error here still?


> Despite VLC's reversed comment, using an int seems to be the exception to the 
> rule (i.e. only linux and windows seem to use it [as-documented]), perhaps 
> doing the unsigned char first and using the int as the fallback would be 
> better? It's not really just a BSD thing, unless you also count LWIP and 
> Solaris as BSD. Unless VLC's code history shows them doing it this way at one 
> time and swapping it (but forgetting the comment) to fix a known bug?
> 

I have blamed vlc code and sure the code doing it this way at one 
time(104938796a3). 
For the mismatch of code and comments, I prefer to code always as code were 
build 
and used by all kinds of system which vlc is supported already. 

As for use BSD, I prefer to count LWIP and Solaris into BSD category which using
rule of byte. If you still prefer to add them into comments, I'm OK also. 

> 
> On 2/4/2022 9:28 PM, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Suggested by zhilizhao, vlc project has solved the compatibility by
> > the same way, so I borrowed the comments from vlc project.
> > 
> > Fix #ticket9449
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/udp.c | 15 +--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 3dc79eb..34488d6 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> >  {
> >  int protocol, cmd;
> >  
> > +/* There is some confusion in the world whether IP_MULTICAST_TTL
> > + * takes a byte or an int as an argument.
> > + * BSD seems to indicate byte so we are going with that and use
> > + * int as a fallback to be safe */
> >  switch (addr->sa_family) {
> >  #ifdef IP_MULTICAST_TTL
> >  case AF_INET:
> > @@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> >  }
> >  
> >  if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 
> > 0) {
> > -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> > -return ff_neterrno();
> > +/* BSD compatibility */
> > +unsigned char ttl;
> > +
> > +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt");
> > +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
> > +if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
> > +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> > +return ff_neterrno();
> > +}
> >  }
> >  
> >  return 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".

-- 
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 v3 3/3] avformat/udp: remove IPPROTO_IPV6 macro

2022-02-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 1871acf..9f6ab1b 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -175,7 +175,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 cmd  = IP_MULTICAST_TTL;
 break;
 #endif
-#if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
+#ifdef IPV6_MULTICAST_HOPS
 case AF_INET6:
 protocol = IPPROTO_IPV6;
 cmd  = IPV6_MULTICAST_HOPS;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v3 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-05 Thread lance . lmwang
From: Limin Wang 

Suggested by zhilizhao, vlc project has solved the compatibility by
the same way, so I borrowed the comments from vlc project.

Fix #ticket9449

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 8178d0e..1871acf 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 {
 int protocol, cmd;
 
+/* There is some confusion in the world whether IP_MULTICAST_TTL
+ * takes a byte or an int as an argument.
+ * BSD seems to indicate byte so we are going with that and use
+ * int and fall back to byte to be safe */
 switch (addr->sa_family) {
 #ifdef IP_MULTICAST_TTL
 case AF_INET:
@@ -182,8 +186,15 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 }
 
 if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) {
-ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST 
TTL)");
-return ff_neterrno();
+/* BSD compatibility */
+unsigned char ttl;
+
+ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 MULTICAST 
TTL)");
+ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
+if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
+ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 
MULTICAST TTL)");
+return ff_neterrno();
+}
 }
 
 return 0;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v3 1/3] avformat/udp: use one setsockopt for ipv4/ipv6

2022-02-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 83c042d..8178d0e 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -162,22 +162,30 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
  struct sockaddr *addr,
  void *logctx)
 {
+int protocol, cmd;
+
+switch (addr->sa_family) {
 #ifdef IP_MULTICAST_TTL
-if (addr->sa_family == AF_INET) {
-if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(mcastTTL)) < 0) {
-ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IP_MULTICAST_TTL)");
-return ff_neterrno();
-}
-}
+case AF_INET:
+protocol = IPPROTO_IP;
+cmd  = IP_MULTICAST_TTL;
+break;
 #endif
 #if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
-if (addr->sa_family == AF_INET6) {
-if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, , 
sizeof(mcastTTL)) < 0) {
-ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IPV6_MULTICAST_HOPS)");
-return ff_neterrno();
-}
-}
+case AF_INET6:
+protocol = IPPROTO_IPV6;
+cmd  = IPV6_MULTICAST_HOPS;
+break;
 #endif
+default:
+return 0;
+}
+
+if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) {
+ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST 
TTL)");
+return ff_neterrno();
+}
+
 return 0;
 }
 
-- 
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 v2 1/3] avformat/udp: use one setsockopt for ipv4/ipv6

2022-02-05 Thread lance . lmwang
On Sat, Feb 05, 2022 at 10:58:08AM +0100, Marton Balint wrote:
> 
> 
> On Sat, 5 Feb 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/udp.c | 31 ---
> > 1 file changed, 20 insertions(+), 11 deletions(-)
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 83c042d..3dc79eb 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -162,22 +162,31 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> >  struct sockaddr *addr,
> >  void *logctx)
> > {
> > +int protocol, cmd;
> > +
> > +switch (addr->sa_family) {
> > #ifdef IP_MULTICAST_TTL
> > -if (addr->sa_family == AF_INET) {
> > -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(mcastTTL)) < 0) {
> > -ff_log_net_error(logctx, AV_LOG_ERROR, 
> > "setsockopt(IP_MULTICAST_TTL)");
> > -return ff_neterrno();
> > -}
> > -}
> > +case AF_INET:
> > +protocol = IPPROTO_IP;
> > +cmd  = IP_MULTICAST_TTL;
> > +break;
> > #endif
> > #if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
> > -if (addr->sa_family == AF_INET6) {
> > -if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, 
> > , sizeof(mcastTTL)) < 0) {
> > -ff_log_net_error(logctx, AV_LOG_ERROR, 
> > "setsockopt(IPV6_MULTICAST_HOPS)");
> > +case AF_INET6:
> > +protocol = IPPROTO_IPV6;
> > +cmd  = IPV6_MULTICAST_HOPS;
> > +break;
> > +#endif
> > +default:
> > +errno = EAFNOSUPPORT;
> 
> This is not portable, ff_neterrno is different for winsock. Maybe you should
> simply remove the default case, to make it work like the old code, and not
> mix behaviour changes with factorization.

OK, will remove the default case to same with old code.

> 
> > return ff_neterrno();
> > -}
> > }
> > -#endif
> > +
> > +if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 
> > 0) {
> > +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> 
> "setsockopt(IPV4/IPV6 MULTICAST TTL)", so we know that the issue was with
> TTL setting?

Sure, it looks better. will update the patch.

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

-- 
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 v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-05 Thread lance . lmwang
On Sat, Feb 05, 2022 at 10:59:55AM +0100, Marton Balint wrote:
> 
> 
> On Sat, 5 Feb 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Suggested by zhilizhao, vlc project has solved the compatibility by
> > the same way, so I borrowed the comments from vlc project.
> > 
> > Fix #ticket9449
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/udp.c | 15 +--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 3dc79eb..34488d6 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> > {
> > int protocol, cmd;
> > 
> > +/* There is some confusion in the world whether IP_MULTICAST_TTL
> > + * takes a byte or an int as an argument.
> > + * BSD seems to indicate byte so we are going with that and use
> > + * int as a fallback to be safe */
> 
> The code does the opposite. Tries int and falls back to byte. Either change
> code or change comment.

Yes, good catch, so vlc use wrong comments. I'll change comments like below.
+ * BSD seems to indicate byte so we are going with that and tries
+ * int and falls back to byte to be safe */

> 
> Regards,
> Marton
> 
> > switch (addr->sa_family) {
> > #ifdef IP_MULTICAST_TTL
> > case AF_INET:
> > @@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> > }
> > 
> > if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) 
> > {
> > -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> > -return ff_neterrno();
> > +/* BSD compatibility */
> > +unsigned char ttl;
> > +
> > +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt");
> > +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
> > +if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
> > +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> > +return ff_neterrno();
> > +}
> > }
> > 
> > return 0;
> > -- 
> > 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".


[FFmpeg-devel] [PATCH v2 3/3] avformat/udp: remove IPPROTO_IPV6 macro

2022-02-04 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 34488d6..0b078d4 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -175,7 +175,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 cmd  = IP_MULTICAST_TTL;
 break;
 #endif
-#if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
+#ifdef IPV6_MULTICAST_HOPS
 case AF_INET6:
 protocol = IPPROTO_IPV6;
 cmd  = IPV6_MULTICAST_HOPS;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-04 Thread lance . lmwang
From: Limin Wang 

Suggested by zhilizhao, vlc project has solved the compatibility by
the same way, so I borrowed the comments from vlc project.

Fix #ticket9449

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 3dc79eb..34488d6 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 {
 int protocol, cmd;
 
+/* There is some confusion in the world whether IP_MULTICAST_TTL
+ * takes a byte or an int as an argument.
+ * BSD seems to indicate byte so we are going with that and use
+ * int as a fallback to be safe */
 switch (addr->sa_family) {
 #ifdef IP_MULTICAST_TTL
 case AF_INET:
@@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 }
 
 if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) {
-ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
-return ff_neterrno();
+/* BSD compatibility */
+unsigned char ttl;
+
+ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt");
+ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
+if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
+ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
+return ff_neterrno();
+}
 }
 
 return 0;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 1/3] avformat/udp: use one setsockopt for ipv4/ipv6

2022-02-04 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 31 ---
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 83c042d..3dc79eb 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -162,22 +162,31 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
  struct sockaddr *addr,
  void *logctx)
 {
+int protocol, cmd;
+
+switch (addr->sa_family) {
 #ifdef IP_MULTICAST_TTL
-if (addr->sa_family == AF_INET) {
-if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(mcastTTL)) < 0) {
-ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IP_MULTICAST_TTL)");
-return ff_neterrno();
-}
-}
+case AF_INET:
+protocol = IPPROTO_IP;
+cmd  = IP_MULTICAST_TTL;
+break;
 #endif
 #if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
-if (addr->sa_family == AF_INET6) {
-if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, , 
sizeof(mcastTTL)) < 0) {
-ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IPV6_MULTICAST_HOPS)");
+case AF_INET6:
+protocol = IPPROTO_IPV6;
+cmd  = IPV6_MULTICAST_HOPS;
+break;
+#endif
+default:
+errno = EAFNOSUPPORT;
 return ff_neterrno();
-}
 }
-#endif
+
+if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) {
+ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
+return ff_neterrno();
+}
+
 return 0;
 }
 
-- 
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] avformat/rtpdec_rfc4175: fix interlace format

2022-02-04 Thread lance . lmwang
On Wed, Feb 02, 2022 at 03:45:10PM -0500, Patrick Keroulas wrote:
> In previous state, a new frame was allocated on each timestamp step,
> i.e. each frame/field transition. However, for interlace, a new frame
> should be allocated on 1st field, completed with the 2nd and finally
> freed.
> 
> This commit fixes the frame allocation and the detection of missing RTP
> markers.
> 
> Signed-off-by: Patrick Keroulas 
> ---
>  libavformat/rtpdec_rfc4175.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
> index 8e73c07838..83abe499f8 100644
> --- a/libavformat/rtpdec_rfc4175.c
> +++ b/libavformat/rtpdec_rfc4175.c
> @@ -234,20 +234,21 @@ static int rfc4175_handle_packet(AVFormatContext *ctx, 
> PayloadContext *data,
>  uint8_t *dest;
>  
>  if (*timestamp != data->timestamp) {
> -if (data->frame) {
> +if (data->frame && (!data->interlaced || data->field)) {
>  /*
> - * if we're here, it means that two RTP packets didn't have the
> - * same timestamp, which is a sign that they were packets from 
> two
> - * different frames, but we didn't get the flag RTP_FLAG_MARKER 
> on
> - * the first one of these frames (last packet of a frame).
> - * Finalize the previous frame anyway by filling the AVPacket.
> + * if we're here, it means that we missed the cue to return
> + * the previous AVPacket, that cue being the RTP_FLAG_MARKER
> + * in the last packet of either the previous frame (progressive)
> + * or the previous second field (interlace). Let's finalize the
> + * previous frame (or pair of fields) anyway by filling the 
> AVPacket.
>   */
>  av_log(ctx, AV_LOG_ERROR, "Missed previous RTP Marker\n");
>  missed_last_packet = 1;
>  rfc4175_finalize_packet(data, pkt, st->index);
>  }
>  
> -data->frame = av_malloc(data->frame_size);
> +if (!data->frame)
> +data->frame = av_malloc(data->frame_size);
>  
>  data->timestamp = *timestamp;
>  
> -- 
> 2.25.1
> 

applied, thanks.


-- 
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] avformat/rtpdec_rfc4175: fix interlace format

2022-02-03 Thread lance . lmwang
On Wed, Feb 02, 2022 at 03:45:10PM -0500, Patrick Keroulas wrote:
> In previous state, a new frame was allocated on each timestamp step,
> i.e. each frame/field transition. However, for interlace, a new frame
> should be allocated on 1st field, completed with the 2nd and finally
> freed.
> 
> This commit fixes the frame allocation and the detection of missing RTP
> markers.
> 
> Signed-off-by: Patrick Keroulas 
> ---
>  libavformat/rtpdec_rfc4175.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
> index 8e73c07838..83abe499f8 100644
> --- a/libavformat/rtpdec_rfc4175.c
> +++ b/libavformat/rtpdec_rfc4175.c
> @@ -234,20 +234,21 @@ static int rfc4175_handle_packet(AVFormatContext *ctx, 
> PayloadContext *data,
>  uint8_t *dest;
>  
>  if (*timestamp != data->timestamp) {
> -if (data->frame) {
> +if (data->frame && (!data->interlaced || data->field)) {
>  /*
> - * if we're here, it means that two RTP packets didn't have the
> - * same timestamp, which is a sign that they were packets from 
> two
> - * different frames, but we didn't get the flag RTP_FLAG_MARKER 
> on
> - * the first one of these frames (last packet of a frame).
> - * Finalize the previous frame anyway by filling the AVPacket.
> + * if we're here, it means that we missed the cue to return
> + * the previous AVPacket, that cue being the RTP_FLAG_MARKER
> + * in the last packet of either the previous frame (progressive)
> + * or the previous second field (interlace). Let's finalize the
> + * previous frame (or pair of fields) anyway by filling the 
> AVPacket.
>   */
>  av_log(ctx, AV_LOG_ERROR, "Missed previous RTP Marker\n");
>  missed_last_packet = 1;
>  rfc4175_finalize_packet(data, pkt, st->index);
>  }
>  
> -data->frame = av_malloc(data->frame_size);
> +if (!data->frame)
> +data->frame = av_malloc(data->frame_size);
>  
>  data->timestamp = *timestamp;

LGTM 

>  
> -- 
> 2.25.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 3/3] avformat/dashdec: avoid calling strlen multiple times

2022-01-29 Thread lance . lmwang
On Mon, Jan 24, 2022 at 11:48:22AM +0800, Steven Liu wrote:
>  于2022年1月23日周日 11:52写道:
> >
> > From: Limin Wang 
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/dashdec.c | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> > index 0d21989..211d77f 100644
> > --- a/libavformat/dashdec.c
> > +++ b/libavformat/dashdec.c
> > @@ -403,6 +403,7 @@ static int open_url(AVFormatContext *s, AVIOContext 
> > **pb, const char *url,
> >  DASHContext *c = s->priv_data;
> >  AVDictionary *tmp = NULL;
> >  const char *proto_name = NULL;
> > +int proto_name_len;
> >  int ret;
> >
> >  if (av_strstart(url, "crypto", NULL)) {
> > @@ -416,6 +417,7 @@ static int open_url(AVFormatContext *s, AVIOContext 
> > **pb, const char *url,
> >  if (!proto_name)
> >  return AVERROR_INVALIDDATA;
> >
> > +proto_name_len = strlen(proto_name);
> >  // only http(s) & file are allowed
> >  if (av_strstart(proto_name, "file", NULL)) {
> >  if (strcmp(c->allowed_extensions, "ALL") && !av_match_ext(url, 
> > c->allowed_extensions)) {
> > @@ -430,9 +432,9 @@ static int open_url(AVFormatContext *s, AVIOContext 
> > **pb, const char *url,
> >  } else
> >  return AVERROR_INVALIDDATA;
> >
> > -if (!strncmp(proto_name, url, strlen(proto_name)) && 
> > url[strlen(proto_name)] == ':')
> > +if (!strncmp(proto_name, url, proto_name_len) && url[proto_name_len] 
> > == ':')
> >  ;
> > -else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url 
> > + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] == ':')
> > +else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url 
> > + 7, proto_name_len) && url[7 + proto_name_len] == ':')
> >  ;
> >  else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
> >  return AVERROR_INVALIDDATA;
> > --
> > 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".
> 
> lgtm

thanks, will push the patch set tomorrow if no other comments.

> 
> 
> Thanks

-- 
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] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-01-26 Thread lance . lmwang
From: Limin Wang 

Fix #ticket9449
Signed-off-by: Limin Wang 
---
Make it as real patch so that you can test it easily as I don't have BSD system 
for testing.

 libavformat/udp.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 83c042d..a52a489 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -163,8 +163,15 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
  void *logctx)
 {
 #ifdef IP_MULTICAST_TTL
+int ret = 0;
 if (addr->sa_family == AF_INET) {
-if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(mcastTTL)) < 0) {
+ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(mcastTTL));
+if (ret < 0 && errno == EINVAL) {
+/* BSD compatibility */
+unsigned char ttl = (unsigned char) ((mcastTTL > 255) ? 255 : 
mcastTTL);
+ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(ttl));
+}
+if (ret < 0) {
 ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IP_MULTICAST_TTL)");
 return ff_neterrno();
 }
-- 
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] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-26 Thread lance . lmwang
On Thu, Jan 27, 2022 at 10:30:10AM +0800, "zhilizhao(赵志立)" wrote:
> 
> 
> > On Jan 27, 2022, at 9:59 AM, lance.lmw...@gmail.com wrote:
> > 
> > On Wed, Jan 26, 2022 at 09:50:47PM +0100, Marton Balint wrote:
> >> 
> >> 
> >> On Wed, 26 Jan 2022, Brad Smith wrote:
> >> 
> >>> On Wed, Jan 12, 2022 at 12:13:14AM -0500, Brad Smith wrote:
>  Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
>  type should be an unsigned char on anything but Linux.
> >>> 
> >>> Based on feedback so far. Here is a much simpler approach to this issue..
> >> 
> >> Win32 needs DWORD unfortunately. I missed it earlier, sorry.
> >> 
> >> https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options
> > 
> > From my testing on Mac system, it support one byte only, but at least, it'll
> > report "Invalid argument" only if the ttl > 255. Maybe we can try with one 
> > byte
> > again if the errno is invalid like below. I tested it with ttl > 255 on Mac 
> > system
> > and without "Invalid argument" anymore.
> 
> 
> MacOS support int and unsigned char from my test. The upper bound of TTL is 
> limited
> to 255 (limited by protocol design), I guess it’s unrelated to int or 
> unsigned char.

Yes, MacOS isn't caused by one byte or int. By #Ticket9449, it'll failed for 
ttl=10,
so I guess my proposal which try with one byte again should be work for Openbsd 
system.
But you can't limit to 255 only as some system support for int like Win32.

> 
> 
> > 
> > #ifdef IP_MULTICAST_TTL
> > +int ret = 0;
> > if (addr->sa_family == AF_INET) {
> > -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(mcastTTL)) < 0) {
> > +ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(mcastTTL));
> > +/* try with byte also for IP_MULTICAST_TTL for some system like 
> > OpenBSD */
> > +if (ret < 0 && errno == EINVAL) {
> > +unsigned char ttl = mcastTTL;
> > +ff_log_net_error(logctx, AV_LOG_ERROR, 
> > "setsockopt(IP_MULTICAST_TTL): ");
> > +ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(ttl));
> > +}
> > +if (ret < 0) {
> > ff_log_net_error(logctx, AV_LOG_ERROR, 
> > "setsockopt(IP_MULTICAST_TTL)");
> > return ff_neterrno();
> > 
> > 
> >> 
> >> Regards,
> >> Marton
> >> 
> >>> 
> >>> 
> >>> diff --git a/libavformat/udp.c b/libavformat/udp.c
> >>> index 83c042d079..da1b98890b 100644
> >>> --- a/libavformat/udp.c
> >>> +++ b/libavformat/udp.c
> >>> @@ -164,7 +164,9 @@ static int udp_set_multicast_ttl(int sockfd, int 
> >>> mcastTTL,
> >>> {
> >>> #ifdef IP_MULTICAST_TTL
> >>>if (addr->sa_family == AF_INET) {
> >>> -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> >>> sizeof(mcastTTL)) < 0) {
> >>> +unsigned char ttl = mcastTTL;  /* ignore the outdated Linux 
> >>> documentation */
> >>> +
> >>> +if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> >>> sizeof(ttl)) < 0) {
> >>>ff_log_net_error(logctx, AV_LOG_ERROR, 
> >>> "setsockopt(IP_MULTICAST_TTL)");
> >>>return ff_neterrno();
> >>>}
> >>> ___
> >>> 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".
> 
> ___
> 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] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-26 Thread lance . lmwang
On Wed, Jan 26, 2022 at 09:50:47PM +0100, Marton Balint wrote:
> 
> 
> On Wed, 26 Jan 2022, Brad Smith wrote:
> 
> > On Wed, Jan 12, 2022 at 12:13:14AM -0500, Brad Smith wrote:
> > > Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
> > > type should be an unsigned char on anything but Linux.
> > 
> > Based on feedback so far. Here is a much simpler approach to this issue..
> 
> Win32 needs DWORD unfortunately. I missed it earlier, sorry.
> 
> https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options

>From my testing on Mac system, it support one byte only, but at least, it'll
report "Invalid argument" only if the ttl > 255. Maybe we can try with one byte
again if the errno is invalid like below. I tested it with ttl > 255 on Mac 
system
and without "Invalid argument" anymore.

 #ifdef IP_MULTICAST_TTL
+int ret = 0;
 if (addr->sa_family == AF_INET) {
-if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(mcastTTL)) < 0) {
+ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(mcastTTL));
+/* try with byte also for IP_MULTICAST_TTL for some system like 
OpenBSD */
+if (ret < 0 && errno == EINVAL) {
+unsigned char ttl = mcastTTL;
+ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IP_MULTICAST_TTL): ");
+ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(ttl));
+}
+if (ret < 0) {
 ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IP_MULTICAST_TTL)");
 return ff_neterrno();


> 
> Regards,
> Marton
> 
> > 
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 83c042d079..da1b98890b 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -164,7 +164,9 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> > {
> > #ifdef IP_MULTICAST_TTL
> > if (addr->sa_family == AF_INET) {
> > -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(mcastTTL)) < 0) {
> > +unsigned char ttl = mcastTTL;  /* ignore the outdated Linux 
> > documentation */
> > +
> > +if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(ttl)) < 0) {
> > ff_log_net_error(logctx, AV_LOG_ERROR, 
> > "setsockopt(IP_MULTICAST_TTL)");
> > return ff_neterrno();
> > }
> > ___
> > 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] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-25 Thread lance . lmwang
On Tue, Jan 25, 2022 at 04:28:33PM -0800, Chad Fraleigh wrote:
> Since apparently linux will auto-detect (as mentioned by Marton Balint), 
> based on the optlen parameter, just using unsigned char in all cases seems to 
> be the cleanest. However, I would advise including a comment in the code to 
> that effect which says to ignore the [outdated] linux documentation (so 
> someone doesn't needlessly "correct" it in the future).
> 

I agree with, use unsigned char is preferable for all system I think.

> I looked at the kernel source and it does work both ways:
> 
> static int do_ip_setsockopt(struct sock *sk, int level, int optname,
> sockptr_t optval, unsigned int optlen)
> {
>  ...
> switch (optname) {
>  ...
> case IP_MULTICAST_TTL:
>  ...
> if (optlen >= sizeof(int)) {
> if (copy_from_sockptr(, optval, sizeof(val)))
> return -EFAULT;
> } else if (optlen >= sizeof(char)) {
> unsigned char ucval;
> 
> if (copy_from_sockptr(, optval, sizeof(ucval)))
> return -EFAULT;
> val = (int) ucval;
> }
> }
> ...
> }
> 
> This check has been in the kernel since at least 2.6.12-rc2 (from Apr 2005). 
> It should work fine, unless newer ffmpeg builds support is needed on older 
> systems. So the only question is how old are the kernels in IoT and android 
> devices which might use the current ffmpeg?
> 
> 
> On 1/24/2022 11:25 PM, lance.lmw...@gmail.com wrote:
> > On Wed, Jan 12, 2022 at 12:13:13AM -0500, Brad Smith wrote:
> >> Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
> >> type should be an unsigned char on anything but Linux.
> >>
> >>
> >> diff --git a/libavformat/udp.c b/libavformat/udp.c
> >> index 180d96a988..29aa865fff 100644
> >> --- a/libavformat/udp.c
> >> +++ b/libavformat/udp.c
> >> @@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int 
> >> mcastTTL,
> >>  {
> >>  #ifdef IP_MULTICAST_TTL
> >>  if (addr->sa_family == AF_INET) {
> >> -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> >> sizeof(mcastTTL)) < 0) {
> >> +#ifdef __linux__
> >> +int ttl = mcastTTL;
> >> +#else
> >> +unsigned char ttl = mcastTTL;
> >> +#endif
> > 
> > 
> > I don't have BSD system for test, but I prefer to use socklen_t, please try 
> > with my proposal patch:
> > 
> > ---
> >  libavformat/udp.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 83c042d079..b9baa0a803 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -164,7 +164,9 @@ static int udp_set_multicast_ttl(int sockfd, int 
> > mcastTTL,
> >  {
> >  #ifdef IP_MULTICAST_TTL
> >  if (addr->sa_family == AF_INET) {
> > -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(mcastTTL)) < 0) {
> > +socklen_t ttl = mcastTTL;
> > +
> > +if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> > sizeof(ttl)) < 0) {
> >  ff_log_net_error(logctx, AV_LOG_ERROR, 
> > "setsockopt(IP_MULTICAST_TTL)");
> >  return ff_neterrno();
> > 
> > 
> >> +
> >> +if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> >> sizeof(ttl)) < 0) {
> >>  ff_log_net_error(NULL, AV_LOG_ERROR, 
> >> "setsockopt(IP_MULTICAST_TTL)");
> >>  return ff_neterrno();
> >>  }
> >> ___
> >> 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] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-24 Thread lance . lmwang
On Wed, Jan 12, 2022 at 12:13:13AM -0500, Brad Smith wrote:
> Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
> type should be an unsigned char on anything but Linux.
> 
> 
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 180d96a988..29aa865fff 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int 
> mcastTTL,
>  {
>  #ifdef IP_MULTICAST_TTL
>  if (addr->sa_family == AF_INET) {
> -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> sizeof(mcastTTL)) < 0) {
> +#ifdef __linux__
> +int ttl = mcastTTL;
> +#else
> +unsigned char ttl = mcastTTL;
> +#endif


I don't have BSD system for test, but I prefer to use socklen_t, please try 
with my proposal patch:

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

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 83c042d079..b9baa0a803 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -164,7 +164,9 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 {
 #ifdef IP_MULTICAST_TTL
 if (addr->sa_family == AF_INET) {
-if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(mcastTTL)) < 0) {
+socklen_t ttl = mcastTTL;
+
+if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
sizeof(ttl)) < 0) {
 ff_log_net_error(logctx, AV_LOG_ERROR, 
"setsockopt(IP_MULTICAST_TTL)");
 return ff_neterrno();


> +
> +if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> sizeof(ttl)) < 0) {
>  ff_log_net_error(NULL, AV_LOG_ERROR, 
> "setsockopt(IP_MULTICAST_TTL)");
>  return ff_neterrno();
>  }
> ___
> 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 3/3] avformat/dashdec: avoid calling strlen multiple times

2022-01-22 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 0d21989..211d77f 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -403,6 +403,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 DASHContext *c = s->priv_data;
 AVDictionary *tmp = NULL;
 const char *proto_name = NULL;
+int proto_name_len;
 int ret;
 
 if (av_strstart(url, "crypto", NULL)) {
@@ -416,6 +417,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 if (!proto_name)
 return AVERROR_INVALIDDATA;
 
+proto_name_len = strlen(proto_name);
 // only http(s) & file are allowed
 if (av_strstart(proto_name, "file", NULL)) {
 if (strcmp(c->allowed_extensions, "ALL") && !av_match_ext(url, 
c->allowed_extensions)) {
@@ -430,9 +432,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 } else
 return AVERROR_INVALIDDATA;
 
-if (!strncmp(proto_name, url, strlen(proto_name)) && 
url[strlen(proto_name)] == ':')
+if (!strncmp(proto_name, url, proto_name_len) && url[proto_name_len] == 
':')
 ;
-else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 7, 
strlen(proto_name)) && url[7 + strlen(proto_name)] == ':')
+else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 7, 
proto_name_len) && url[7 + proto_name_len] == ':')
 ;
 else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
 return AVERROR_INVALIDDATA;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH 2/3] avformat/rtpdec: return value check for init_get_bits()

2022-01-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/rtpdec_h261.c | 4 +++-
 libavformat/rtpdec_h263_rfc2190.c | 4 +++-
 libavformat/rtpdec_latm.c | 4 +++-
 libavformat/rtpdec_mpeg4.c| 5 -
 libavformat/rtpdec_qt.c   | 4 +++-
 5 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/libavformat/rtpdec_h261.c b/libavformat/rtpdec_h261.c
index a102909..57bc10f 100644
--- a/libavformat/rtpdec_h261.c
+++ b/libavformat/rtpdec_h261.c
@@ -119,7 +119,9 @@ static int h261_handle_packet(AVFormatContext *ctx, 
PayloadContext *rtp_h261_ctx
 } else {
 /* ebit/sbit values inconsistent, assuming packet loss */
 GetBitContext gb;
-init_get_bits(, buf, len*8 - ebit);
+res = init_get_bits(, buf, len*8 - ebit);
+if (res < 0)
+return res;
 skip_bits(, sbit);
 if (rtp_h261_ctx->endbyte_bits) {
 rtp_h261_ctx->endbyte |= get_bits(, 8 - 
rtp_h261_ctx->endbyte_bits);
diff --git a/libavformat/rtpdec_h263_rfc2190.c 
b/libavformat/rtpdec_h263_rfc2190.c
index a0f587f..47aaec0 100644
--- a/libavformat/rtpdec_h263_rfc2190.c
+++ b/libavformat/rtpdec_h263_rfc2190.c
@@ -142,7 +142,9 @@ static int h263_handle_packet(AVFormatContext *ctx, 
PayloadContext *data,
 } else {
 /* Start/end skip bits not matching - missed packets? */
 GetBitContext gb;
-init_get_bits(, buf, len*8 - ebit);
+ret = init_get_bits(, buf, len*8 - ebit);
+if (ret < 0)
+return ret;
 skip_bits(, sbit);
 if (data->endbyte_bits) {
 data->endbyte |= get_bits(, 8 - data->endbyte_bits);
diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c
index 104a00a..329b8db 100644
--- a/libavformat/rtpdec_latm.c
+++ b/libavformat/rtpdec_latm.c
@@ -101,7 +101,9 @@ static int parse_fmtp_config(AVStream *st, const char 
*value)
 if (!config)
 return AVERROR(ENOMEM);
 ff_hex_to_data(config, value);
-init_get_bits(, config, len*8);
+ret = init_get_bits(, config, len*8);
+if (ret < 0)
+return ret;
 audio_mux_version = get_bits(, 1);
 same_time_framing = get_bits(, 1);
 skip_bits(, 6); /* num_sub_frames */
diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c
index 34c7950..723b6fc 100644
--- a/libavformat/rtpdec_mpeg4.c
+++ b/libavformat/rtpdec_mpeg4.c
@@ -124,6 +124,7 @@ static int rtp_parse_mp4_au(PayloadContext *data, const 
uint8_t *buf, int len)
 {
 int au_headers_length, au_header_size, i;
 GetBitContext getbitcontext;
+int ret;
 
 if (len < 2)
 return AVERROR_INVALIDDATA;
@@ -144,7 +145,9 @@ static int rtp_parse_mp4_au(PayloadContext *data, const 
uint8_t *buf, int len)
 if (len < data->au_headers_length_bytes)
 return AVERROR_INVALIDDATA;
 
-init_get_bits(, buf, data->au_headers_length_bytes * 8);
+ret = init_get_bits(, buf, data->au_headers_length_bytes * 
8);
+if (ret < 0)
+return ret;
 
 /* XXX: Wrong if optional additional sections are present (cts, dts 
etc...) */
 au_header_size = data->sizelength + data->indexlength;
diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c
index 6723cd1..495a3ec 100644
--- a/libavformat/rtpdec_qt.c
+++ b/libavformat/rtpdec_qt.c
@@ -82,7 +82,9 @@ static int qt_rtp_parse_packet(AVFormatContext *s, 
PayloadContext *qt,
  * The RTP payload is described in:
  * http://developer.apple.com/quicktime/icefloe/dispatch026.html
  */
-init_get_bits(, buf, len << 3);
+ret = init_get_bits(, buf, len << 3);
+if (ret < 0)
+return ret;
 ffio_init_context(, (uint8_t*)buf, len, 0, NULL, NULL, NULL, NULL);
 
 if (len < 4)
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH 1/3] avformat/rtpdec: Fix negative missed packets in warning message

2022-01-22 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/rtpdec.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 20fe2b8..f285a41 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -835,9 +835,14 @@ static int rtp_parse_queued_packet(RTPDemuxContext *s, 
AVPacket *pkt)
 if (s->queue_len <= 0)
 return -1;
 
-if (!has_next_packet(s))
+if (!has_next_packet(s)) {
+int pkt_missed  = s->queue->seq - s->seq - 1;
+
+if (pkt_missed < 0)
+pkt_missed += UINT16_MAX;
 av_log(s->ic, AV_LOG_WARNING,
-   "RTP: missed %d packets\n", s->queue->seq - s->seq - 1);
+   "RTP: missed %d packets\n", pkt_missed);
+}
 
 /* Parse the first packet in the queue, and dequeue it */
 rv   = rtp_parse_packet_internal(s, pkt, s->queue->buf, s->queue->len);
-- 
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 v3 2/3] avcodec/libopenh264enc: make the profile configuablable correctly

2022-01-14 Thread lance . lmwang
On Fri, Jan 14, 2022 at 02:07:26PM +0200, Martin Storsjö wrote:
> On Fri, 14 Jan 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > due to the limitations set in d3a7bdd4ac54349aea9150a234478635d50ebd87,
> > you weren't able to use main profile with OpenH264 1.8, or high profile
> > with older versions
> > 
> > Reviewed-by: Martin Storsjö 
> > Signed-off-by: Limin Wang 
> > ---
> > libavcodec/libopenh264enc.c | 8 
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index 5b5914c..1bad233 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -220,26 +220,25 @@ static av_cold int svc_encode_init(AVCodecContext 
> > *avctx)
> > #endif
> > 
> > switch (s->profile) {
> > -#if OPENH264_VER_AT_LEAST(1, 8)
> > case FF_PROFILE_H264_HIGH:
> > param.iEntropyCodingModeFlag = 1;
> > 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:
> > +s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
> > +case FF_PROFILE_H264_CONSTRAINED_BASELINE:
> 
> I don't think it's specifically necessary to move the case labels around
> like this; you could just leave both case labels above it, and the
> assignment would be a no-op for one case. (No need to resend the patch for
> that, do whichever form you prefer.)

OK, will not move the case lables as suggestion.

> 
> > param.iEntropyCodingModeFlag = 0;
> > av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
> >"select EProfileIdc PRO_BASELINE in libopenh264.\n");
> > break;
> > default:
> > +s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
> > param.iEntropyCodingModeFlag = 0;
> > av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
> >"select EProfileIdc PRO_BASELINE in libopenh264.\n");
> > @@ -251,6 +250,7 @@ static av_cold int svc_encode_init(AVCodecContext 
> > *avctx)
> > param.sSpatialLayers[0].fFrameRate  = param.fMaxFrameRate;
> > param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
> > param.sSpatialLayers[0].iMaxSpatialBitrate  = param.iMaxBitrate;
> > +param.sSpatialLayers[0].uiProfileIdc= s->profile;
> 
> Thanks, this seems sensible to me. This is ok if you've tested that setting
> profile to FF_PROFILE_H264_CONSTRAINED_BASELINE (as opposed to PRO_BASELINE)
> does work with both some old and some recent version of OpenH264.

Yes, have tested with v1.4.0, v1.7.0 and master.

> 
> // Martin


-- 
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 v3 3/3] avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option

2022-01-14 Thread lance . lmwang
From: Limin Wang 

For high/main profile, user can choose to use cavlc by specify "-coder cavlc",
for default, it'll will use cabac, if it's baseline, we'll use cavlc by specs 
anyway.

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc 
-frames:v 1 -bsf trace_headers -f null -
before the patch:
entropy_coding_mode_flag0 = 1

after the patch:
entropy_coding_mode_flag0 = 0

Reviewed-by: Martin Storsjö 
Signed-off-by: Limin Wang 
---
 libavcodec/libopenh264enc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 1bad233..a1e78c9 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -193,7 +193,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 #endif
 param.bPrefixNalAddingCtrl   = 0;
 param.iLoopFilterDisableIdc  = !s->loopfilter;
-param.iEntropyCodingModeFlag = 0;
+param.iEntropyCodingModeFlag = s->coder >= 0 ? s->coder : 1;
 param.iMultipleThreadIdc = avctx->thread_count;
 
 /* Allow specifying the libopenh264 profile through AVCodecContext. */
@@ -221,14 +221,14 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 
 switch (s->profile) {
 case FF_PROFILE_H264_HIGH:
-param.iEntropyCodingModeFlag = 1;
-av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-"select EProfileIdc PRO_HIGH in libopenh264.\n");
+av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+"select EProfileIdc PRO_HIGH in libopenh264.\n",
+param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
 break;
 case FF_PROFILE_H264_MAIN:
-param.iEntropyCodingModeFlag = 1;
-av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-"select EProfileIdc PRO_MAIN in libopenh264.\n");
+av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+"select EProfileIdc PRO_MAIN in libopenh264.\n",
+param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
 break;
 case FF_PROFILE_UNKNOWN:
 s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v3 2/3] avcodec/libopenh264enc: make the profile configuablable correctly

2022-01-14 Thread lance . lmwang
From: Limin Wang 

due to the limitations set in d3a7bdd4ac54349aea9150a234478635d50ebd87,
you weren't able to use main profile with OpenH264 1.8, or high profile
with older versions

Reviewed-by: Martin Storsjö 
Signed-off-by: Limin Wang 
---
 libavcodec/libopenh264enc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 5b5914c..1bad233 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -220,26 +220,25 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 #endif
 
 switch (s->profile) {
-#if OPENH264_VER_AT_LEAST(1, 8)
 case FF_PROFILE_H264_HIGH:
 param.iEntropyCodingModeFlag = 1;
 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:
+s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
 param.iEntropyCodingModeFlag = 0;
 av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
"select EProfileIdc PRO_BASELINE in libopenh264.\n");
 break;
 default:
+s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
 param.iEntropyCodingModeFlag = 0;
 av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
"select EProfileIdc PRO_BASELINE in libopenh264.\n");
@@ -251,6 +250,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 param.sSpatialLayers[0].fFrameRate  = param.fMaxFrameRate;
 param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
 param.sSpatialLayers[0].iMaxSpatialBitrate  = param.iMaxBitrate;
+param.sSpatialLayers[0].uiProfileIdc= s->profile;
 
 #if OPENH264_VER_AT_LEAST(1, 7)
 if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) {
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v3 1/3] avcodec/libopenh264enc: support for colorspace and range information

2022-01-14 Thread lance . lmwang
From: Limin Wang 

Reviewed-by: Martin Storsjö 
Signed-off-by: Limin Wang 
---
 libavcodec/libopenh264enc.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index de4b85c..5b5914c 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -330,6 +330,28 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 }
 }
 
+#if OPENH264_VER_AT_LEAST(1, 6)
+param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
+if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) {
+param.sSpatialLayers[0].bVideoSignalTypePresent = true;
+param.sSpatialLayers[0].bFullRange = (avctx->color_range == 
AVCOL_RANGE_JPEG);
+}
+
+if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED  ||
+avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
+avctx->color_trc != AVCOL_TRC_UNSPECIFIED) {
+param.sSpatialLayers[0].bVideoSignalTypePresent = true;
+param.sSpatialLayers[0].bColorDescriptionPresent = true;
+}
+
+if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED)
+param.sSpatialLayers[0].uiColorMatrix = avctx->colorspace;
+if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
+param.sSpatialLayers[0].uiColorPrimaries = avctx->color_primaries;
+if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED)
+param.sSpatialLayers[0].uiTransferCharacteristics = avctx->color_trc;
+#endif
+
 if ((*s->encoder)->InitializeExt(s->encoder, ) != cmResultSuccess) {
 av_log(avctx, AV_LOG_ERROR, "Initialize failed\n");
 return AVERROR_UNKNOWN;
-- 
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 v2 2/3] avcodec/libopenh264enc: make the profile configuablable correctly

2022-01-14 Thread lance . lmwang
On Fri, Jan 14, 2022 at 11:28:14AM +0200, Martin Storsjö wrote:
> On Fri, 14 Jan 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > d3a7bdd4ac54349aea9150a234478635d50ebd87 was based on incorrect conclusions
> > because we had missed to set uiProfileIdc.
> > 
> > If the version of libopenh264 >= 1.8, we can't configured main profile as
> > expected, below is the testing cli:
> > 
> > ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -frames:v 1 
> > test.ts
> > It'll report:
> > [libopenh264 @ 0x5638300] Unsupported profile, select EProfileIdc 
> > PRO_BASELINE in libopenh264.
> 
> Given the referenced commit, the fact that you can't use main profile with
> 1.8 (or high profile with older) isn't a surprise as that was part of the
> deliberate design in that commit, so I'm not sure if this is a good example
> to include. Or reword it to say that "due to the limitations set in
> , you weren't able to use main profile with OpenH264 1.8, or high
> profile with older versions".

Sure, will reword the message as suggestion.

> 
> > Signed-off-by: Limin Wang 
> > ---
> > libavcodec/libopenh264enc.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index 5b5914c..8e27edb 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -220,19 +220,16 @@ static av_cold int svc_encode_init(AVCodecContext 
> > *avctx)
> > #endif
> > 
> > switch (s->profile) {
> > -#if OPENH264_VER_AT_LEAST(1, 8)
> > case FF_PROFILE_H264_HIGH:
> > param.iEntropyCodingModeFlag = 1;
> > 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;
> 
> For this fallback case, I think we should set s->profile to
> FF_PROFILE_H264_CONSTRAINED_BASELINE or something similar (does OpenH264
> work correctly with FF_PROFILE_H264_CONSTRAINED_BASELINE too, or only with
> FF_PROFILE_H264_BASELINE which is equal to PRO_BASELINE), as we otherwise
> would be setting unknown values into uiProfileIdc.

Sure, will update to set profile to FF_PROFILE_H264_CONSTRAINED_BASELINE for 
unknown case.

> 
> // Martin
> 

-- 
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 3/3] avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option

2022-01-14 Thread lance . lmwang
From: Limin Wang 

For high/main profile, user can choose to use cavlc by specify "-coder cavlc",
for default, it'll will use cabac, if it's baseline, we'll use cavlc by specs 
anyway.

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc 
-frames:v 1 -bsf trace_headers -f null -
before the patch:
entropy_coding_mode_flag0 = 1

after the patch:
entropy_coding_mode_flag0 = 0

Signed-off-by: Limin Wang 
---
 libavcodec/libopenh264enc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 8e27edb..4c0997b 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -193,7 +193,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 #endif
 param.bPrefixNalAddingCtrl   = 0;
 param.iLoopFilterDisableIdc  = !s->loopfilter;
-param.iEntropyCodingModeFlag = 0;
+param.iEntropyCodingModeFlag = s->coder >= 0 ? s->coder : 1;
 param.iMultipleThreadIdc = avctx->thread_count;
 
 /* Allow specifying the libopenh264 profile through AVCodecContext. */
@@ -221,14 +221,14 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 
 switch (s->profile) {
 case FF_PROFILE_H264_HIGH:
-param.iEntropyCodingModeFlag = 1;
-av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-"select EProfileIdc PRO_HIGH in libopenh264.\n");
+av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+"select EProfileIdc PRO_HIGH in libopenh264.\n",
+param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
 break;
 case FF_PROFILE_H264_MAIN:
-param.iEntropyCodingModeFlag = 1;
-av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-"select EProfileIdc PRO_MAIN in libopenh264.\n");
+av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+"select EProfileIdc PRO_MAIN in libopenh264.\n",
+param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
 break;
 case FF_PROFILE_H264_CONSTRAINED_BASELINE:
 case FF_PROFILE_UNKNOWN:
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 2/3] avcodec/libopenh264enc: make the profile configuablable correctly

2022-01-14 Thread lance . lmwang
From: Limin Wang 

d3a7bdd4ac54349aea9150a234478635d50ebd87 was based on incorrect conclusions
because we had missed to set uiProfileIdc.

If the version of libopenh264 >= 1.8, we can't configured main profile as
expected, below is the testing cli:

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -frames:v 1 
test.ts
It'll report:
[libopenh264 @ 0x5638300] Unsupported profile, select EProfileIdc PRO_BASELINE 
in libopenh264.

Signed-off-by: Limin Wang 
---
 libavcodec/libopenh264enc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 5b5914c..8e27edb 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -220,19 +220,16 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 #endif
 
 switch (s->profile) {
-#if OPENH264_VER_AT_LEAST(1, 8)
 case FF_PROFILE_H264_HIGH:
 param.iEntropyCodingModeFlag = 1;
 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;
@@ -251,6 +248,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 param.sSpatialLayers[0].fFrameRate  = param.fMaxFrameRate;
 param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
 param.sSpatialLayers[0].iMaxSpatialBitrate  = param.iMaxBitrate;
+param.sSpatialLayers[0].uiProfileIdc= s->profile;
 
 #if OPENH264_VER_AT_LEAST(1, 7)
 if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) {
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 1/3] avcodec/libopenh264enc: support for colorspace and range information

2022-01-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/libopenh264enc.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index de4b85c..5b5914c 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -330,6 +330,28 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 }
 }
 
+#if OPENH264_VER_AT_LEAST(1, 6)
+param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
+if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) {
+param.sSpatialLayers[0].bVideoSignalTypePresent = true;
+param.sSpatialLayers[0].bFullRange = (avctx->color_range == 
AVCOL_RANGE_JPEG);
+}
+
+if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED  ||
+avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
+avctx->color_trc != AVCOL_TRC_UNSPECIFIED) {
+param.sSpatialLayers[0].bVideoSignalTypePresent = true;
+param.sSpatialLayers[0].bColorDescriptionPresent = true;
+}
+
+if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED)
+param.sSpatialLayers[0].uiColorMatrix = avctx->colorspace;
+if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
+param.sSpatialLayers[0].uiColorPrimaries = avctx->color_primaries;
+if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED)
+param.sSpatialLayers[0].uiTransferCharacteristics = avctx->color_trc;
+#endif
+
 if ((*s->encoder)->InitializeExt(s->encoder, ) != cmResultSuccess) {
 av_log(avctx, AV_LOG_ERROR, "Initialize failed\n");
 return AVERROR_UNKNOWN;
-- 
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 3/3] avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option

2022-01-13 Thread lance . lmwang
On Fri, Jan 14, 2022 at 12:01:26AM +0200, Martin Storsjö wrote:
> On Thu, 13 Jan 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc 
> > -frames:v 1 -bsf trace_headers -f null -
> > 
> > before the patch:
> > entropy_coding_mode_flag0 = 1
> > 
> > after the patch:
> > entropy_coding_mode_flag0 = 0
> 
> I don't understand what this bit in the commit message tries to say?
> 
> 
> Doesn't this patch have the effect, that if I only specify "-profile high",
> I'll end up with CAVLC unless I specifically pass "-coder cabac" too? If
> coder wasn't specified, I think we should still default to CABAC for
> main/high.

Sorry, I'll update the message.
it's high profile, we can't to use cavlc even if specify -coder. Yes, if haven't
set coder, it's preferable to enable cabac for high.

> 
> // Martin
> 

-- 
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 2/3] avcodec/libopenh264enc: make the profile configuablable correctly

2022-01-13 Thread lance . lmwang
On Thu, Jan 13, 2022 at 11:57:36PM +0200, Martin Storsjö wrote:
> On Thu, 13 Jan 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > If the version of libopenh264 >= 1.8, we can't configured main profile as
> > expected, below is the testing cli:
> > 
> > ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -frames:v 1 
> > test.ts
> > It'll report:
> > [libopenh264 @ 0x5638300] Unsupported profile, select EProfileIdc 
> > PRO_BASELINE in libopenh264.
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavcodec/libopenh264enc.c | 8 +---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index a55bef8..995ee37 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -220,26 +220,27 @@ static av_cold int svc_encode_init(AVCodecContext 
> > *avctx)
> > #endif
> > 
> > switch (s->profile) {
> > -#if OPENH264_VER_AT_LEAST(1, 8)
> > case FF_PROFILE_H264_HIGH:
> > +s->profile = PRO_HIGH;
> 
> I don't think we should reuse the s->profile field for this value here.
> 
> In practice, both FF_PROFILE_H264_HIGH and PRO_HIGH have the same values,
> but they're enums from different namespaces, so would it be clearer to use
> one variable for profiles set with FF_PROFILE_* and one with the PRO_*
> values?

Yes, I think they're same value by specs, I'll delete the assignment for PRO_* 
to make it be cleaner.

> 
> > param.iEntropyCodingModeFlag = 1;
> > av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
> > "select EProfileIdc PRO_HIGH in libopenh264.\n");
> > break;
> > -#else
> > case FF_PROFILE_H264_MAIN:
> > +s->profile = PRO_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:
> > +s->profile = PRO_BASELINE;
> > param.iEntropyCodingModeFlag = 0;
> > av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
> >"select EProfileIdc PRO_BASELINE in libopenh264.\n");
> > break;
> > default:
> > +s->profile = PRO_BASELINE;
> > param.iEntropyCodingModeFlag = 0;
> > av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
> >"select EProfileIdc PRO_BASELINE in libopenh264.\n");
> > @@ -251,6 +252,7 @@ static av_cold int svc_encode_init(AVCodecContext 
> > *avctx)
> > param.sSpatialLayers[0].fFrameRate  = param.fMaxFrameRate;
> > param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
> > param.sSpatialLayers[0].iMaxSpatialBitrate  = param.iMaxBitrate;
> > +param.sSpatialLayers[0].uiProfileIdc= s->profile;
> 
> So this assignment is what was missing, and was what caused the incorrect
> conclusion in d3a7bdd4ac54349aea9150a234478635d50ebd87? I think it'd be good
> to explicitly spell this out in the commit message, saying that

OK, will add the following message into commit message:
d3a7bdd4ac54349aea9150a234478635d50ebd87 was based on incorrect conclusions
because we had missed to set uiProfileIdc.

> 
> // Martin
> 

-- 
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 1/3] avcodec/libopenh264enc: support for colorspace and range information

2022-01-13 Thread lance . lmwang
On Thu, Jan 13, 2022 at 11:35:32PM +0200, Martin Storsjö wrote:
> On Thu, 13 Jan 2022, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavcodec/libopenh264enc.c | 15 +++
> > 1 file changed, 15 insertions(+)
> > 
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index de4b85c..a55bef8 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -330,6 +330,21 @@ static av_cold int svc_encode_init(AVCodecContext 
> > *avctx)
> > }
> > }
> > 
> > +#if OPENH264_VER_AT_LEAST(1, 6)
> > +param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
> > +param.sSpatialLayers[0].bVideoSignalTypePresent = true;
> 
> What does this flag do, and why do we set it unconditionally while we didn't
> use to before?
> 

OK, will update and set the flag only if bFullRange is set.

> > +if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED)
> > +param.sSpatialLayers[0].bFullRange = (avctx->color_range == 
> > AVCOL_RANGE_JPEG);
> > +
> > +param.sSpatialLayers[0].bColorDescriptionPresent = true;
> 
> Ditto - what does this do and why do we set it even if we wouldn't set any
> of the other fields?

will update and set the flag only if any the following fields are set.

> 
> // Martin
> 

-- 
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 3/3] avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option

2022-01-13 Thread lance . lmwang
From: Limin Wang 

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc 
-frames:v 1 -bsf trace_headers -f null -

before the patch:
entropy_coding_mode_flag0 = 1

after the patch:
entropy_coding_mode_flag0 = 0

Signed-off-by: Limin Wang 
---
 libavcodec/libopenh264enc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 995ee37..91deb6c 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -193,7 +193,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 #endif
 param.bPrefixNalAddingCtrl   = 0;
 param.iLoopFilterDisableIdc  = !s->loopfilter;
-param.iEntropyCodingModeFlag = 0;
+param.iEntropyCodingModeFlag = s->coder >= 0 ? s->coder : 0;
 param.iMultipleThreadIdc = avctx->thread_count;
 
 /* Allow specifying the libopenh264 profile through AVCodecContext. */
@@ -222,15 +222,15 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 switch (s->profile) {
 case FF_PROFILE_H264_HIGH:
 s->profile = PRO_HIGH;
-param.iEntropyCodingModeFlag = 1;
-av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-"select EProfileIdc PRO_HIGH in libopenh264.\n");
+av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+"select EProfileIdc PRO_HIGH in libopenh264.\n",
+s->coder == 1 ? "CABAC" : "CAVLC");
 break;
 case FF_PROFILE_H264_MAIN:
 s->profile = PRO_MAIN;
-param.iEntropyCodingModeFlag = 1;
-av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-"select EProfileIdc PRO_MAIN in libopenh264.\n");
+av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+"select EProfileIdc PRO_MAIN in libopenh264.\n",
+s->coder == 1 ? "CABAC" : "CAVLC");
 break;
 case FF_PROFILE_H264_CONSTRAINED_BASELINE:
 case FF_PROFILE_UNKNOWN:
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH 2/3] avcodec/libopenh264enc: make the profile configuablable correctly

2022-01-13 Thread lance . lmwang
From: Limin Wang 

If the version of libopenh264 >= 1.8, we can't configured main profile as
expected, below is the testing cli:

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -frames:v 1 
test.ts
It'll report:
[libopenh264 @ 0x5638300] Unsupported profile, select EProfileIdc PRO_BASELINE 
in libopenh264.

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index a55bef8..995ee37 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -220,26 +220,27 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 #endif
 
 switch (s->profile) {
-#if OPENH264_VER_AT_LEAST(1, 8)
 case FF_PROFILE_H264_HIGH:
+s->profile = PRO_HIGH;
 param.iEntropyCodingModeFlag = 1;
 av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
 "select EProfileIdc PRO_HIGH in libopenh264.\n");
 break;
-#else
 case FF_PROFILE_H264_MAIN:
+s->profile = PRO_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:
+s->profile = PRO_BASELINE;
 param.iEntropyCodingModeFlag = 0;
 av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
"select EProfileIdc PRO_BASELINE in libopenh264.\n");
 break;
 default:
+s->profile = PRO_BASELINE;
 param.iEntropyCodingModeFlag = 0;
 av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
"select EProfileIdc PRO_BASELINE in libopenh264.\n");
@@ -251,6 +252,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 param.sSpatialLayers[0].fFrameRate  = param.fMaxFrameRate;
 param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
 param.sSpatialLayers[0].iMaxSpatialBitrate  = param.iMaxBitrate;
+param.sSpatialLayers[0].uiProfileIdc= s->profile;
 
 #if OPENH264_VER_AT_LEAST(1, 7)
 if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) {
-- 
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".


  1   2   3   4   5   6   7   8   9   10   >