Re: [FFmpeg-devel] [PATCH]lavf, lavfi: Remove uses of sizeof(char)

2020-04-03 Thread Andreas Rheinhardt
Carl Eugen Hoyos:
> Hi!
> 
> Attached patch removes uses of sizeof(char) from libavfilter and libavformat.
> 
> Please comment, Carl Eugen
> 
The commit message is misleading: Actually C is based around
sizeof(char) = 1. From the semantics of the sizeof operator: "When
applied to an operand that has type char, unsigned char, or signed char,
(or a qualified version thereof) the result is 1." (C90, 6.3.3.4; C99,
6.5.3.4).

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

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

[FFmpeg-devel] [PATCH v1] avformat/movenc: cosmetics

2020-04-03 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6db09b7..7140ad3 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2711,7 +2711,7 @@ static int mov_write_hdlr_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
 } else {
 hdlr_type = "text";
 }
-descr = "SubtitleHandler";
+descr = "SubtitleHandler";
 }
 } else if (track->par->codec_tag == MKTAG('r','t','p',' ')) {
 hdlr_type = "hint";
-- 
2.9.5

___
ffmpeg-devel mailing list
ffmpeg-devel@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/matroskaenc: add matroska subtitle muxer (.mks)

2020-04-03 Thread Steven Liu


> 2020年4月4日 上午9:37,Jan Chren (rindeal)  写道:
> 
> RnJvbSBlYWE5ZjI2ODU0MzY3MjVlMTllYjk0ZTdmMmQwMTc0YmE1NmI3NDI5IE1vbiBTZXAgMTcg
> MDA6MDA6MDAgMjAwMQpGcm9tOiBKYW4gQ2hyZW4gKHJpbmRlYWwpIDxkZXYucmluZGVhbEBnbWFp
> bC5jb20+CkRhdGU6IFRodSwgMSBBcHIgMjAyMCAwMDowMDowMCArMDAwMApTdWJqZWN0OiBbUEFU
> Q0hdIGF2Zm9ybWF0L21hdHJvc2thZW5jOiBhZGQgbWF0cm9za2Egc3VidGl0bGUgbXV4ZXIgKC5t
> a3MpCgpTaWduZWQtb2ZmLWJ5OiBKYW4gQ2hyZW4gKHJpbmRlYWwpIDxkZXYucmluZGVhbEBnbWFp
> bC5jb20+Ci0tLQogbGliYXZmb3JtYXQvbWF0cm9za2FlbmMuYyB8IDI4ICsrKysrKysrKysrKysr
> KysrKysrKysrKysrKysKIDEgZmlsZSBjaGFuZ2VkLCAyOCBpbnNlcnRpb25zKCspCgpkaWZmIC0t
> Z2l0IGEvbGliYXZmb3JtYXQvbWF0cm9za2FlbmMuYyBiL2xpYmF2Zm9ybWF0L21hdHJvc2thZW5j
> LmMKaW5kZXggNWRhZTUzMDI2ZDguLjYyMTI3ZmU5N2YwIDEwMDY0NAotLS0gYS9saWJhdmZvcm1h
> dC9tYXRyb3NrYWVuYy5jCisrKyBiL2xpYmF2Zm9ybWF0L21hdHJvc2thZW5jLmMKQEAgLTI3OTMs
> MyArMjc5MywzMSBAQCBBVk91dHB1dEZvcm1hdCBmZl9tYXRyb3NrYV9hdWRpb19tdXhlciA9IHsK
> ICAgICAucHJpdl9jbGFzcyAgICAgICAgPSAmbWthX2NsYXNzLAogfTsKICNlbmRpZgorCisjaWYg
> Q09ORklHX01BVFJPU0tBX1NVQlRJVExFX01VWEVSCitzdGF0aWMgY29uc3QgQVZDbGFzcyBta3Nf
> Y2xhc3MgPSB7CisgICAgLmNsYXNzX25hbWUgPSAibWF0cm9za2Egc3VidGl0bGUgbXV4ZXIiLAor
> ICAgIC5pdGVtX25hbWUgID0gYXZfZGVmYXVsdF9pdGVtX25hbWUsCisgICAgLm9wdGlvbiAgICAg
> PSBvcHRpb25zLAorICAgIC52ZXJzaW9uICAgID0gTElCQVZVVElMX1ZFUlNJT05fSU5ULAorfTsK
> K0FWT3V0cHV0Rm9ybWF0IGZmX21hdHJvc2thX3N1YnRpdGxlX211eGVyID0geworICAgIC5uYW1l
> ICAgICAgICAgICAgICA9ICJtYXRyb3NrYSIsCisgICAgLmxvbmdfbmFtZSAgICAgICAgID0gTlVM
> TF9JRl9DT05GSUdfU01BTEwoIk1hdHJvc2thIFN1YnRpdGxlcyIpLAorICAgIC5leHRlbnNpb25z
> ICAgICAgICA9ICJta3MiLAorICAgIC5wcml2X2RhdGFfc2l6ZSAgICA9IHNpemVvZihNYXRyb3Nr
> YU11eENvbnRleHQpLAorICAgIC5zdWJ0aXRsZV9jb2RlYyAgICA9IEFWX0NPREVDX0lEX0FTUywK
> KyAgICAuaW5pdCAgICAgICAgICAgICAgPSBta3ZfaW5pdCwKKyAgICAuZGVpbml0ICAgICAgICAg
> ICAgPSBta3ZfZGVpbml0LAorICAgIC53cml0ZV9oZWFkZXIgICAgICA9IG1rdl93cml0ZV9oZWFk
> ZXIsCisgICAgLndyaXRlX3BhY2tldCAgICAgID0gbWt2X3dyaXRlX2ZsdXNoX3BhY2tldCwKKyAg
> ICAud3JpdGVfdHJhaWxlciAgICAgPSBta3Zfd3JpdGVfdHJhaWxlciwKKyAgICAuY2hlY2tfYml0
> c3RyZWFtICAgPSBta3ZfY2hlY2tfYml0c3RyZWFtLAorICAgIC5mbGFncyAgICAgICAgICAgICA9
> IEFWRk1UX0dMT0JBTEhFQURFUiB8IEFWRk1UX1ZBUklBQkxFX0ZQUyB8CisgICAgICAgICAgICAg
> ICAgICAgICAgICAgQVZGTVRfVFNfTk9OU1RSSUNUIHwgQVZGTVRfQUxMT1dfRkxVU0gsCisgICAg
> LmNvZGVjX3RhZyAgICAgICAgID0gKGNvbnN0IEFWQ29kZWNUYWcqIGNvbnN0IFtdKXsKKyAgICAg
> ICAgYWRkaXRpb25hbF9zdWJ0aXRsZV90YWdzLCAwCisgICAgfSwKKyAgICAucHJpdl9jbGFzcyAg
> ICAgICAgPSAmbWtzX2NsYXNzLAorfTsKKyNlbmRpZgo=
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Looks bad to me

Thanks

Steven Liu



___
ffmpeg-devel mailing list
ffmpeg-devel@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/matroskaenc: remove MAX_TRACKS limit

2020-04-03 Thread Jan Chren (rindeal)
RnJvbSA0M2U0Yjk2OTVhNDM0MjExMmIxMTE3ZGI2NTI2YmFmYTFmOWRhYjNlIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBKYW4gQ2hyZW4gKHJpbmRlYWwpIDxkZXYucmluZGVhbEBnbWFp
bC5jb20+CkRhdGU6IFRodSwgMSBBcHIgMjAyMCAwMDowMDowMCArMDAwMApTdWJqZWN0OiBbUEFU
Q0hdIGF2Zm9ybWF0L21hdHJvc2thZW5jOiByZW1vdmUgTUFYX1RSQUNLUyBsaW1pdAoKSXQgd2Fz
IGludHJvZHVjZWQgaW4gN2JlMGY0OGEzMjE1NWVmOWY0NzFmZmM1YTFiNDFkNjYyZWEzMzdmMQp0
byBzZXQgc2l6ZSBvZiBhbiBhcnJheSBzdHJ1Y3QgZmllbGQsIGJ1dCB0aGF0IGJhZCBkZXNpZ24g
d2FzIGZpeGVkCmluIDY1ZWY3NGY3NDkwMDU5MGYxMzRiNGExMzBlOGY1NmU1MjcyZDE5MjUuCkFz
IHN1Y2ggdGhpcyBhcnRpZmljaWFsIGxpbWl0IHNlcnZlcyBubyBwdXJwb3NlIGFueW1vcmUuCgpT
aWduZWQtb2ZmLWJ5OiBKYW4gQ2hyZW4gKHJpbmRlYWwpIDxkZXYucmluZGVhbEBnbWFpbC5jb20+
Ci0tLQogbGliYXZmb3JtYXQvbWF0cm9za2FlbmMuYyB8IDExIC0tLS0tLS0tLS0tCiAxIGZpbGUg
Y2hhbmdlZCwgMTEgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEvbGliYXZmb3JtYXQvbWF0cm9z
a2FlbmMuYyBiL2xpYmF2Zm9ybWF0L21hdHJvc2thZW5jLmMKaW5kZXggNWRhZTUzMDI2ZDguLjNh
ZjA1NDAzZDFkIDEwMDY0NAotLS0gYS9saWJhdmZvcm1hdC9tYXRyb3NrYWVuYy5jCisrKyBiL2xp
YmF2Zm9ybWF0L21hdHJvc2thZW5jLmMKQEAgLTExNywxMCArMTE3LDYgQEAgdHlwZWRlZiBzdHJ1
Y3QgbWt2X2F0dGFjaG1lbnRzIHsKICNkZWZpbmUgTU9ERV9NQVRST1NLQXYyIDB4MDEKICNkZWZp
bmUgTU9ERV9XRUJNICAgICAgIDB4MDIKIAotLyoqIE1heGltdW0gbnVtYmVyIG9mIHRyYWNrcyBh
bGxvd2VkIGluIGEgTWF0cm9za2EgZmlsZSAod2l0aCB0cmFjayBudW1iZXJzIGluCi0gKiByYW5n
ZSAxIHRvIDEyNiAoaW5jbHVzaXZlKSAqLwotI2RlZmluZSBNQVhfVFJBQ0tTIDEyNgotCiB0eXBl
ZGVmIHN0cnVjdCBNYXRyb3NrYU11eENvbnRleHQgewogICAgIGNvbnN0IEFWQ2xhc3MgICAqY2xh
c3M7CiAgICAgaW50ICAgICAgICAgICAgIG1vZGU7CkBAIC0yNjA0LDEzICsyNjAwLDYgQEAgc3Rh
dGljIGludCBta3ZfaW5pdChzdHJ1Y3QgQVZGb3JtYXRDb250ZXh0ICpzKQogewogICAgIGludCBp
OwogCi0gICAgaWYgKHMtPm5iX3N0cmVhbXMgPiBNQVhfVFJBQ0tTKSB7Ci0gICAgICAgIGF2X2xv
ZyhzLCBBVl9MT0dfRVJST1IsCi0gICAgICAgICAgICAgICAiQXQgbW9zdCAlZCBzdHJlYW1zIGFy
ZSBzdXBwb3J0ZWQgZm9yIG11eGluZyBpbiBNYXRyb3NrYVxuIiwKLSAgICAgICAgICAgICAgIE1B
WF9UUkFDS1MpOwotICAgICAgICByZXR1cm4gQVZFUlJPUihFSU5WQUwpOwotICAgIH0KLQogICAg
IGZvciAoaSA9IDA7IGkgPCBzLT5uYl9zdHJlYW1zOyBpKyspIHsKICAgICAgICAgaWYgKHMtPnN0
cmVhbXNbaV0tPmNvZGVjcGFyLT5jb2RlY19pZCA9PSBBVl9DT0RFQ19JRF9BVFJBQzMgfHwKICAg
ICAgICAgICAgIHMtPnN0cmVhbXNbaV0tPmNvZGVjcGFyLT5jb2RlY19pZCA9PSBBVl9DT0RFQ19J
RF9DT09LIHx8Cg==
___
ffmpeg-devel mailing list
ffmpeg-devel@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/matroskaenc: add matroska subtitle muxer (.mks)

2020-04-03 Thread Jan Chren (rindeal)
RnJvbSBlYWE5ZjI2ODU0MzY3MjVlMTllYjk0ZTdmMmQwMTc0YmE1NmI3NDI5IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBKYW4gQ2hyZW4gKHJpbmRlYWwpIDxkZXYucmluZGVhbEBnbWFp
bC5jb20+CkRhdGU6IFRodSwgMSBBcHIgMjAyMCAwMDowMDowMCArMDAwMApTdWJqZWN0OiBbUEFU
Q0hdIGF2Zm9ybWF0L21hdHJvc2thZW5jOiBhZGQgbWF0cm9za2Egc3VidGl0bGUgbXV4ZXIgKC5t
a3MpCgpTaWduZWQtb2ZmLWJ5OiBKYW4gQ2hyZW4gKHJpbmRlYWwpIDxkZXYucmluZGVhbEBnbWFp
bC5jb20+Ci0tLQogbGliYXZmb3JtYXQvbWF0cm9za2FlbmMuYyB8IDI4ICsrKysrKysrKysrKysr
KysrKysrKysrKysrKysKIDEgZmlsZSBjaGFuZ2VkLCAyOCBpbnNlcnRpb25zKCspCgpkaWZmIC0t
Z2l0IGEvbGliYXZmb3JtYXQvbWF0cm9za2FlbmMuYyBiL2xpYmF2Zm9ybWF0L21hdHJvc2thZW5j
LmMKaW5kZXggNWRhZTUzMDI2ZDguLjYyMTI3ZmU5N2YwIDEwMDY0NAotLS0gYS9saWJhdmZvcm1h
dC9tYXRyb3NrYWVuYy5jCisrKyBiL2xpYmF2Zm9ybWF0L21hdHJvc2thZW5jLmMKQEAgLTI3OTMs
MyArMjc5MywzMSBAQCBBVk91dHB1dEZvcm1hdCBmZl9tYXRyb3NrYV9hdWRpb19tdXhlciA9IHsK
ICAgICAucHJpdl9jbGFzcyAgICAgICAgPSAmbWthX2NsYXNzLAogfTsKICNlbmRpZgorCisjaWYg
Q09ORklHX01BVFJPU0tBX1NVQlRJVExFX01VWEVSCitzdGF0aWMgY29uc3QgQVZDbGFzcyBta3Nf
Y2xhc3MgPSB7CisgICAgLmNsYXNzX25hbWUgPSAibWF0cm9za2Egc3VidGl0bGUgbXV4ZXIiLAor
ICAgIC5pdGVtX25hbWUgID0gYXZfZGVmYXVsdF9pdGVtX25hbWUsCisgICAgLm9wdGlvbiAgICAg
PSBvcHRpb25zLAorICAgIC52ZXJzaW9uICAgID0gTElCQVZVVElMX1ZFUlNJT05fSU5ULAorfTsK
K0FWT3V0cHV0Rm9ybWF0IGZmX21hdHJvc2thX3N1YnRpdGxlX211eGVyID0geworICAgIC5uYW1l
ICAgICAgICAgICAgICA9ICJtYXRyb3NrYSIsCisgICAgLmxvbmdfbmFtZSAgICAgICAgID0gTlVM
TF9JRl9DT05GSUdfU01BTEwoIk1hdHJvc2thIFN1YnRpdGxlcyIpLAorICAgIC5leHRlbnNpb25z
ICAgICAgICA9ICJta3MiLAorICAgIC5wcml2X2RhdGFfc2l6ZSAgICA9IHNpemVvZihNYXRyb3Nr
YU11eENvbnRleHQpLAorICAgIC5zdWJ0aXRsZV9jb2RlYyAgICA9IEFWX0NPREVDX0lEX0FTUywK
KyAgICAuaW5pdCAgICAgICAgICAgICAgPSBta3ZfaW5pdCwKKyAgICAuZGVpbml0ICAgICAgICAg
ICAgPSBta3ZfZGVpbml0LAorICAgIC53cml0ZV9oZWFkZXIgICAgICA9IG1rdl93cml0ZV9oZWFk
ZXIsCisgICAgLndyaXRlX3BhY2tldCAgICAgID0gbWt2X3dyaXRlX2ZsdXNoX3BhY2tldCwKKyAg
ICAud3JpdGVfdHJhaWxlciAgICAgPSBta3Zfd3JpdGVfdHJhaWxlciwKKyAgICAuY2hlY2tfYml0
c3RyZWFtICAgPSBta3ZfY2hlY2tfYml0c3RyZWFtLAorICAgIC5mbGFncyAgICAgICAgICAgICA9
IEFWRk1UX0dMT0JBTEhFQURFUiB8IEFWRk1UX1ZBUklBQkxFX0ZQUyB8CisgICAgICAgICAgICAg
ICAgICAgICAgICAgQVZGTVRfVFNfTk9OU1RSSUNUIHwgQVZGTVRfQUxMT1dfRkxVU0gsCisgICAg
LmNvZGVjX3RhZyAgICAgICAgID0gKGNvbnN0IEFWQ29kZWNUYWcqIGNvbnN0IFtdKXsKKyAgICAg
ICAgYWRkaXRpb25hbF9zdWJ0aXRsZV90YWdzLCAwCisgICAgfSwKKyAgICAucHJpdl9jbGFzcyAg
ICAgICAgPSAmbWtzX2NsYXNzLAorfTsKKyNlbmRpZgo=
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-04-03 Thread Limin Wang
On Fri, Apr 03, 2020 at 11:23:59PM +0200, Michael Niedermayer wrote:
> On Fri, Apr 03, 2020 at 11:05:59PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/mux.c| 16 
> >  tests/ref/fate/binsub-movtextenc |  2 +-
> >  tests/ref/fate/movenc| 50 +++
> >  tests/ref/fate/sub2video | 86 
> > 
> >  4 files changed, 85 insertions(+), 69 deletions(-)
> > 
> > diff --git a/libavformat/mux.c b/libavformat/mux.c
> > index cc2d1e2..dc897c2 100644
> > --- a/libavformat/mux.c
> > +++ b/libavformat/mux.c
> > @@ -548,6 +548,17 @@ fail:
> >  return ret;
> >  }
> >  
> > +static int is_intra_only(enum AVCodecID id)
> > +{
> > +const AVCodecDescriptor *d = avcodec_descriptor_get(id);
> > +if (!d)
> > +return 0;
> > +if ((d->type == AVMEDIA_TYPE_VIDEO || d->type == AVMEDIA_TYPE_AUDIO) &&
> > +!(d->props & AV_CODEC_PROP_INTRA_ONLY))
> > +return 0;
> > +return 1;
> > +}
> 
> this should not be duplicated with code in utils.c

OK

> 
> 
> > +
> >  #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
> >  
> >  /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but
> > @@ -664,6 +675,11 @@ static int compute_muxer_pkt_fields(AVFormatContext 
> > *s, AVStream *st, AVPacket *
> >  frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * 
> > st->time_base.num);
> >  break;
> >  }
> > +
> > +/* update flags */
> > +if (is_intra_only(st->codecpar->codec_id))
> > +pkt->flags |= AV_PKT_FLAG_KEY;
> > +
> 
> it may make sense to store the AVCodecDescriptor and not search it again for
> each packet. But then the "is_intra_only" itself also does not change so that
> should itself be computet just once per stream

Do you say we should add a is_intra_only field in AVStream to compute at 
beginning,
however it'll change the API header. So I prefer to use is_intra_only() 
function first,  

> 
> thx
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> I am the wisest man alive, for I know one thing, and that is that I know
> nothing. -- Socrates



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-04-03 Thread Limin Wang
On Fri, Apr 03, 2020 at 05:19:08PM +0200, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/mux.c| 16 
> >  tests/ref/fate/binsub-movtextenc |  2 +-
> >  tests/ref/fate/movenc| 50 +++
> >  tests/ref/fate/sub2video | 86 
> > 
> >  4 files changed, 85 insertions(+), 69 deletions(-)
> > 
> > diff --git a/libavformat/mux.c b/libavformat/mux.c
> > index cc2d1e2..dc897c2 100644
> > --- a/libavformat/mux.c
> > +++ b/libavformat/mux.c
> > @@ -548,6 +548,17 @@ fail:
> >  return ret;
> >  }
> >  
> > +static int is_intra_only(enum AVCodecID id)
> > +{
> > +const AVCodecDescriptor *d = avcodec_descriptor_get(id);
> > +if (!d)
> > +return 0;
> > +if ((d->type == AVMEDIA_TYPE_VIDEO || d->type == AVMEDIA_TYPE_AUDIO) &&
> > +!(d->props & AV_CODEC_PROP_INTRA_ONLY))
> > +return 0;
> > +return 1;
> > +}
> > +
> >  #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
> >  
> >  /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but
> > @@ -664,6 +675,11 @@ static int compute_muxer_pkt_fields(AVFormatContext 
> > *s, AVStream *st, AVPacket *
> >  frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * 
> > st->time_base.num);
> >  break;
> >  }
> > +
> > +/* update flags */
> > +if (is_intra_only(st->codecpar->codec_id))
> > +pkt->flags |= AV_PKT_FLAG_KEY;
> > +
> >  return 0;
> >  }
> >  FF_ENABLE_DEPRECATION_WARNINGS
> 
> You have added the check to code that is deprecated and slated to be
> removed. Maybe it would be better to add it to prepare_input_packet()
> instead?

OK, I'll move the check to prepare_input_packet.

> 
> > diff --git a/tests/ref/fate/binsub-movtextenc 
> > b/tests/ref/fate/binsub-movtextenc
> > index 78c05f4..a8f94b7 100644
> > --- a/tests/ref/fate/binsub-movtextenc
> > +++ b/tests/ref/fate/binsub-movtextenc
> > @@ -1 +1 @@
> > -35adf776cd73e808186ae7124445f4b8
> > +fc6d07679ac1f718aa50de687924cd97
> > diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
> > index 637a347..fb39b98 100644
> > --- a/tests/ref/fate/movenc
> > +++ b/tests/ref/fate/movenc
> > @@ -2,17 +2,17 @@ write_data len 36, time nopts, type header atom ftyp
> >  write_data len 2389, time nopts, type header atom -
> >  write_data len 788, time 100, type sync atom moof
> >  write_data len 110, time nopts, type trailer atom -
> > -66cf48604f039aa9a51711786f5c8778 3323 non-empty-moov
> > +5f401347fc3c771b819e2449d69d4861 3323 non-empty-moov
> >  write_data len 36, time nopts, type header atom ftyp
> >  write_data len 2721, time nopts, type header atom -
> >  write_data len 908, time 97, type sync atom moof
> >  write_data len 110, time nopts, type trailer atom -
> > -04b2e86f455af94f9258b8d66dbf71f5 3775 non-empty-moov-elst
> > +4267feee527adf8cd4f7b36ac0fc0872 3775 non-empty-moov-elst
> >  write_data len 36, time nopts, type header atom ftyp
> >  write_data len 2629, time nopts, type header atom -
> >  write_data len 908, time 100, type sync atom moof
> >  write_data len 110, time nopts, type trailer atom -
> > -e9f6fa032d6d8265d67aef5de81a48bf 3683 non-empty-moov-no-elst
> > +44077b9ad45f3e16fafe4e5ada54e9b0 3683 non-empty-moov-no-elst
> >  write_data len 24, time nopts, type header atom ftyp
> [...]
> > -1,  22564,  22564,  2127000, 2133, 0x670c11a5, F=0x0
> > +1,  22564,  22564,  2127000, 2133, 0x670c11a5
> >  0,   1139,   1139,1,   518400, 0xbab197ea
> > -1,  227834000,  227834000,  1262000, 1264, 0xc1d9fc57, F=0x0
> > +1,  227834000,  227834000,  1262000, 1264, 0xc1d9fc57
> >  0,   1140,   1140,1,   518400, 0xb046dd30
> >  0,   1145,   1145,1,   518400, 0xbab197ea
> > 
> Have you checked whether all these changes are beneficial?

I think it's caused by the keyframe flags, so have no clue how to check
the beneficial for these fate testing.


> 
> - 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 v3 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/encoders.texi  |  8 
 libavcodec/mpeg12enc.c | 22 +-
 libavcodec/mpegvideo.h |  1 +
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index e23b6b3..5022b94 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2753,6 +2753,14 @@ For maximum compatibility, use @samp{component}.
 @item a53cc @var{boolean}
 Import closed captions (which must be ATSC compatible format) into output.
 Default is 1 (on).
+@item profile @var{integer}
+Select the mpeg2 profile to encode, possible values:
+@table @samp
+@item 422
+@item high
+@item main
+@item simple
+@end table
 @end table
 
 @section png
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 643ba81..9fe0c8b 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -156,23 +156,30 @@ static av_cold int encode_init(AVCodecContext *avctx)
 }
 }
 
-if (avctx->profile == FF_PROFILE_UNKNOWN) {
+if (s->profile == FF_PROFILE_UNKNOWN)
+s->profile = avctx->profile;
+
+if (s->profile == FF_PROFILE_UNKNOWN) {
 if (avctx->level != FF_LEVEL_UNKNOWN) {
 av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
 return -1;
 }
 /* Main or 4:2:2 */
 avctx->profile = s->chroma_format == CHROMA_420 ? 
FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
+s->profile = s->chroma_format == CHROMA_420 ? FF_PROFILE_MPEG2_MAIN : 
FF_PROFILE_MPEG2_422;
+} else if (s->profile < FF_PROFILE_MPEG2_422) {
+av_log(avctx, AV_LOG_ERROR, "Invalid mpeg2 profile set\n");
+return -1;
 }
 
 if (avctx->level == FF_LEVEL_UNKNOWN) {
-if (avctx->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
+if (s->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
 if (avctx->width <= 720 && avctx->height <= 608)
 avctx->level = 5;   /* Main */
 else
 avctx->level = 2;   /* High */
 } else {
-if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
+if (s->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
 av_log(avctx, AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color 
sampling\n");
 return -1;
@@ -321,9 +328,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 put_header(s, EXT_START_CODE);
 put_bits(>pb, 4, 1); // seq ext
 
-put_bits(>pb, 1, s->avctx->profile == FF_PROFILE_MPEG2_422); // 
escx 1 for 4:2:2 profile
+put_bits(>pb, 1, s->profile == FF_PROFILE_MPEG2_422); // escx 1 
for 4:2:2 profile
 
-put_bits(>pb, 3, s->avctx->profile); // profile
+put_bits(>pb, 3, s->profile); // profile
 put_bits(>pb, 4, s->avctx->level);   // level
 
 put_bits(>pb, 1, s->progressive_sequence);
@@ -1165,6 +1172,11 @@ static const AVOption mpeg2_options[] = {
 { "secam",NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_SECAM  },  0, 0, VE, "video_format" },
 { "mac",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_MAC},  0, 0, VE, "video_format" },
 { "unspecified",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_UNSPECIFIED},  0, 0, VE, "video_format" },
+{ "profile",  "Set the profile",  OFFSET(profile),   
AV_OPT_TYPE_INT,{ .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 
FF_PROFILE_MPEG2_SIMPLE, VE, "profile" },
+{ "422",  "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_422 }, 0, 0, VE, "profile" },
+{ "high", "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_HIGH}, 0, 0, VE, "profile" },
+{ "main", "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_MAIN}, 0, 0, VE, "profile" },
+{ "simple",   "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_SIMPLE  }, 0, 0, VE, "profile" },
 FF_MPV_COMMON_OPTS
 { NULL },
 };
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 29e692f..cee423e 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -456,6 +456,7 @@ typedef struct MpegEncContext {
 int progressive_sequence;
 int mpeg_f_code[2][2];
 int a53_cc;
+int profile;
 
 // picture structure defines are loaded from mpegutils.h
 int picture_structure;
-- 
2.9.5

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

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

Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread Limin Wang
On Fri, Apr 03, 2020 at 03:47:09PM +, Fu, Linjie wrote:
> > From: ffmpeg-devel  On Behalf Of
> > Limin Wang
> > Sent: Friday, April 3, 2020 22:55
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support
> > mpeg2 encoder profile with const options
> > 
> > On Fri, Apr 03, 2020 at 04:25:15PM +0200, Hendrik Leppkes wrote:
> > > On Fri, Apr 3, 2020 at 3:12 PM  wrote:
> > > >
> > > > From: Limin Wang 
> > > >
> > > > make setting profile more user friendly
> > > >
> > >
> > > Please make sure API users can still set it through avctx->profile,
> > > otherwise this would be an API break.
> > 
> > Right, I'll update the patch to check avctx->profile != unknown, then
> > overwrite
> > the s->profile with it to void API break.
> > 
> Would it be better to determine the profile with a priority like:
> 1.s->profile; then
> 2. avctx->profile; then
> 3. a default profile;
> in case both avctx->profile and s->profile are set?
> 
> If user set a profile explicitly (through either option in cmdline or 
> av_opt_set()), 
> above priority seems to be natural. (and libx264 [1] has the same logic)
I'm OK with the logic, will update the patch change the priority. thx.

> 
> - Linjie
> 
> [1] https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libx264.c#L806
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 v10 3/3] libavcodec/jpeg2000dec.c: Fix indentation

2020-04-03 Thread Michael Niedermayer
On Fri, Apr 03, 2020 at 11:57:58PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> ---
>  libavcodec/jpeg2000dec.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)

will apply

thx

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

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


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

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

Re: [FFmpeg-devel] [PATCH v10 2/3] libavcodec/jpeg2000dec.c: Handle non EOC streams

2020-04-03 Thread Michael Niedermayer
On Fri, Apr 03, 2020 at 11:57:57PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> This patch allows decoding of j2k streams which do
> not have an EOC marker.
> ---
>  libavcodec/jpeg2000dec.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato


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

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

Re: [FFmpeg-devel] [PATCH v10 1/3] libavcodec/jpeg2000dec.c: Add support for PPT marker

2020-04-03 Thread Michael Niedermayer
On Fri, Apr 03, 2020 at 11:57:56PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> This patch adds functional changes to support the
> PPT marker.
> ---
>  libavcodec/jpeg2000dec.c | 88 
>  1 file changed, 79 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 7103cd6ceb..02905b9e49 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
>  Jpeg2000QuantStyle  qntsty[4];
>  Jpeg2000POC poc;
>  Jpeg2000TileParttile_part[32];
> +uint8_t has_ppt;// whether this tile has a 
> ppt marker
> +uint8_t *packed_headers;// contains packed headers. 
> Used only along with PPT marker
> +int packed_headers_size;// size in bytes of the 
> packed headers
> +GetByteContext  packed_headers_stream;  // byte context 
> corresponding to packed headers
>  uint16_t tp_idx;// Tile-part index
>  int coord[2][2];// border coordinates {{x0, x1}, 
> {y0, y1}}
>  } Jpeg2000Tile;
> @@ -855,6 +859,39 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
>  return 0;
>  }
>  
> +static int get_ppt(Jpeg2000DecoderContext *s, int n)
> +{
> +Jpeg2000Tile *tile;
> +
> +if (s->curtileno < 0)
> +return AVERROR_INVALIDDATA;
> +
> +tile = >tile[s->curtileno];
> +if (tile->tp_idx != 0) {
> +av_log(s->avctx, AV_LOG_ERROR,
> +   "PPT marker can occur only on first tile part of a tile.\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +tile->has_ppt = 1;  // this tile has a ppt marker
> +/*Zppt = */ bytestream2_get_byte(>g); // Zppt is skipped and not used
> +if (!tile->packed_headers) {
> +tile->packed_headers = av_malloc_array(n - 3, 1);

av_malloc() or av_realloc seems to make more sense here, the *1 isnt usefull


> +memcpy(tile->packed_headers, s->g.buffer, n - 3);

missing check for malloc failure


> +tile->packed_headers_size = n - 3;
> +} else {
> +tile->packed_headers = av_realloc_array(tile->packed_headers,
> +tile->packed_headers_size + 
> n - 3,
> +1);
> +memcpy(tile->packed_headers + tile->packed_headers_size,
> +   s->g.buffer, n - 3);
> +tile->packed_headers_size += n - 3;
> +}

isnt packed_headers_size 0 before the initial allocation ?
if so the if and else can be simplified



> +bytestream2_skip(>g, n - 3);
> +
> +return 0;
> +}
> +
>  static int init_tile(Jpeg2000DecoderContext *s, int tileno)
>  {
>  int compno;
> @@ -938,19 +975,23 @@ static int 
> jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>  if (layno < rlevel->band[0].prec[precno].decoded_layers)
>  return 0;
>  rlevel->band[0].prec[precno].decoded_layers = layno + 1;
> -
> -if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
> -if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> -s->g = tile->tile_part[++(*tp_index)].tpg;
> +// Select stream to read from
> +if (tile->has_ppt) {
> +s->g = tile->packed_headers_stream;
> +} else {
> +s->g = tile->tile_part[*tp_index].tpg;
> +if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
> +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> +s->g = tile->tile_part[++(*tp_index)].tpg;
> +}
>  }
> +if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
> +bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
>  }
>  
> -if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
> -bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
> -
>  if (!(ret = get_bits(s, 1))) {
>  jpeg2000_flush(s);
> -return 0;
> +goto skip_data;
>  } else if (ret < 0)
>  return ret;
>  
> @@ -1056,6 +1097,18 @@ static int 
> jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>  av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead 
> %X\n", bytestream2_peek_be32(>g));
>  }
>  
> +// Save state of stream
> +if (tile->has_ppt) {

> +tile->packed_headers_stream = s->g;
> +s->g = tile->tile_part[*tp_index].tpg;
> +if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
> +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> +s->g = tile->tile_part[++(*tp_index)].tpg;
> +}
> +}
> +if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
> +bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);

This looks like duplicated code, maybe this is cleaner if its factored into a 
seperate function

[FFmpeg-devel] [PATCH]lavf, lavfi: Remove uses of sizeof(char)

2020-04-03 Thread Carl Eugen Hoyos
Hi!

Attached patch removes uses of sizeof(char) from libavfilter and libavformat.

Please comment, Carl Eugen
From eb8c99ab8b714b8699adfb252723ee66f00cd00f Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 4 Apr 2020 01:30:14 +0200
Subject: [PATCH] lavf, lavfi: Remove uses of sizeof(char).

FFmpeg relies on sizeof(char) == 1.
---
 libavfilter/dnn/dnn_backend_tf.c | 2 +-
 libavfilter/vf_deshake.c | 4 ++--
 libavformat/webmdashenc.c| 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index a921667424..9ceca5cea0 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -95,7 +95,7 @@ static TF_Tensor *allocate_input_tensor(const DNNData *input)
 break;
 case DNN_UINT8:
 dt = TF_UINT8;
-size = sizeof(char);
+size = 1;
 break;
 default:
 av_assert0(!"should not reach here");
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index b516ea2d59..28a541b94a 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -354,7 +354,7 @@ static av_cold int init(AVFilterContext *ctx)
 if (deshake->filename)
 deshake->fp = fopen(deshake->filename, "w");
 if (deshake->fp)
-fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", sizeof(char), 104, deshake->fp);
+fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", 1, 104, deshake->fp);
 
 // Quadword align left edge of box for MMX code, adjust width if necessary
 // to keep right margin
@@ -485,7 +485,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 // Write statistics to file
 if (deshake->fp) {
 snprintf(tmp, 256, "%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", orig.vec.x, deshake->avg.vec.x, t.vec.x, orig.vec.y, deshake->avg.vec.y, t.vec.y, orig.angle, deshake->avg.angle, t.angle, orig.zoom, deshake->avg.zoom, t.zoom);
-fwrite(tmp, sizeof(char), strlen(tmp), deshake->fp);
+fwrite(tmp, 1, strlen(tmp), deshake->fp);
 }
 
 // Turn relative current frame motion into absolute by adding it to the
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index d05b265330..7847659c63 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -439,7 +439,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
 static int to_integer(char *p, int len)
 {
 int ret;
-char *q = av_malloc(sizeof(char) * len);
+char *q = av_malloc(len);
 if (!q)
 return AVERROR(ENOMEM);
 av_strlcpy(q, p, len);
-- 
2.24.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]lavu/mem: Make alloc array functions more similar to av_malloc

2020-04-03 Thread Carl Eugen Hoyos
Hi!

Attached patch makes the alloc array functions more similar to
av_malloc, depending on max_alloc_size instead of INT_MAX.

Allows a work-around for ticket #7140

Please comment, Carl Eugen
From 7ae240a9f7885130251031aba5d0764b11947fec Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 4 Apr 2020 00:37:03 +0200
Subject: [PATCH] lavu/mem: Make alloc array functions more similar to
 av_malloc().

Do not limit the array allocation functions to allocations of INT_MAX,
instead depend on max_alloc_size like av_malloc().

Allows a workaround for ticket #7140.
---
 libavutil/mem.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 88fe09b179..8783b85a45 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -183,21 +183,21 @@ int av_reallocp(void *ptr, size_t size)
 
 void *av_malloc_array(size_t nmemb, size_t size)
 {
-if (!size || nmemb >= INT_MAX / size)
+if (!size || nmemb >= SIZE_MAX / size)
 return NULL;
 return av_malloc(nmemb * size);
 }
 
 void *av_mallocz_array(size_t nmemb, size_t size)
 {
-if (!size || nmemb >= INT_MAX / size)
+if (!size || nmemb >= SIZE_MAX / size)
 return NULL;
 return av_mallocz(nmemb * size);
 }
 
 void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
 {
-if (!size || nmemb >= INT_MAX / size)
+if (!size || nmemb >= SIZE_MAX / size)
 return NULL;
 return av_realloc(ptr, nmemb * size);
 }
@@ -243,7 +243,7 @@ void *av_mallocz(size_t size)
 
 void *av_calloc(size_t nmemb, size_t size)
 {
-if (size <= 0 || nmemb >= INT_MAX / size)
+if (size <= 0 || nmemb >= SIZE_MAX / size)
 return NULL;
 return av_mallocz(nmemb * size);
 }
-- 
2.24.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]lavfi/telecine: Mark telecined frames as interlaced

2020-04-03 Thread Carl Eugen Hoyos
Am Sa., 4. Apr. 2020 um 00:40 Uhr schrieb James Almer :
>
> On 4/3/2020 6:37 PM, Carl Eugen Hoyos wrote:
> > Am Fr., 3. Apr. 2020 um 23:19 Uhr schrieb Carl Eugen Hoyos 
> > :
> >
> >> Attached patch marks actually telecined frames as interlaced,
> >> other frames as progressive.
> >
> > New patch with changes to fate attached.
> >
> > Please comment, Carl Eugen
>
> Those yadif tests look wrong. The patch shouldn't affect them.

Clearly, thank you!

New patch attached, it should now only change the telecined
frames and leave the other frames as they are, the setfield
filter can be used to force a progressive setting for them.

Please review, Carl Eugen
From 97f3bba7b4f4f4bf4bbb69376daeb45e3386ba62 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Fri, 3 Apr 2020 23:04:15 +0200
Subject: [PATCH] lavfi/telecine: Mark telecined frames as interlaced.

---
 libavfilter/vf_telecine.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 62599a7a3a..3e65f08e39 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -207,6 +207,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 s->stride[i],
 (s->planeheight[i] - !s->first_field + 1) / 2);
 }
+s->frame[nout]->interlaced_frame = 1;
 nout++;
 len--;
 s->occupied = 0;
@@ -220,6 +221,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 inpicref->data[i], inpicref->linesize[i],
 s->stride[i],
 s->planeheight[i]);
+s->frame[nout]->interlaced_frame = inpicref->interlaced_frame;
 nout++;
 len -= 2;
 }
@@ -236,6 +238,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 
 for (i = 0; i < nout; i++) {
 AVFrame *frame = av_frame_clone(s->frame[i]);
+int interlaced = frame->interlaced_frame;
 
 if (!frame) {
 av_frame_free();
@@ -243,6 +246,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 }
 
 av_frame_copy_props(frame, inpicref);
+frame->interlaced_frame = interlaced;
 frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
  av_rescale(outlink->frame_count_in, s->ts_unit.num,
 s->ts_unit.den);
diff --git a/tests/ref/fate/filter-pixfmts-fieldmatch b/tests/ref/fate/filter-pixfmts-fieldmatch
index c3165b872d..eb0fc3c224 100644
--- a/tests/ref/fate/filter-pixfmts-fieldmatch
+++ b/tests/ref/fate/filter-pixfmts-fieldmatch
@@ -1,5 +1,5 @@
-yuv410p a6c9b4065e8253d8120772f69be0bf04
-yuv411p b913e634ad37ce046240252bed8681fb
-yuv420p a9286560141eb14595e427dbe5829b00
-yuv422p 11ad22ce00c5e8a30d0472f29fb15434
-yuv444p 6c5b0c1343d625d0656b6755906fd874
+yuv410p 572e4416ae6988dab3dbdbed3296b57c
+yuv411p ce9ccbb1985b7840955e57c23d4bc003
+yuv420p f06c53990f577893fef6a4270aab691b
+yuv422p 1c6ad2c3198ad577593214ebc9bc5705
+yuv444p 24813e175b1b09c01f5ec16149d83fce
diff --git a/tests/ref/fate/filter-pixfmts-pullup b/tests/ref/fate/filter-pixfmts-pullup
index c6ddb3489a..88c1dd565d 100644
--- a/tests/ref/fate/filter-pixfmts-pullup
+++ b/tests/ref/fate/filter-pixfmts-pullup
@@ -1,12 +1,12 @@
-gray415c928947f83f9b45c24ad15a094bda
-yuv410p 0f29d0b6394871e1e6cde484b4f351f4
-yuv411p ec059b1992e1acda472b9b2dd3e4506b
-yuv420p dba6303cd02cc39cb0db7b546793d565
-yuv422p d7d3224dd900bb1b96608a28a704360d
-yuv440p d4c5f20701cfceb4bbf7d75cfcc13514
-yuv444p 7e405274037e7f2ab845d7413a71e16d
-yuvj411pdc602e7bd3449d16e17e695815616b1e
-yuvj420pb98ec86eeef2d512aeb2fc4d32ffa656
-yuvj422pf09c3240bb662477b76ce4da34b4feed
-yuvj440p8d3ab69e2bd2f9be323c18922533
-yuvj444p2dc27560eed5d685354796de853c
+gray0af7cbb0cfb3efcb946e697c4b7bd5f9
+yuv410p c7a9e3aeb6b30eadcdf6ca5acb52c5b2
+yuv411p 2e19fb03dd57e4700ff560da3a84402e
+yuv420p 7019c5de9774970eb3a7828cb92439e8
+yuv422p 8fc1c9fff0aa2566a50ff10a54e80ba7
+yuv440p 16775691a106117ecd244c45252f4ba7
+yuv444p b6ec514e4c30fea6b0dd696bf7d147d5
+yuvj411p0b899555985616330109a2381d9828a4
+yuvj420p1f51fe0c2c8d5ba12409bc4c821fed56
+yuvj422p5e9a13247fe5201ea83d3a64241631e3
+yuvj440p2e22b2e340f372792bec5ba0a8f46822
+yuvj444pbecc016653bb26b472625d87dbfc10c4
___
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]lavfi/telecine: Mark telecined frames as interlaced

2020-04-03 Thread James Almer
On 4/3/2020 6:37 PM, Carl Eugen Hoyos wrote:
> Am Fr., 3. Apr. 2020 um 23:19 Uhr schrieb Carl Eugen Hoyos 
> :
> 
>> Attached patch marks actually telecined frames as interlaced,
>> other frames as progressive.
> 
> New patch with changes to fate attached.
> 
> Please comment, Carl Eugen

Those yadif tests look wrong. The patch shouldn't affect them.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [inline assembly compliance] Issues and patches

2020-04-03 Thread Michael Niedermayer
On Fri, Apr 03, 2020 at 10:41:58PM +0200, FRÉDÉRIC RECOULES wrote:
> Dear developpers, 
> 
> 
> 
> we are academic researchers working in automated program analysis. 
> We are currently interested in checking compliance of inline asm chunks 
> as found in C programs. 
> 
> While benchmarking our tool and technique, we found a number of issues in 
> FFMPEG. We report them to you, as well as adequate patches. 
> Actually, we found 59 significant compliance issues in your code. 
> We join 3 patches for some of them, together with explanations and 
> we can send you other patches on demand. 
> 
> 
> * All these bugs are related to compliance between the block of asm and its 
> surrounding "contract" (in gcc-style notation). They are akin to undefined or 
> implementation-defined behaviours in C: they currently do not manifest 
> themselves in your program, but at some point in time with compiler 
> optimizations becoming more and more aggressive or changes in undocumented 
> compiler choices regarding asm chunks, they can suddenly trigger a 
> (hard-to-find) bug. 
> 
> * The typical problems come from the compiler missing dataflow information 
> and performing undue optimizations on this wrong basis, or the compiler 
> allocating an already used register. Actually, we demonstrate "in lab" 
> problems 
> with all these categories of bugs in case of inlining 
> (especially with LTO enabler) or code refactoring. 
> 
> * Some of those issues may seems benign or irrealistic but it cost nothing 
> to patch so, why not do it? 
> 
> 
> We would be very interested to hear your opinion on these matters. 
> Are you interested in such errors and patches? 
> Also, besides the patches, we are currently working on a code analyzer 
> prototype designed to check asm compliance and to propose patches when the 
> chunk is not compliant. This is still work in progress and we are finalizing 
> it. 
> The errors and patches I reported to you came from my prototype. 
> In case such a prototype would be made available, would you consider using 
> it? 
> 
> 
> 
> Best regards 
> 
> Frédéric Recoules 

This breaks build with shared libs

In file included from src/libavcodec/x86/hpeldsp_init.c:104:
src/libavcodec/x86/rnd_template.c:102:30: error: dereference of pointer to 
incomplete type 'const uint8_t []'
  "m"   (*(const uint8_t (*)[])pixels),
 ^
src/libavcodec/x86/rnd_template.c:188:30: error: dereference of pointer to 
incomplete type 'const uint8_t []'
  "m"   (*(const uint8_t (*)[])pixels),
 ^
In file included from src/libavcodec/x86/hpeldsp_init.c:139:
src/libavcodec/x86/rnd_template.c:102:30: error: dereference of pointer to 
incomplete type 'const uint8_t []'
  "m"   (*(const uint8_t (*)[])pixels),
 ^
src/libavcodec/x86/rnd_template.c:188:30: error: dereference of pointer to 
incomplete type 'const uint8_t []'
  "m"   (*(const uint8_t (*)[])pixels),
 ^
4 errors generated.
src/ffbuild/common.mak:59: recipe for target 'libavcodec/x86/hpeldsp_init.o' 
failed
make: *** [libavcodec/x86/hpeldsp_init.o] Error 1



[...]
> diff --git a/libavcodec/x86/rnd_template.c b/libavcodec/x86/rnd_template.c
> index 09946bd23f..1be010e066 100644
> --- a/libavcodec/x86/rnd_template.c
> +++ b/libavcodec/x86/rnd_template.c
> @@ -30,146 +30,164 @@
>  #include "inline_asm.h"
> 
>  // put_pixels
> -av_unused STATIC void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t 
> *pixels,
> -  ptrdiff_t line_size, int h)
> +av_unused STATIC void DEF(put, pixels8_xy2)(uint8_t *block,
> + const uint8_t *pixels,
> + ptrdiff_t line_size, int h)

unrelated whitespace change


>  {
> -MOVQ_ZERO(mm7);
> -SET_RND(mm6); // =2 for rnd  and  =1 for no_rnd version
> -__asm__ volatile(
> -"movq   (%1), %%mm0 \n\t"
> -"movq   1(%1), %%mm4\n\t"
> -"movq   %%mm0, %%mm1\n\t"
> -"movq   %%mm4, %%mm5\n\t"
> -"punpcklbw %%mm7, %%mm0 \n\t"
> -"punpcklbw %%mm7, %%mm4 \n\t"
> -"punpckhbw %%mm7, %%mm1 \n\t"
> -"punpckhbw %%mm7, %%mm5 \n\t"
> -"paddusw %%mm0, %%mm4   \n\t"
> -"paddusw %%mm1, %%mm5   \n\t"
> -"xor%%"FF_REG_a", %%"FF_REG_a" \n\t"
> -"add%3, %1  \n\t"
> -".p2align 3 \n\t"
> -"1: \n\t"
> -"movq   (%1, %%"FF_REG_a"), %%mm0  \n\t"
> -"movq   1(%1, %%"FF_REG_a"), %%mm2 \n\t"
> -"movq   %%mm0, %%mm1\n\t"
> -"movq   %%mm2, %%mm3\n\t"
> -"punpcklbw %%mm7, %%mm0 \n\t"
> -"punpcklbw %%mm7, %%mm2 \n\t"
> -  

[FFmpeg-devel] [PATCH] avcodec/amfenc: adapt to the new internal encode API

2020-04-03 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/amfenc.c  | 45 
 libavcodec/amfenc.h  |  2 ++
 libavcodec/amfenc_h264.c |  1 -
 libavcodec/amfenc_hevc.c |  1 -
 4 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c
index 876fddd2b6..d318c21978 100644
--- a/libavcodec/amfenc.c
+++ b/libavcodec/amfenc.c
@@ -33,6 +33,7 @@
 #include "libavutil/time.h"
 
 #include "amfenc.h"
+#include "encode.h"
 #include "internal.h"
 
 #if CONFIG_D3D11VA
@@ -112,6 +113,10 @@ static int amf_load_library(AVCodecContext *avctx)
 AMFQueryVersion_Fn version_fun;
 AMF_RESULT res;
 
+ctx->frame = av_frame_alloc();
+if (!ctx->frame) {
+return AVERROR(ENOMEM);
+}
 ctx->delayed_frame = av_frame_alloc();
 if (!ctx->delayed_frame) {
 return AVERROR(ENOMEM);
@@ -401,6 +406,7 @@ int av_cold ff_amf_encode_close(AVCodecContext *avctx)
 ctx->factory = NULL;
 ctx->version = 0;
 ctx->delayed_drain = 0;
+av_frame_free(>frame);
 av_frame_free(>delayed_frame);
 av_fifo_freep(>timestamp_list);
 
@@ -588,17 +594,27 @@ static void amf_release_buffer_with_frame_ref(AMFBuffer 
*frame_ref_storage_buffe
 frame_ref_storage_buffer->pVtbl->Release(frame_ref_storage_buffer);
 }
 
-int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame)
+int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
 {
 AmfContext *ctx = avctx->priv_data;
 AMFSurface *surface;
 AMF_RESULT  res;
 int ret;
+AMF_RESULT  res_query;
+AMFData*data = NULL;
+AVFrame*frame = ctx->frame;
+int block_and_wait;
 
 if (!ctx->encoder)
 return AVERROR(EINVAL);
 
-if (!frame) { // submit drain
+if (!frame->buf[0]) {
+ret = ff_encode_get_frame(avctx, frame);
+if (ret < 0 && ret != AVERROR_EOF)
+return ret;
+}
+
+if (!frame->buf[0]) { // submit drain
 if (!ctx->eof) { // submit drain one time only
 if (ctx->delayed_surface != NULL) {
 ctx->delayed_drain = 1; // input queue is full: resubmit 
Drain() in ff_amf_receive_packet
@@ -613,15 +629,10 @@ int ff_amf_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
 AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, 
"Drain() failed with error %d\n", res);
 }
 }
-} else{
-return AVERROR_EOF;
 }
-} else { // submit frame
+} else if (!ctx->delayed_surface) { // submit frame
 int hw_surface = 0;
 
-if (ctx->delayed_surface != NULL) {
-return AVERROR(EAGAIN); // should not happen when called from 
ffmpeg, other clients may resubmit
-}
 // prepare surface from frame
 switch (frame->format) {
 #if CONFIG_D3D11VA
@@ -693,38 +704,28 @@ int ff_amf_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
 break;
 }
 
-
 // submit surface
 res = ctx->encoder->pVtbl->SubmitInput(ctx->encoder, 
(AMFData*)surface);
 if (res == AMF_INPUT_FULL) { // handle full queue
 //store surface for later submission
 ctx->delayed_surface = surface;
 if (surface->pVtbl->GetMemoryType(surface) == AMF_MEMORY_DX11) {
-av_frame_ref(ctx->delayed_frame, frame);
+av_frame_move_ref(ctx->delayed_frame, frame);
 }
 } else {
 surface->pVtbl->Release(surface);
 AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, 
"SubmitInput() failed with error %d\n", res);
 
 if ((ret = timestamp_queue_enqueue(avctx, frame->pts)) < 0) {
+av_frame_unref(frame);
 return ret;
 }
 
 }
+
+av_frame_unref(frame);
 }
-return 0;
-}
-int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
-{
-int ret;
-AMF_RESULT  res;
-AMF_RESULT  res_query;
-AmfContext *ctx = avctx->priv_data;
-AMFData*data = NULL;
-int block_and_wait;
 
-if (!ctx->encoder)
-return AVERROR(EINVAL);
 
 do {
 block_and_wait = 0;
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
index b1361842bd..39cbdc881c 100644
--- a/libavcodec/amfenc.h
+++ b/libavcodec/amfenc.h
@@ -65,6 +65,8 @@ typedef struct AmfContext {
 int hwsurfaces_in_queue;
 int hwsurfaces_in_queue_max;
 
+AVFrame*frame;
+
 // helpers to handle async calls
 int delayed_drain;
 AMFSurface *delayed_surface;
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index 7f2817f115..7a8029f3b7 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -383,7 +383,6 @@ AVCodec ff_h264_amf_encoder = {
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = 

Re: [FFmpeg-devel] [PATCH]lavfi/telecine: Mark telecined frames as interlaced

2020-04-03 Thread Carl Eugen Hoyos
Am Fr., 3. Apr. 2020 um 23:19 Uhr schrieb Carl Eugen Hoyos :

> Attached patch marks actually telecined frames as interlaced,
> other frames as progressive.

New patch with changes to fate attached.

Please comment, Carl Eugen
From 97f3bba7b4f4f4bf4bbb69376daeb45e3386ba62 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Fri, 3 Apr 2020 23:04:15 +0200
Subject: [PATCH] lavfi/telecine: Mark telecined frames as interlaced.

---
 libavfilter/vf_telecine.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 62599a7a3a..3e65f08e39 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -207,6 +207,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 s->stride[i],
 (s->planeheight[i] - !s->first_field + 1) / 2);
 }
+s->frame[nout]->interlaced_frame = 1;
 nout++;
 len--;
 s->occupied = 0;
@@ -220,6 +221,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 inpicref->data[i], inpicref->linesize[i],
 s->stride[i],
 s->planeheight[i]);
+s->frame[nout]->interlaced_frame = inpicref->interlaced_frame;
 nout++;
 len -= 2;
 }
@@ -236,6 +238,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 
 for (i = 0; i < nout; i++) {
 AVFrame *frame = av_frame_clone(s->frame[i]);
+int interlaced = frame->interlaced_frame;
 
 if (!frame) {
 av_frame_free();
@@ -243,6 +246,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 }
 
 av_frame_copy_props(frame, inpicref);
+frame->interlaced_frame = interlaced;
 frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
  av_rescale(outlink->frame_count_in, s->ts_unit.num,
 s->ts_unit.den);
diff --git a/tests/ref/fate/filter-pixfmts-fieldmatch b/tests/ref/fate/filter-pixfmts-fieldmatch
index c3165b872d..eb0fc3c224 100644
--- a/tests/ref/fate/filter-pixfmts-fieldmatch
+++ b/tests/ref/fate/filter-pixfmts-fieldmatch
@@ -1,5 +1,5 @@
-yuv410p a6c9b4065e8253d8120772f69be0bf04
-yuv411p b913e634ad37ce046240252bed8681fb
-yuv420p a9286560141eb14595e427dbe5829b00
-yuv422p 11ad22ce00c5e8a30d0472f29fb15434
-yuv444p 6c5b0c1343d625d0656b6755906fd874
+yuv410p 572e4416ae6988dab3dbdbed3296b57c
+yuv411p ce9ccbb1985b7840955e57c23d4bc003
+yuv420p f06c53990f577893fef6a4270aab691b
+yuv422p 1c6ad2c3198ad577593214ebc9bc5705
+yuv444p 24813e175b1b09c01f5ec16149d83fce
diff --git a/tests/ref/fate/filter-pixfmts-pullup b/tests/ref/fate/filter-pixfmts-pullup
index c6ddb3489a..88c1dd565d 100644
--- a/tests/ref/fate/filter-pixfmts-pullup
+++ b/tests/ref/fate/filter-pixfmts-pullup
@@ -1,12 +1,12 @@
-gray415c928947f83f9b45c24ad15a094bda
-yuv410p 0f29d0b6394871e1e6cde484b4f351f4
-yuv411p ec059b1992e1acda472b9b2dd3e4506b
-yuv420p dba6303cd02cc39cb0db7b546793d565
-yuv422p d7d3224dd900bb1b96608a28a704360d
-yuv440p d4c5f20701cfceb4bbf7d75cfcc13514
-yuv444p 7e405274037e7f2ab845d7413a71e16d
-yuvj411pdc602e7bd3449d16e17e695815616b1e
-yuvj420pb98ec86eeef2d512aeb2fc4d32ffa656
-yuvj422pf09c3240bb662477b76ce4da34b4feed
-yuvj440p8d3ab69e2bd2f9be323c18922533
-yuvj444p2dc27560eed5d685354796de853c
+gray0af7cbb0cfb3efcb946e697c4b7bd5f9
+yuv410p c7a9e3aeb6b30eadcdf6ca5acb52c5b2
+yuv411p 2e19fb03dd57e4700ff560da3a84402e
+yuv420p 7019c5de9774970eb3a7828cb92439e8
+yuv422p 8fc1c9fff0aa2566a50ff10a54e80ba7
+yuv440p 16775691a106117ecd244c45252f4ba7
+yuv444p b6ec514e4c30fea6b0dd696bf7d147d5
+yuvj411p0b899555985616330109a2381d9828a4
+yuvj420p1f51fe0c2c8d5ba12409bc4c821fed56
+yuvj422p5e9a13247fe5201ea83d3a64241631e3
+yuvj440p2e22b2e340f372792bec5ba0a8f46822
+yuvj444pbecc016653bb26b472625d87dbfc10c4
diff --git a/tests/ref/fate/filter-yadif-mode0 b/tests/ref/fate/filter-yadif-mode0
index be807f9de5..15017492ff 100644
--- a/tests/ref/fate/filter-yadif-mode0
+++ b/tests/ref/fate/filter-yadif-mode0
@@ -33,3 +33,34 @@
 0, 36, 36,1,   622080, 0x2e81bd32
 0, 37, 37,1,   622080, 0x852cf6cf
 0, 38, 38,1,   622080, 0xb055f0e5
+yadif->cur->interlaced_frame: 1 
+yadif->cur->interlaced_frame: 1 
+yadif->cur->interlaced_frame: 1 
+yadif->cur->interlaced_frame: 1 
+yadif->cur->interlaced_frame: 1 
+yadif->cur->interlaced_frame: 1 
+yadif->cur->interlaced_frame: 1 

Re: [FFmpeg-devel] [inline assembly compliance] Issues and patches

2020-04-03 Thread Kieran Kunhya
On Fri, 3 Apr 2020 at 22:07, Carl Eugen Hoyos  wrote:

> Am Fr., 3. Apr. 2020 um 22:42 Uhr schrieb FRÉDÉRIC RECOULES
> :
>
> > we are academic researchers working in automated program analysis.
> > We are currently interested in checking compliance of inline asm chunks
> > as found in C programs.
> >
> > While benchmarking our tool and technique, we found a number of issues in
> > FFMPEG. We report them to you, as well as adequate patches.
> > Actually, we found 59 significant compliance issues in your code.
> > We join 3 patches for some of them, together with explanations and
> > we can send you other patches on demand.
> >
> >
> > * All these bugs are related to compliance between the block of asm and
> its
> > surrounding "contract" (in gcc-style notation). They are akin to
> undefined or
> > implementation-defined behaviours in C: they currently do not manifest
> > themselves in your program, but at some point in time with compiler
> > optimizations becoming more and more aggressive or changes in
> undocumented
> > compiler choices regarding asm chunks, they can suddenly trigger a
> > (hard-to-find) bug.
>
> So your current patch does not change compilation output (without
> debug symbols) when compared with md5sum or similar?
>

We do not do such a comparison for C undefined behaviour changes so why
should we do such a comparison for this code?

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

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

Re: [FFmpeg-devel] [PATCH v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-04-03 Thread Michael Niedermayer
On Fri, Apr 03, 2020 at 11:05:59PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/mux.c| 16 
>  tests/ref/fate/binsub-movtextenc |  2 +-
>  tests/ref/fate/movenc| 50 +++
>  tests/ref/fate/sub2video | 86 
> 
>  4 files changed, 85 insertions(+), 69 deletions(-)
> 
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index cc2d1e2..dc897c2 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -548,6 +548,17 @@ fail:
>  return ret;
>  }
>  
> +static int is_intra_only(enum AVCodecID id)
> +{
> +const AVCodecDescriptor *d = avcodec_descriptor_get(id);
> +if (!d)
> +return 0;
> +if ((d->type == AVMEDIA_TYPE_VIDEO || d->type == AVMEDIA_TYPE_AUDIO) &&
> +!(d->props & AV_CODEC_PROP_INTRA_ONLY))
> +return 0;
> +return 1;
> +}

this should not be duplicated with code in utils.c


> +
>  #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
>  
>  /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but
> @@ -664,6 +675,11 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, 
> AVStream *st, AVPacket *
>  frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * 
> st->time_base.num);
>  break;
>  }
> +
> +/* update flags */
> +if (is_intra_only(st->codecpar->codec_id))
> +pkt->flags |= AV_PKT_FLAG_KEY;
> +

it may make sense to store the AVCodecDescriptor and not search it again for
each packet. But then the "is_intra_only" itself also does not change so that
should itself be computet just once per stream

thx

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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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

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

[FFmpeg-devel] [PATCH]lavfi/telecine: Mark telecined frames as interlaced

2020-04-03 Thread Carl Eugen Hoyos
Hi!

Attached patch marks actually telecined frames as interlaced,
other frames as progressive.

Please comment, Carl Eugen
From 97f3bba7b4f4f4bf4bbb69376daeb45e3386ba62 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Fri, 3 Apr 2020 23:04:15 +0200
Subject: [PATCH] lavfi/telecine: Mark telecined frames as interlaced.

---
 libavfilter/vf_telecine.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 62599a7a3a..3e65f08e39 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -207,6 +207,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 s->stride[i],
 (s->planeheight[i] - !s->first_field + 1) / 2);
 }
+s->frame[nout]->interlaced_frame = 1;
 nout++;
 len--;
 s->occupied = 0;
@@ -220,6 +221,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 inpicref->data[i], inpicref->linesize[i],
 s->stride[i],
 s->planeheight[i]);
+s->frame[nout]->interlaced_frame = 0;
 nout++;
 len -= 2;
 }
@@ -236,6 +238,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 
 for (i = 0; i < nout; i++) {
 AVFrame *frame = av_frame_clone(s->frame[i]);
+int interlaced = frame->interlaced_frame;
 
 if (!frame) {
 av_frame_free();
@@ -243,6 +246,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 }
 
 av_frame_copy_props(frame, inpicref);
+frame->interlaced_frame = interlaced;
 frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
  av_rescale(outlink->frame_count_in, s->ts_unit.num,
 s->ts_unit.den);
-- 
2.24.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] avcodec/libaomenc.c: Add super-resolution options to libaom wrapper

2020-04-03 Thread Wang Cao
Signed-off-by: Wang Cao 
---
 doc/encoders.texi  | 39 +++
 libavcodec/libaomenc.c | 47 ++
 libavcodec/version.h   |  2 +-
 3 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 18bfe8f2eb..e32fecdca3 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1606,6 +1606,45 @@ Enable the use of global motion for block prediction. 
Default is true.
 Enable block copy mode for intra block prediction. This mode is
 useful for screen content. Default is true.
 
+@item enable-superres (@emph{boolean})
+Enable super-resolution during the encoding process.
+
+@item superres-mode (@emph{mode})
+Select super-resolution mode.
+
+@table @option
+@item none (@emph{0})
+No frame superres allowed.
+
+@item fixed (@emph{1})
+All frames are coded at the specified scale and super-resolved.
+
+@item random (@emph{2})
+All frames are coded at a random scale and super-resolved.
+
+@item qthresh (@emph{3})
+Superres scale for a frame is determined based on q_index.
+
+@item auto (@emph{4})
+Automatically select superres for appropriate frames.
+@end table
+
+@item superres_denominator
+The denominator for superres to use when @option{superres-mode} is 
@option{fixed}. Valid value 
+ranges from 8 to 16.
+
+@item superres_kf_denominator
+The denominator for superres to use on key frames when 
+@option{superres-mode} is @option{fixed}. Valid value ranges from 8 to 16.
+
+@item superres_qthresh
+The q level threshold after which superres is used when @option{superres-mode} 
is 
+@option{qthresh}. Valid value ranges from 1 to 63.
+
+@item superres_kf_qthresh
+The q level threshold after which superres is used for key frames when 
+@option{superres-mode} is @option{qthresh}. Valid value ranges from 1 to 63.
+
 @end table
 
 @section libkvazaar
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 20b0e5c8e9..8552813a8a 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -95,6 +95,12 @@ typedef struct AOMEncoderContext {
 int enable_restoration;
 int usage;
 int tune;
+int enable_superres;
+int superres_mode;
+int superres_denominator;
+int superres_qthresh;
+int superres_kf_denominator;
+int superres_kf_qthresh;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
@@ -134,6 +140,16 @@ static const char *const ctlidstr[] = {
 #endif
 [AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
 [AOME_SET_TUNING]   = "AOME_SET_TUNING",
+[AV1E_SET_ENABLE_SUPERRES]  = "AV1E_SET_ENABLE_SUPERRES",
+};
+
+enum AOMSuperresModes {
+AOM_SUPERRES_MODE_NONE= 0,
+AOM_SUPERRES_MODE_FIXED   = 1,
+AOM_SUPERRES_MODE_RANDOM  = 2,
+AOM_SUPERRES_MODE_QTHRESH = 3,
+AOM_SUPERRES_MODE_AUTO= 4,
+AOM_SUPERRES_MODE_NB
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -203,6 +219,13 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
width, "tile_width_count:",  cfg->tile_width_count,
width, "tile_height_count:", cfg->tile_height_count);
 av_log(avctx, level, "\n");
+av_log(avctx, level, "super resolution settings\n"
+ "  %*s%u\n  %*s%u\n  %*s%u\n  %*s%u\n  %*s%u\n  ",
+   width, "rc_superres_mode:",   cfg->rc_superres_mode,
+   width, "rc_superres_denominator:",cfg->rc_superres_denominator,
+   width, "rc_superres_qthresh:",cfg->rc_superres_qthresh,
+   width, "rc_superres_kf_denominator:", 
cfg->rc_superres_kf_denominator,
+   width, "rc_superres_kf_qthresh:", cfg->rc_superres_kf_qthresh);
 }
 
 static void coded_frame_add(void *list, struct FrameListData *cx_frame)
@@ -545,6 +568,17 @@ static av_cold int aom_init(AVCodecContext *avctx,
 return AVERROR(EINVAL);
 }
 
+if (ctx->superres_mode >= 0)
+enccfg.rc_superres_mode = ctx->superres_mode;
+if (ctx->superres_qthresh > 0)
+enccfg.rc_superres_qthresh = ctx->superres_qthresh;
+if (ctx->superres_kf_qthresh > 0)
+enccfg.rc_superres_kf_qthresh = ctx->superres_kf_qthresh;
+if (ctx->superres_denominator >= 0)
+enccfg.rc_superres_denominator = ctx->superres_denominator;
+if (ctx->superres_kf_denominator >= 0)
+enccfg.rc_superres_kf_denominator = ctx->superres_kf_denominator;
+
 dump_enc_cfg(avctx, );
 
 enccfg.g_w= avctx->width;
@@ -687,6 +721,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
 // codec control failures are currently treated only as warnings
 av_log(avctx, AV_LOG_DEBUG, "aom_codec_control\n");
 codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
+if (ctx->enable_superres >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_SUPERRES, ctx->enable_superres);
 if (ctx->auto_alt_ref >= 0)
 codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
 if 

Re: [FFmpeg-devel] [inline assembly compliance] Issues and patches

2020-04-03 Thread Carl Eugen Hoyos
Am Fr., 3. Apr. 2020 um 22:42 Uhr schrieb FRÉDÉRIC RECOULES
:

> we are academic researchers working in automated program analysis.
> We are currently interested in checking compliance of inline asm chunks
> as found in C programs.
>
> While benchmarking our tool and technique, we found a number of issues in
> FFMPEG. We report them to you, as well as adequate patches.
> Actually, we found 59 significant compliance issues in your code.
> We join 3 patches for some of them, together with explanations and
> we can send you other patches on demand.
>
>
> * All these bugs are related to compliance between the block of asm and its
> surrounding "contract" (in gcc-style notation). They are akin to undefined or
> implementation-defined behaviours in C: they currently do not manifest
> themselves in your program, but at some point in time with compiler
> optimizations becoming more and more aggressive or changes in undocumented
> compiler choices regarding asm chunks, they can suddenly trigger a
> (hard-to-find) bug.

So your current patch does not change compilation output (without
debug symbols) when compared with md5sum or similar?

We only accept patches made with git format-patch, no diff files.

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

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

[FFmpeg-devel] [PATCH v2 1/2] avcodec/libaomenc.c: Add a libaom command-line option 'tune'

2020-04-03 Thread Wang Cao
Signed-off-by: Wang Cao 
---
 doc/encoders.texi  | 9 +
 libavcodec/libaomenc.c | 7 +++
 libavcodec/version.h   | 2 +-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index e23b6b32fe..18bfe8f2eb 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1508,6 +1508,15 @@ Complexity-based.
 Cyclic refresh.
 @end table
 
+@item tune (@emph{tune})
+Set the distortion metric the encoder is tuned with. Default is @code{psnr}.
+
+@table @samp
+@item psnr (@emph{0})
+
+@item ssim (@emph{1})
+@end table
+
 @item lag-in-frames
 Set the maximum number of frames which the encoder may keep in flight
 at any one time for lookahead purposes.  Defaults to the internal
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 096aadbe1c..20b0e5c8e9 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -94,6 +94,7 @@ typedef struct AOMEncoderContext {
 int enable_intrabc;
 int enable_restoration;
 int usage;
+int tune;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
@@ -132,6 +133,7 @@ static const char *const ctlidstr[] = {
 [AV1E_SET_ENABLE_INTRABC]   = "AV1E_SET_ENABLE_INTRABC",
 #endif
 [AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
+[AOME_SET_TUNING]   = "AOME_SET_TUNING",
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -699,6 +701,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
 if (ctx->crf >= 0)
 codecctl_int(avctx, AOME_SET_CQ_LEVEL,  ctx->crf);
+if (ctx->tune >= 0)
+codecctl_int(avctx, AOME_SET_TUNING, ctx->tune);
 
 codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
 codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
@@ -1096,6 +1100,9 @@ static const AVOption options[] = {
 { "usage",   "Quality and compression efficiency vs speed 
tradeof", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, "usage"},
 { "good","Good quality",  0, AV_OPT_TYPE_CONST, {.i64 = 0 
/* AOM_USAGE_GOOD_QUALITY */}, 0, 0, VE, "usage"},
 { "realtime","Realtime encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 1 
/* AOM_USAGE_REALTIME */}, 0, 0, VE, "usage"},
+{ "tune","The metric that encoder tunes. Automatically choosen 
by the encoder by default", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 
AOM_TUNE_SSIM, VE, "tune"},
+{ "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
+{ "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
 { NULL },
 };
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f4d1d4de21..dadca75430 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  77
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
2.26.0.292.g33ef6b2f38-goog

___
ffmpeg-devel mailing list
ffmpeg-devel@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] [inline assembly compliance] Issues and patches

2020-04-03 Thread FRÉDÉRIC RECOULES
Dear developpers, 



we are academic researchers working in automated program analysis. 
We are currently interested in checking compliance of inline asm chunks 
as found in C programs. 

While benchmarking our tool and technique, we found a number of issues in 
FFMPEG. We report them to you, as well as adequate patches. 
Actually, we found 59 significant compliance issues in your code. 
We join 3 patches for some of them, together with explanations and 
we can send you other patches on demand. 


* All these bugs are related to compliance between the block of asm and its 
surrounding "contract" (in gcc-style notation). They are akin to undefined or 
implementation-defined behaviours in C: they currently do not manifest 
themselves in your program, but at some point in time with compiler 
optimizations becoming more and more aggressive or changes in undocumented 
compiler choices regarding asm chunks, they can suddenly trigger a 
(hard-to-find) bug. 

* The typical problems come from the compiler missing dataflow information 
and performing undue optimizations on this wrong basis, or the compiler 
allocating an already used register. Actually, we demonstrate "in lab" problems 
with all these categories of bugs in case of inlining 
(especially with LTO enabler) or code refactoring. 

* Some of those issues may seems benign or irrealistic but it cost nothing 
to patch so, why not do it? 


We would be very interested to hear your opinion on these matters. 
Are you interested in such errors and patches? 
Also, besides the patches, we are currently working on a code analyzer 
prototype designed to check asm compliance and to propose patches when the 
chunk is not compliant. This is still work in progress and we are finalizing 
it. 
The errors and patches I reported to you came from my prototype. 
In case such a prototype would be made available, would you consider using it? 



Best regards 

Frédéric Recoules 
1. Overview of found issues
---

1.1 missing "memory" clobber (x 8)


Memory keyword is missing breaking data dependencies.
Every operation initializing memory blocks pointed by the input pointers
can be discarded. Every read of those blocks may return the same value as before
the chunk was executed.

1.2 xmm registers are clobbered (x 2)
~~~

xmm registers are not declared in clobbers
(wherease other chunks using XMM register have listed them in clobbers).

1.3 mmx registers are clobbered (x56)
~~~

mmx registers are never listed in clobbers.

1.4 inter-chunk dependency with mmx register (x 23)


Some mmx registers are initialized by a chunk and used by another.
Even if the chunk are volatile and contiguous in the sources, the compiler
is still able to insert some instructions between them.

1.5 static symbols are hard written in assembly (x 27)
~~~

Some static const values are accessed by name in the chunk without
being stated in the interface. The risk here is that the compiler
deem the value as never used and get rid of it.
If so, the compilation will fail so, not a "big" issue but a bad practice.

2. Proposed patches (x 3 functions)
---

Refactor assembly chunk contained in:
- libavcodec/x86/lossless_videoencdsp_init.c
- libavcodec/x86/rnd_template.c

Following GNU inline assembly guidelines, the patch:
- add missing MMX clobbers
- replace positional placeholder (%[0-9]) by symbolic names
- replace volatile keyword and "memory" clobber by corresponding i/o entries
- replace register clobbering (ex: FF_REG_a) by scratch registers
- refine some macros
- [Cosmetic] mnemonic alignment

[build] HAVE_MMX_CLOBBERS have been added to configure
following the XMM scheme
---
 configure  |   3 +
 libavcodec/x86/hpeldsp_init.c  |   8 +
 libavcodec/x86/inline_asm.h|  30 ++-
 libavcodec/x86/lossless_videoencdsp_init.c |  55 ++--
 libavcodec/x86/rnd_template.c  | 282 +++--
 libavutil/x86/asm.h|  20 ++
 6 files changed, 231 insertions(+), 167 deletions(-)
diff --git a/configure b/configure
index dcead3a300..2e4b68915d 100755
--- a/configure
+++ b/configure
@@ -2250,6 +2250,7 @@ TOOLCHAIN_FEATURES="
 symver_gnu_asm
 vfp_args
 xform_asm
+mmx_clobbers
 xmm_clobbers
 "

@@ -5792,6 +5793,8 @@ EOF
 check_inline_asm ebx_available '""::"b"(0)' &&
 check_inline_asm ebx_available '"":::"%ebx"'

+# check whether xmm clobbers are supported
+check_inline_asm mmx_clobbers '"":::"%mm0"'
 # check whether xmm clobbers are supported
 check_inline_asm xmm_clobbers '"":::"%xmm0"'

diff --git a/libavcodec/x86/hpeldsp_init.c b/libavcodec/x86/hpeldsp_init.c
index d89928cec6..17501a2b5a 100644
--- a/libavcodec/x86/hpeldsp_init.c
+++ 

Re: [FFmpeg-devel] [PATCH v2 2/2] avcodec/libaomenc.c: Add super-resolution options to libaom wrapper

2020-04-03 Thread Wang Cao
On Wed, Mar 18, 2020 at 6:38 AM James Zern  wrote:

> Hi,
>
> On Thu, Mar 5, 2020 at 6:20 PM Wang Cao  wrote:
> >
> > Signed-off-by: Wang Cao 
> > ---
> > The changes are made according to the code review
> > - Bump the MICRO version
> > - Use enum for Super resolution mode consts. The original enum in libaom
> >   is not public so a enum is defined and matched the original enum
> >  doc/encoders.texi  | 39 +++
> >  libavcodec/libaomenc.c | 47 ++
> >  libavcodec/version.h   |  2 +-
> >  3 files changed, 87 insertions(+), 1 deletion(-)
> >
> > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > index 0a74ecce9b..04f05e7c9b 100644
> > --- a/doc/encoders.texi
> > +++ b/doc/encoders.texi
> > @@ -1608,6 +1608,45 @@ Enable the use of global motion for block
> prediction. Default is true.
> >  Enable block copy mode for intra block prediction. This mode is
> >  useful for screen content. Default is true.
> >
> > +@item enable-superres (@emph{boolean})
> > +Enable super-resolution during the encoding process.
> > +
>
> Funny aomenc in libaom doesn't have this option. It must assume the
> library defaults will take care of it, seems like a bug.
>
> Yes they use a default value "1" for this internally (
https://aomedia.googlesource.com/aom/+/master/av1/av1_cx_iface.c).

> > +@item superres-mode (@emph{mode})
> > +Select super-resultion mode.
> > +
>
> resolution
>
I will send a new patch to apply the changes you mentioned.
-- 

Wang Cao |  Software Engineer |  wang...@google.com |  650-203-7807
___
ffmpeg-devel mailing list
ffmpeg-devel@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]configure: Filter -Wl, linker flags out for msvc compilation

2020-04-03 Thread Carl Eugen Hoyos
Am Mi., 1. Apr. 2020 um 16:59 Uhr schrieb Carl Eugen Hoyos :

> Attached patch silences a few warnings when compiling with cl.exe or
> clang-cl.exe.
> Or are there any working options?

I will push this if there are no objections.

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

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

Re: [FFmpeg-devel] [PATCH]lavc/aacdec_template: Only warn once about unusual 7.1 encoding

2020-04-03 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 22:38 Uhr schrieb Carl Eugen Hoyos
:
>
> Am Fr., 27. März 2020 um 19:00 Uhr schrieb Carl Eugen Hoyos
> :
>
> > Attached patch reduces warnings when decoding a file with 7.1(wide)
> > aac encoding.
>
> New patch attached that does not lead to new crashes.

Ping.

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

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

Re: [FFmpeg-devel] [RFC, PATCH]lavu/log: Do not change the terminal background colour

2020-04-03 Thread Carl Eugen Hoyos
Am So., 29. März 2020 um 17:19 Uhr schrieb Carl Eugen Hoyos
:

> Attached patch fixes ticket #8587, not sure if we want this or not,
> but I do not consider the missing encircled / blinking effect (that is
> not used by our command line tools) an issue.

Ping.

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

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

Re: [FFmpeg-devel] [PATCH]qsv: Fix format specifiers for int variables

2020-04-03 Thread Carl Eugen Hoyos
Am Mi., 1. Apr. 2020 um 16:55 Uhr schrieb Carl Eugen Hoyos :

> Attached patches fix three wrong format specifiers, the variables are
> all of type int but the specifier PRId16 is used.

Will push them tomorrow.

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

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

[FFmpeg-devel] [PATCH v10 1/3] libavcodec/jpeg2000dec.c: Add support for PPT marker

2020-04-03 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds functional changes to support the
PPT marker.
---
 libavcodec/jpeg2000dec.c | 88 
 1 file changed, 79 insertions(+), 9 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7103cd6ceb..02905b9e49 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
 Jpeg2000QuantStyle  qntsty[4];
 Jpeg2000POC poc;
 Jpeg2000TileParttile_part[32];
+uint8_t has_ppt;// whether this tile has a ppt 
marker
+uint8_t *packed_headers;// contains packed headers. 
Used only along with PPT marker
+int packed_headers_size;// size in bytes of the packed 
headers
+GetByteContext  packed_headers_stream;  // byte context corresponding 
to packed headers
 uint16_t tp_idx;// Tile-part index
 int coord[2][2];// border coordinates {{x0, x1}, {y0, 
y1}}
 } Jpeg2000Tile;
@@ -855,6 +859,39 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
 return 0;
 }
 
+static int get_ppt(Jpeg2000DecoderContext *s, int n)
+{
+Jpeg2000Tile *tile;
+
+if (s->curtileno < 0)
+return AVERROR_INVALIDDATA;
+
+tile = >tile[s->curtileno];
+if (tile->tp_idx != 0) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "PPT marker can occur only on first tile part of a tile.\n");
+return AVERROR_INVALIDDATA;
+}
+
+tile->has_ppt = 1;  // this tile has a ppt marker
+/*Zppt = */ bytestream2_get_byte(>g); // Zppt is skipped and not used
+if (!tile->packed_headers) {
+tile->packed_headers = av_malloc_array(n - 3, 1);
+memcpy(tile->packed_headers, s->g.buffer, n - 3);
+tile->packed_headers_size = n - 3;
+} else {
+tile->packed_headers = av_realloc_array(tile->packed_headers,
+tile->packed_headers_size + n 
- 3,
+1);
+memcpy(tile->packed_headers + tile->packed_headers_size,
+   s->g.buffer, n - 3);
+tile->packed_headers_size += n - 3;
+}
+bytestream2_skip(>g, n - 3);
+
+return 0;
+}
+
 static int init_tile(Jpeg2000DecoderContext *s, int tileno)
 {
 int compno;
@@ -938,19 +975,23 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 if (layno < rlevel->band[0].prec[precno].decoded_layers)
 return 0;
 rlevel->band[0].prec[precno].decoded_layers = layno + 1;
-
-if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
-if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
-s->g = tile->tile_part[++(*tp_index)].tpg;
+// Select stream to read from
+if (tile->has_ppt) {
+s->g = tile->packed_headers_stream;
+} else {
+s->g = tile->tile_part[*tp_index].tpg;
+if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
 }
+if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
 }
 
-if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
-bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
-
 if (!(ret = get_bits(s, 1))) {
 jpeg2000_flush(s);
-return 0;
+goto skip_data;
 } else if (ret < 0)
 return ret;
 
@@ -1056,6 +1097,18 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead 
%X\n", bytestream2_peek_be32(>g));
 }
 
+// Save state of stream
+if (tile->has_ppt) {
+tile->packed_headers_stream = s->g;
+s->g = tile->tile_part[*tp_index].tpg;
+if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
+}
+if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+}
 for (bandno = 0; bandno < rlevel->nbands; bandno++) {
 Jpeg2000Band *band = rlevel->band + bandno;
 Jpeg2000Prec *prec = band->prec + precno;
@@ -1097,6 +1150,15 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 av_freep(>lengthinc);
 }
 }
+// Save state of stream
+tile->tile_part[*tp_index].tpg = s->g;
+return 0;
+
+skip_data:
+if (tile->has_ppt)
+tile->packed_headers_stream = s->g;
+else
+tile->tile_part[*tp_index].tpg = s->g;
 return 0;
 }
 
@@ -1929,6 +1991,11 @@ static int 

[FFmpeg-devel] [PATCH v10 3/3] libavcodec/jpeg2000dec.c: Fix indentation

2020-04-03 Thread gautamramk
From: Gautam Ramakrishnan 

---
 libavcodec/jpeg2000dec.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 32a09c6d5c..36a9e9858a 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1350,14 +1350,14 @@ static int 
jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
 continue;
 }
 
-for (layno = 0; layno < LYEpoc; layno++) {
-if ((ret = jpeg2000_decode_packet(s, tile, 
tp_index,
-codsty, rlevel,
-precno, layno,
-qntsty->expn + 
(reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
-
qntsty->nguardbits)) < 0)
-return ret;
-}
+for (layno = 0; layno < LYEpoc; layno++) {
+if ((ret = jpeg2000_decode_packet(s, tile, 
tp_index,
+  codsty, rlevel,
+  precno, layno,
+  qntsty->expn + 
(reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
+  
qntsty->nguardbits)) < 0)
+return ret;
+}
 }
 }
 }
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH v10 2/3] libavcodec/jpeg2000dec.c: Handle non EOC streams

2020-04-03 Thread gautamramk
From: Gautam Ramakrishnan 

This patch allows decoding of j2k streams which do
not have an EOC marker.
---
 libavcodec/jpeg2000dec.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 02905b9e49..32a09c6d5c 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2006,8 +2006,12 @@ static int 
jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
 
 len = bytestream2_get_be16(>g);
 if (len < 2 || bytestream2_get_bytes_left(>g) < len - 2) {
-av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, 
bytestream2_get_bytes_left(>g));
-return AVERROR_INVALIDDATA;
+if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
+av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", 
len, bytestream2_get_bytes_left(>g));
+return AVERROR_INVALIDDATA;
+}
+av_log(s->avctx, AV_LOG_WARNING, "Missing EOC Marker.\n");
+break;
 }
 
 switch (marker) {
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] avformat/mpegts: use a buffer pool for PES payloads

2020-04-03 Thread James Almer
On 4/2/2020 4:54 PM, Marton Balint wrote:
> 
> 
> On Thu, 2 Apr 2020, James Almer wrote:
> 
>> On 4/2/2020 3:49 PM, Marton Balint wrote:
>>>
>>>
>>> On Thu, 2 Apr 2020, James Almer wrote:
>>>
 On 4/2/2020 3:27 PM, Marton Balint wrote:
>
>
> On Thu, 2 Apr 2020, Marton Balint wrote:
>
>>
>>
>> On Thu, 2 Apr 2020, James Almer wrote:
>>
>>> On 3/29/2020 6:07 PM, James Almer wrote:
 This produces a small speed up in demuxing

 Signed-off-by: James Almer 
 ---
  libavformat/mpegts.c | 20 
  1 file changed, 16 insertions(+), 4 deletions(-)

 diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
 index 7f56bacb2c..7746a524c4 100644
 --- a/libavformat/mpegts.c
 +++ b/libavformat/mpegts.c
 @@ -157,6 +157,8 @@ struct MpegTSContext {
  int resync_size;
  int merge_pmt_versions;

 +    AVBufferPool *pool;
 +
  /**/
  /* private mpegts data */
  /* scan context */
 @@ -1177,8 +1179,7 @@ static int mpegts_push_data(MpegTSFilter
 *filter,
  pes->total_size = MAX_PES_PAYLOAD;

  /* allocate pes buffer */
 -    pes->buffer =
 av_buffer_alloc(pes->total_size +
 - 
>> AV_INPUT_BUFFER_PADDING_SIZE);
 +    pes->buffer = av_buffer_pool_get(ts->pool);
  if (!pes->buffer)
  return AVERROR(ENOMEM);

 @@ -1351,8 +1352,7 @@ skip:
  if (ret < 0)
  return ret;
  pes->total_size = MAX_PES_PAYLOAD;
 -    pes->buffer =
 av_buffer_alloc(pes->total_size +
 - 
>> AV_INPUT_BUFFER_PADDING_SIZE);
 +    pes->buffer = av_buffer_pool_get(ts->pool);
  if (!pes->buffer)
  return AVERROR(ENOMEM);
  ts->stop_parse = 1;
 @@ -3032,6 +3032,10 @@ static int
 mpegts_read_header(AVFormatContext
 *s)
  ts->stream = s;
  ts->auto_guess = 0;

 +    ts->pool = av_buffer_pool_init(MAX_PES_PAYLOAD + 
>> AV_INPUT_BUFFER_PADDING_SIZE, NULL);
 +    if (!ts->pool)
 +    return AVERROR(ENOMEM);
 +
  if (s->iformat == _mpegts_demuxer) {
  /* normal demux */

 @@ -3200,6 +3204,8 @@ static void mpegts_free(MpegTSContext *ts)

  clear_programs(ts);

 +    av_buffer_pool_uninit(>pool);
 +
  for (i = 0; i < NB_PID_MAX; i++)
  if (ts->pids[i])
  mpegts_close_filter(ts, ts->pids[i]);
 @@ -3295,6 +3301,12 @@ MpegTSContext 
>> *avpriv_mpegts_parse_open(AVFormatContext *s)
  ts->stream = s;
  ts->auto_guess = 1;

 +    ts->pool = av_buffer_pool_init(MAX_PES_PAYLOAD + 
>> AV_INPUT_BUFFER_PADDING_SIZE, NULL);
 +    if (!ts->pool) {
 +    av_free(ts);
 +    return NULL;
 +    }
 +
  mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
  mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
  mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
>>>
>>> Will apply soon if no one objects.
>>
>> LGTM.
>
> On second thought aint this going to waste too much memory on small
> packets? If packets are queued somewhere it can make a huge difference
> if every buffer is 200kb...
>
> Does the speedup goes away if only unbound packets make use of the
> buffer pool?
>
> Thanks,
> Marton

 I tried these two LG 4k HDR sample videos, and the pool was never
 bigger
 than 3 to 5 buffers for the entire demuxing process.
>>>
>>> That is the case if there is no packet buffering, like in ffmpeg using a
>>> single input. But in ffplay or a lot of other apps packets are
>>> pre-buffered to remove the latency of the source media. An app could
>>> have assumed that if it buffers 1 MB of packets it will not consume a
>>> lot more than 1 MB of memory.
>>>

 I'll bench again with your suggestion, but i don't think it will be a
 problem even as is.
>>>
>>> Maybe we should create log2(MAX_PACKET_SIZE) number of buffer pools
>>> instead? In that case the memory wasted is at most 100%... Still not
>>> very good, but a lot more acceptable.
>>
>> I don't think that's possible, or worth trying. There's currently no way
>> to query the amount of buffers in a given pool, and definitely no way to
>> know what buffers 

Re: [FFmpeg-devel] [PATCH 02/14] avformat/matroska: clean the structure formatting

2020-04-03 Thread Andreas Rheinhardt
Steve Lhomme:
> On 2020-03-25 23:24, Andreas Rheinhardt wrote:
>> Steve Lhomme:
>>> From: Steve Lhomme 
>>>
>>> Always use a comma at the end, order elements by value.
>>> ---
>>>   libavformat/matroska.h | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavformat/matroska.h b/libavformat/matroska.h
>>> index 9e33e51c94..e177cd027f 100644
>>> --- a/libavformat/matroska.h
>>> +++ b/libavformat/matroska.h
>>> @@ -286,13 +286,13 @@ typedef enum {
>>>   typedef enum {
>>>   MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED = 0,
>>>   MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED   = 1,
>>> -    MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE  = 2
>>> +    MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE  = 2,
>>>   } MatroskaVideoInterlaceFlag;
>>>     typedef enum {
>>>   MATROSKA_VIDEO_FIELDORDER_PROGRESSIVE  = 0,
>>> -    MATROSKA_VIDEO_FIELDORDER_UNDETERMINED = 2,
>>>   MATROSKA_VIDEO_FIELDORDER_TT   = 1,
>>> +    MATROSKA_VIDEO_FIELDORDER_UNDETERMINED = 2,
>>>   MATROSKA_VIDEO_FIELDORDER_BB   = 6,
>>>   MATROSKA_VIDEO_FIELDORDER_TB   = 9,
>>>   MATROSKA_VIDEO_FIELDORDER_BT   = 14,
>>>
>> Would it actually be allowed to add new values to the range of
>> FlagInterlaced (to which the MatroskaVideoInterlaceFlag enum
>> corresponds)? If no, then we should not add a comma, as this signals
>> extensibility.
>> The reordering looks good either way.
> 
> Yes, dependending on the DocType version it might be possible that some
> new values are added to enums (not just this one).
> 
> Also I'm not sure I can tell an element in the last of an "list" in XSLT
> so that would be more trouble to generate the code.

Applied.

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

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

Re: [FFmpeg-devel] [PATCH 03/14] avformat/matroska: use more consistent spacing in enums

2020-04-03 Thread Andreas Rheinhardt
Steve Lhomme:
> From: Steve Lhomme 
> 
> ---
>  libavformat/matroska.h | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/matroska.h b/libavformat/matroska.h
> index e177cd027f..5520e9ce8f 100644
> --- a/libavformat/matroska.h
> +++ b/libavformat/matroska.h
> @@ -284,18 +284,18 @@ typedef enum {
>  } MatroskaTrackEncodingCompAlgo;
>  
>  typedef enum {
> -MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED = 0,
> -MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED   = 1,
> -MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE  = 2,
> +  MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED = 0,
> +  MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED   = 1,
> +  MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE  = 2,
>  } MatroskaVideoInterlaceFlag;
>  
>  typedef enum {
> -MATROSKA_VIDEO_FIELDORDER_PROGRESSIVE  = 0,
> -MATROSKA_VIDEO_FIELDORDER_TT   = 1,
> -MATROSKA_VIDEO_FIELDORDER_UNDETERMINED = 2,
> -MATROSKA_VIDEO_FIELDORDER_BB   = 6,
> -MATROSKA_VIDEO_FIELDORDER_TB   = 9,
> -MATROSKA_VIDEO_FIELDORDER_BT   = 14,
> +  MATROSKA_VIDEO_FIELDORDER_PROGRESSIVE  = 0,
> +  MATROSKA_VIDEO_FIELDORDER_TT   = 1,
> +  MATROSKA_VIDEO_FIELDORDER_UNDETERMINED = 2,
> +  MATROSKA_VIDEO_FIELDORDER_BB   = 6,
> +  MATROSKA_VIDEO_FIELDORDER_TB   = 9,
> +  MATROSKA_VIDEO_FIELDORDER_BT   = 14,
>  } MatroskaVideoFieldOrder;
>  
>  typedef enum {
> 
Actually FFmpeg uses an indent size of four. It seems that most enums
already abide by this and most of those that don't are in
libavformat/matroska.h.

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

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

[FFmpeg-devel] [PATCH] ffplay: flush correct stream after stats update

2020-04-03 Thread Gyan Doshi
Stats and logs are written to stderr, not stdout.
---
 fftools/ffplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 416ebbf7df..1beec54293 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -1736,7 +1736,7 @@ display:
 else
 av_log(NULL, AV_LOG_INFO, "%s", buf.str);
 
-fflush(stdout);
+fflush(stderr);
 av_bprint_finalize(, NULL);
 
 last_time = cur_time;
-- 
2.26.0

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

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

Re: [FFmpeg-devel] [PATCH] ffplay: always show stats at all log levels if requested by user

2020-04-03 Thread Gyan Doshi



On 03-04-2020 09:26 pm, Marton Balint wrote:



On Fri, 3 Apr 2020, Gyan Doshi wrote:


Since 3b491c5a500, stats would be hidden if loglevel was lower than
info, even if -stats was set.


Please mention ticket #6962.


Revised patch sent. I'll change the flush target in a separate patch as 
it's an independent change.


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

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

[FFmpeg-devel] [PATCH v2] ffplay: always show stats at all log levels if requested by user

2020-04-03 Thread Gyan Doshi
Since 3b491c5a500, stats would be hidden if loglevel was lower than
info, even if -stats was set.

Fixes #6962
---
 doc/ffplay.texi  |  5 +++--
 fftools/ffplay.c | 36 
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index a487c0de8d..f3761bb12e 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -133,8 +133,9 @@ This option has been deprecated in favor of private 
options, try -pixel_format.
 @item -stats
 Print several playback statistics, in particular show the stream
 duration, the codec parameters, the current position in the stream and
-the audio/video synchronisation drift. It is on by default, to
-explicitly disable it you need to specify @code{-nostats}.
+the audio/video synchronisation drift. It is shown by default, unless the
+log level is lower than @code{info}. Its display can be forced by manually
+specifying this option. To disable it, you need to specify @code{-nostats}.
 
 @item -fast
 Non-spec-compliant optimizations.
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2ed4b22d3e..416ebbf7df 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -40,6 +40,7 @@
 #include "libavutil/samplefmt.h"
 #include "libavutil/avassert.h"
 #include "libavutil/time.h"
+#include "libavutil/bprint.h"
 #include "libavformat/avformat.h"
 #include "libavdevice/avdevice.h"
 #include "libswscale/swscale.h"
@@ -326,7 +327,7 @@ static int display_disable;
 static int borderless;
 static int alwaysontop;
 static int startup_volume = 100;
-static int show_status = 1;
+static int show_status = -1;
 static int av_sync_type = AV_SYNC_AUDIO_MASTER;
 static int64_t start_time = AV_NOPTS_VALUE;
 static int64_t duration = AV_NOPTS_VALUE;
@@ -1692,6 +1693,7 @@ display:
 }
 is->force_refresh = 0;
 if (show_status) {
+AVBPrint buf;
 static int64_t last_time;
 int64_t cur_time;
 int aqsize, vqsize, sqsize;
@@ -1715,18 +1717,28 @@ display:
 av_diff = get_master_clock(is) - get_clock(>vidclk);
 else if (is->audio_st)
 av_diff = get_master_clock(is) - get_clock(>audclk);
-av_log(NULL, AV_LOG_INFO,
-   "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB 
f=%"PRId64"/%"PRId64"   \r",
-   get_master_clock(is),
-   (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? 
"M-V" : (is->audio_st ? "M-A" : "   ")),
-   av_diff,
-   is->frame_drops_early + is->frame_drops_late,
-   aqsize / 1024,
-   vqsize / 1024,
-   sqsize,
-   is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_dts : 0,
-   is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_pts : 0);
+
+av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
+av_bprintf(,
+  "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB 
f=%"PRId64"/%"PRId64"   \r",
+  get_master_clock(is),
+  (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? 
"M-V" : (is->audio_st ? "M-A" : "   ")),
+  av_diff,
+  is->frame_drops_early + is->frame_drops_late,
+  aqsize / 1024,
+  vqsize / 1024,
+  sqsize,
+  is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_dts : 0,
+  is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_pts : 0);
+
+if (show_status == 1 && AV_LOG_INFO > av_log_get_level())
+fprintf(stderr, "%s", buf.str);
+else
+av_log(NULL, AV_LOG_INFO, "%s", buf.str);
+
 fflush(stdout);
+av_bprint_finalize(, NULL);
+
 last_time = cur_time;
 }
 }
-- 
2.26.0

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

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

Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread Hendrik Leppkes
On Fri, Apr 3, 2020 at 5:47 PM Fu, Linjie  wrote:
>
> > From: ffmpeg-devel  On Behalf Of
> > Limin Wang
> > Sent: Friday, April 3, 2020 22:55
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support
> > mpeg2 encoder profile with const options
> >
> > On Fri, Apr 03, 2020 at 04:25:15PM +0200, Hendrik Leppkes wrote:
> > > On Fri, Apr 3, 2020 at 3:12 PM  wrote:
> > > >
> > > > From: Limin Wang 
> > > >
> > > > make setting profile more user friendly
> > > >
> > >
> > > Please make sure API users can still set it through avctx->profile,
> > > otherwise this would be an API break.
> >
> > Right, I'll update the patch to check avctx->profile != unknown, then
> > overwrite
> > the s->profile with it to void API break.
> >
> Would it be better to determine the profile with a priority like:
> 1.s->profile; then
> 2. avctx->profile; then
> 3. a default profile;
> in case both avctx->profile and s->profile are set?
>
> If user set a profile explicitly (through either option in cmdline or 
> av_opt_set()),
> above priority seems to be natural. (and libx264 [1] has the same logic)
>

That would be just fine.

- Hendrik
___
ffmpeg-devel mailing list
ffmpeg-devel@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] ffplay: always show stats at all log levels if requested by user

2020-04-03 Thread Marton Balint



On Fri, 3 Apr 2020, Gyan Doshi wrote:


Since 3b491c5a500, stats would be hidden if loglevel was lower than
info, even if -stats was set.


Please mention ticket #6962.


---
fftools/ffplay.c | 36 
1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2ed4b22d3e..d529c60e81 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -40,6 +40,7 @@
#include "libavutil/samplefmt.h"
#include "libavutil/avassert.h"
#include "libavutil/time.h"
+#include "libavutil/bprint.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
@@ -326,7 +327,7 @@ static int display_disable;
static int borderless;
static int alwaysontop;
static int startup_volume = 100;
-static int show_status = 1;
+static int show_status = -1;
static int av_sync_type = AV_SYNC_AUDIO_MASTER;
static int64_t start_time = AV_NOPTS_VALUE;
static int64_t duration = AV_NOPTS_VALUE;
@@ -1692,6 +1693,7 @@ display:
}
is->force_refresh = 0;
if (show_status) {
+AVBPrint buf;
static int64_t last_time;
int64_t cur_time;
int aqsize, vqsize, sqsize;
@@ -1715,18 +1717,28 @@ display:
av_diff = get_master_clock(is) - get_clock(>vidclk);
else if (is->audio_st)
av_diff = get_master_clock(is) - get_clock(>audclk);
-av_log(NULL, AV_LOG_INFO,
-   "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB 
f=%"PRId64"/%"PRId64"   \r",
-   get_master_clock(is),
-   (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st 
? "M-A" : "   ")),
-   av_diff,
-   is->frame_drops_early + is->frame_drops_late,
-   aqsize / 1024,
-   vqsize / 1024,
-   sqsize,
-   is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_dts : 0,
-   is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_pts : 0);
+
+av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
+av_bprintf(,
+  "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB 
f=%"PRId64"/%"PRId64"   \r",
+  get_master_clock(is),
+  (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : 
(is->audio_st ? "M-A" : "   ")),
+  av_diff,
+  is->frame_drops_early + is->frame_drops_late,
+  aqsize / 1024,
+  vqsize / 1024,
+  sqsize,
+  is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_dts : 0,
+  is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_pts : 0);
+
+if (show_status == 1 && AV_LOG_INFO > av_log_get_level())
+printf("%s", buf.str);
+else
+av_log(NULL, AV_LOG_INFO, "%s", buf.str);


This is kind of strange that stats are sometimes stdout, sometimes stderr, 
we should at least try to be consistent with ffmpeg.c:


if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
fprintf(stderr, "%s%c", buf.str, end);
} else
av_log(NULL, AV_LOG_INFO, "%s%c", buf.str, end);

fflush(stderr);

At least only stderr is used there...



+
fflush(stdout);


And in that case this needs to be stderr.


+av_bprint_finalize(, NULL);
+
last_time = cur_time;
}
}
--


Also the docs of the -stats option also need updating (may can be a 
separate patch because ffmpeg.c -stats docs is also outdated...)


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

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

Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Limin Wang
> Sent: Friday, April 3, 2020 22:55
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support
> mpeg2 encoder profile with const options
> 
> On Fri, Apr 03, 2020 at 04:25:15PM +0200, Hendrik Leppkes wrote:
> > On Fri, Apr 3, 2020 at 3:12 PM  wrote:
> > >
> > > From: Limin Wang 
> > >
> > > make setting profile more user friendly
> > >
> >
> > Please make sure API users can still set it through avctx->profile,
> > otherwise this would be an API break.
> 
> Right, I'll update the patch to check avctx->profile != unknown, then
> overwrite
> the s->profile with it to void API break.
> 
Would it be better to determine the profile with a priority like:
1.s->profile; then
2. avctx->profile; then
3. a default profile;
in case both avctx->profile and s->profile are set?

If user set a profile explicitly (through either option in cmdline or 
av_opt_set()), 
above priority seems to be natural. (and libx264 [1] has the same logic)

- Linjie

[1] https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libx264.c#L806

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

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

Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread Limin Wang
On Fri, Apr 03, 2020 at 04:25:15PM +0200, Hendrik Leppkes wrote:
> On Fri, Apr 3, 2020 at 3:12 PM  wrote:
> >
> > From: Limin Wang 
> >
> > make setting profile more user friendly
> >
> 
> Please make sure API users can still set it through avctx->profile,
> otherwise this would be an API break.

Right, I'll update the patch to check avctx->profile != unknown, then overwrite 
the s->profile with it to void API break. 

> 
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-04-03 Thread Andreas Rheinhardt
lance.lmw...@gmail.com:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/mux.c| 16 
>  tests/ref/fate/binsub-movtextenc |  2 +-
>  tests/ref/fate/movenc| 50 +++
>  tests/ref/fate/sub2video | 86 
> 
>  4 files changed, 85 insertions(+), 69 deletions(-)
> 
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index cc2d1e2..dc897c2 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -548,6 +548,17 @@ fail:
>  return ret;
>  }
>  
> +static int is_intra_only(enum AVCodecID id)
> +{
> +const AVCodecDescriptor *d = avcodec_descriptor_get(id);
> +if (!d)
> +return 0;
> +if ((d->type == AVMEDIA_TYPE_VIDEO || d->type == AVMEDIA_TYPE_AUDIO) &&
> +!(d->props & AV_CODEC_PROP_INTRA_ONLY))
> +return 0;
> +return 1;
> +}
> +
>  #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
>  
>  /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but
> @@ -664,6 +675,11 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, 
> AVStream *st, AVPacket *
>  frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * 
> st->time_base.num);
>  break;
>  }
> +
> +/* update flags */
> +if (is_intra_only(st->codecpar->codec_id))
> +pkt->flags |= AV_PKT_FLAG_KEY;
> +
>  return 0;
>  }
>  FF_ENABLE_DEPRECATION_WARNINGS

You have added the check to code that is deprecated and slated to be
removed. Maybe it would be better to add it to prepare_input_packet()
instead?

> diff --git a/tests/ref/fate/binsub-movtextenc 
> b/tests/ref/fate/binsub-movtextenc
> index 78c05f4..a8f94b7 100644
> --- a/tests/ref/fate/binsub-movtextenc
> +++ b/tests/ref/fate/binsub-movtextenc
> @@ -1 +1 @@
> -35adf776cd73e808186ae7124445f4b8
> +fc6d07679ac1f718aa50de687924cd97
> diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
> index 637a347..fb39b98 100644
> --- a/tests/ref/fate/movenc
> +++ b/tests/ref/fate/movenc
> @@ -2,17 +2,17 @@ write_data len 36, time nopts, type header atom ftyp
>  write_data len 2389, time nopts, type header atom -
>  write_data len 788, time 100, type sync atom moof
>  write_data len 110, time nopts, type trailer atom -
> -66cf48604f039aa9a51711786f5c8778 3323 non-empty-moov
> +5f401347fc3c771b819e2449d69d4861 3323 non-empty-moov
>  write_data len 36, time nopts, type header atom ftyp
>  write_data len 2721, time nopts, type header atom -
>  write_data len 908, time 97, type sync atom moof
>  write_data len 110, time nopts, type trailer atom -
> -04b2e86f455af94f9258b8d66dbf71f5 3775 non-empty-moov-elst
> +4267feee527adf8cd4f7b36ac0fc0872 3775 non-empty-moov-elst
>  write_data len 36, time nopts, type header atom ftyp
>  write_data len 2629, time nopts, type header atom -
>  write_data len 908, time 100, type sync atom moof
>  write_data len 110, time nopts, type trailer atom -
> -e9f6fa032d6d8265d67aef5de81a48bf 3683 non-empty-moov-no-elst
> +44077b9ad45f3e16fafe4e5ada54e9b0 3683 non-empty-moov-no-elst
>  write_data len 24, time nopts, type header atom ftyp
[...]
> -1,  22564,  22564,  2127000, 2133, 0x670c11a5, F=0x0
> +1,  22564,  22564,  2127000, 2133, 0x670c11a5
>  0,   1139,   1139,1,   518400, 0xbab197ea
> -1,  227834000,  227834000,  1262000, 1264, 0xc1d9fc57, F=0x0
> +1,  227834000,  227834000,  1262000, 1264, 0xc1d9fc57
>  0,   1140,   1140,1,   518400, 0xb046dd30
>  0,   1145,   1145,1,   518400, 0xbab197ea
> 
Have you checked whether all these changes are beneficial?

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

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

[FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile high option support

2020-04-03 Thread Linjie Fu
Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention mode,
which determined by iEntropyCodingModeFlag in ParamTranscode().



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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index f02c5fd..d331cfd 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -42,7 +42,7 @@ typedef struct SVCContext {
 ISVCEncoder *encoder;
 int slice_mode; // deprecated
 int loopfilter;
-char *profile;
+int profile;
 int max_nal_size;
 int skip_frames;
 int skipped;
@@ -71,7 +71,11 @@ static const AVOption options[] = {
 { "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_DYN_SLICE }, 0, 0, VE, "slice_mode" },
 #endif
 { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, 
{ .i64 = 1 }, 0, 1, VE },
-{ "profile", "set profile restrictions", OFFSET(profile), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
+{ "profile", "Set profile restrictions", OFFSET(profile), AV_OPT_TYPE_INT, 
{ .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 0x, VE, "profile" },
+#define PROFILE(name, value)  name, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = value 
}, 0, 0, VE, "profile"
+{ PROFILE("constrained_baseline", 
FF_PROFILE_H264_CONSTRAINED_BASELINE) },
+{ PROFILE("high", FF_PROFILE_H264_HIGH) },
+#undef PROFILE
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
@@ -107,12 +111,28 @@ static av_cold int svc_encode_init_profile(AVCodecContext 
*avctx, SEncParamExt *
 {
 SVCContext *s = avctx->priv_data;
 
-if (s->profile && !strcmp(s->profile, "main"))
-param->iEntropyCodingModeFlag = 1; //< 0:CAVLC  1:CABAC
-else if (!s->profile && s->cabac)
+if (s->profile == FF_PROFILE_UNKNOWN)
+s->profile = s->cabac ? FF_PROFILE_H264_HIGH :
+FF_PROFILE_H264_CONSTRAINED_BASELINE;
+
+switch (s->profile) {
+case FF_PROFILE_H264_HIGH:
 param->iEntropyCodingModeFlag = 1;
-else
+av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
+   "select EProfileIdc PRO_HIGH in libopenh264.\n");
+break;
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+case FF_PROFILE_UNKNOWN:
+param->iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+default:
 param->iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+}
 
 return 0;
 }
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 07/10] lavc/libopenh264enc: separate svc_encode_init() into several functions

2020-04-03 Thread Linjie Fu
Separate the initialization procedure into different functions.

Make it more readable and easier to be extended.

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index e89cedf..f02c5fd 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -103,120 +103,51 @@ static av_cold int svc_encode_close(AVCodecContext 
*avctx)
 return 0;
 }
 
-static av_cold int svc_encode_init(AVCodecContext *avctx)
+static av_cold int svc_encode_init_profile(AVCodecContext *avctx, SEncParamExt 
*param)
 {
 SVCContext *s = avctx->priv_data;
-SEncParamExt param = { 0 };
-int err;
-int log_level;
-WelsTraceCallback callback_function;
-AVCPBProperties *props;
 
-if ((err = ff_libopenh264_check_version(avctx)) < 0)
-return err;
+if (s->profile && !strcmp(s->profile, "main"))
+param->iEntropyCodingModeFlag = 1; //< 0:CAVLC  1:CABAC
+else if (!s->profile && s->cabac)
+param->iEntropyCodingModeFlag = 1;
+else
+param->iEntropyCodingModeFlag = 0;
 
-if (WelsCreateSVCEncoder(>encoder)) {
-av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
-return AVERROR_UNKNOWN;
-}
+return 0;
+}
 
-// Pass all libopenh264 messages to our callback, to allow ourselves to 
filter them.
-log_level = WELS_LOG_DETAIL;
-(*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_LEVEL, 
_level);
+static av_cold int svc_encode_init_rate_control(AVCodecContext *avctx, 
SEncParamExt *param)
+{
+SVCContext *s = avctx->priv_data;
 
-// Set the logging callback function to one that uses av_log() (see 
implementation above).
-callback_function = (WelsTraceCallback) ff_libopenh264_trace_callback;
-(*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_CALLBACK, 
_function);
+/* Rate Control */
+param->iRCMode= s->rc_mode;
 
-// Set the AVCodecContext as the libopenh264 callback context so that it 
can be passed to av_log().
-(*s->encoder)->SetOption(s->encoder, 
ENCODER_OPTION_TRACE_CALLBACK_CONTEXT, );
+param->iTargetBitrate = avctx->bit_rate;
+param->iMaxBitrate= FFMAX(avctx->rc_max_rate, 
avctx->bit_rate);
+param->bEnableFrameSkip   = s->skip_frames;
 
-(*s->encoder)->GetDefaultParams(s->encoder, );
+// QP = 0 is not well supported, so default to (1, 51)
+param->iMaxQp = avctx->qmax >= 0 ? 
av_clip(avctx->qmax, 1, 51) : 51;
+param->iMinQp = avctx->qmin >= 0 ? 
av_clip(avctx->qmin, 1, param->iMaxQp) : 1;
+param->bEnableAdaptiveQuant   = 1;
 
-#if FF_API_CODER_TYPE
-FF_DISABLE_DEPRECATION_WARNINGS
-if (!s->cabac)
-s->cabac = avctx->coder_type == FF_CODER_TYPE_AC;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
+param->iSpatialLayerNum   = 1;  // Number of 
dependency(Spatial/CGS) layers used to be encoded
+param->iTemporalLayerNum  = 1;  // Number of temporal layer 
specified
 
-param.fMaxFrameRate  = 1/av_q2d(avctx->time_base);
-param.iPicWidth  = avctx->width;
-param.iPicHeight = avctx->height;
-param.iTargetBitrate = avctx->bit_rate;
-param.iMaxBitrate= FFMAX(avctx->rc_max_rate, 
avctx->bit_rate);
-param.iRCMode= s->rc_mode;
-// QP = 0 is not well supported, so default to (1, 51)
-param.iMaxQp = avctx->qmax >= 0 ? av_clip(avctx->qmax, 
1, 51) : 51;
-param.iMinQp = avctx->qmin >= 0 ? av_clip(avctx->qmin, 
1, param.iMaxQp) : 1;
-param.iTemporalLayerNum  = 1;
-param.iSpatialLayerNum   = 1;
-param.bEnableDenoise = 0;
-param.bEnableBackgroundDetection = 1;
-param.bEnableAdaptiveQuant   = 1;
-param.bEnableFrameSkip   = s->skip_frames;
-param.bEnableLongTermReference   = 0;
-param.iLtrMarkPeriod = 30;
-param.uiIntraPeriod  = avctx->gop_size;
-#if OPENH264_VER_AT_LEAST(1, 4)
-param.eSpsPpsIdStrategy  = CONSTANT_ID;
-#else
-param.bEnableSpsPpsIdAddition= 0;
-#endif
-param.bPrefixNalAddingCtrl   = 0;
-param.iLoopFilterDisableIdc  = !s->loopfilter;
-param.iEntropyCodingModeFlag = 0;
-param.iMultipleThreadIdc = avctx->thread_count;
-if (s->profile && !strcmp(s->profile, "main"))
-param.iEntropyCodingModeFlag = 1;
-else if (!s->profile && s->cabac)
-param.iEntropyCodingModeFlag = 1;
+param->bEnableDenoise = 0;  // Denoise control
+param->bEnableBackgroundDetection = 1;  // Background detection control
 
-param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
-

[FFmpeg-devel] [PATCH 10/10] lavc/libopenh264enc: replace cabac option with coder

2020-04-03 Thread Linjie Fu
Change the default option to -1 and allow the default cabac to be
decided by profile.

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 70ded55..94faeef 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -46,7 +46,7 @@ typedef struct SVCContext {
 int max_nal_size;
 int skip_frames;
 int skipped;
-int cabac;
+int coder;
 
 // rate control mode
 int rc_mode;
@@ -78,7 +78,12 @@ static const AVOption options[] = {
 #undef PROFILE
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
-{ "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
+{ "coder", "Coder type",  OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, 
-1, 1, VE, "coder" },
+{ "default",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 
INT_MIN, INT_MAX, VE, "coder" },
+{ "cavlc",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "cabac",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "vlc",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  
INT_MIN, INT_MAX, VE, "coder" },
+{ "ac",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  
INT_MIN, INT_MAX, VE, "coder" },
 
 { "rc_mode", "Select rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, 
{ .i64 = RC_QUALITY_MODE }, RC_OFF_MODE, RC_TIMESTAMP_MODE, VE, "rc_mode" },
 { "off",   "bit rate control off", 
0, AV_OPT_TYPE_CONST, { .i64 = RC_OFF_MODE }, 0, 0, VE, 
"rc_mode" },
@@ -127,8 +132,15 @@ static av_cold int svc_encode_init_profile(AVCodecContext 
*avctx, SEncParamExt *
 break;
 }
 
-if (s->profile == FF_PROFILE_UNKNOWN)
-s->profile = s->cabac ? FF_PROFILE_H264_HIGH :
+#if FF_API_CODER_TYPE
+FF_DISABLE_DEPRECATION_WARNINGS
+if (s->coder < 0 && avctx->coder_type == FF_CODER_TYPE_AC)
+s->coder = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+if (s->profile == FF_PROFILE_UNKNOWN && s->coder >= 0)
+s->profile = s->coder ? FF_PROFILE_H264_HIGH :
 FF_PROFILE_H264_CONSTRAINED_BASELINE;
 
 switch (s->profile) {
@@ -348,13 +360,6 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 
 (*s->encoder)->GetDefaultParams(s->encoder, );
 
-#if FF_API_CODER_TYPE
-FF_DISABLE_DEPRECATION_WARNINGS
-if (!s->cabac)
-s->cabac = avctx->coder_type == FF_CODER_TYPE_AC;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 if (err = svc_encode_init_params(avctx, ) < 0)
 return err;
 
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 09/10] lavc/libopenh264enc: allow specifying the profile through AVCodecContext

2020-04-03 Thread Linjie Fu
Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index d331cfd..70ded55 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -111,6 +111,22 @@ static av_cold int svc_encode_init_profile(AVCodecContext 
*avctx, SEncParamExt *
 {
 SVCContext *s = avctx->priv_data;
 
+/* Allow specifying the libopenh264 profile through AVCodecContext. */
+if (FF_PROFILE_UNKNOWN == s->profile &&
+FF_PROFILE_UNKNOWN != avctx->profile)
+switch (avctx->profile) {
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
+break;
+case FF_PROFILE_H264_HIGH:
+s->profile = FF_PROFILE_H264_HIGH;
+break;
+default:
+av_log(avctx, AV_LOG_WARNING,
+   "Unsupported avctx->profile: %d.\n", avctx->profile);
+break;
+}
+
 if (s->profile == FF_PROFILE_UNKNOWN)
 s->profile = s->cabac ? FF_PROFILE_H264_HIGH :
 FF_PROFILE_H264_CONSTRAINED_BASELINE;
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 05/10] lavc/libopenh264enc: prompt slice number changing according to cpus

2020-04-03 Thread Linjie Fu
Libopenh264enc would set the slice according to the number of cpu cores
if uiSliceNum equals to 0 (auto) in SM_FIXEDSLCNUM_SLICE mode.

Prompt a warning for user to catch this.

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index dab8244..01a85fb 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -237,6 +237,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.sSpatialLayers[0].sSliceCfg.uiSliceMode   = 
s->slice_mode;
 param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 
avctx->slices;
 #endif
+if (avctx->slices == 0 && s->slice_mode == SM_FIXEDSLCNUM_SLICE)
+av_log(avctx, AV_LOG_WARNING, "Auto slice number, "
+   "default to use the number of CPU cores: %d\n", av_cpu_count());
 
 if (s->slice_mode == SM_SIZELIMITED_SLICE) {
 if (s->max_nal_size) {
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 04/10] lavc/libopenh264enc: add bit rate control select support

2020-04-03 Thread Linjie Fu
RC_BITRATE_MODE:
set BITS_EXCEEDED to iCurrentBitsLevel and allows QP adjust
in RcCalculatePictureQp().

RC_BUFFERBASED_MODE:
use buffer status to adjust the video quality.

RC_TIMESTAMP_MODE:
bit rate control based on timestamp.

Default to use RC_QUALITY_MODE.

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 3ff5be7..dab8244 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -47,6 +47,9 @@ typedef struct SVCContext {
 int skip_frames;
 int skipped;
 int cabac;
+
+// rate control mode
+int rc_mode;
 } SVCContext;
 
 #define OFFSET(x) offsetof(SVCContext, x)
@@ -71,6 +74,13 @@ static const AVOption options[] = {
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
+
+{ "rc_mode", "Select rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, 
{ .i64 = RC_QUALITY_MODE }, RC_OFF_MODE, RC_TIMESTAMP_MODE, VE, "rc_mode" },
+{ "off",   "bit rate control off", 
0, AV_OPT_TYPE_CONST, { .i64 = RC_OFF_MODE }, 0, 0, VE, 
"rc_mode" },
+{ "quality",   "quality mode", 
0, AV_OPT_TYPE_CONST, { .i64 = RC_QUALITY_MODE }, 0, 0, VE, 
"rc_mode" },
+{ "bitrate",   "bitrate mode", 
0, AV_OPT_TYPE_CONST, { .i64 = RC_BITRATE_MODE }, 0, 0, VE, 
"rc_mode" },
+{ "buffer","using buffer status to adjust the video quality (no 
bitrate control)", 0, AV_OPT_TYPE_CONST, { .i64 = RC_BUFFERBASED_MODE }, 0, 0, 
VE, "rc_mode" },
+{ "timestamp", "bit rate control based on timestamp",  
0, AV_OPT_TYPE_CONST, { .i64 = RC_TIMESTAMP_MODE },   0, 0, VE, 
"rc_mode" },
 { NULL }
 };
 
@@ -134,7 +144,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.iPicHeight = avctx->height;
 param.iTargetBitrate = avctx->bit_rate;
 param.iMaxBitrate= FFMAX(avctx->rc_max_rate, 
avctx->bit_rate);
-param.iRCMode= RC_QUALITY_MODE;
+param.iRCMode= s->rc_mode;
 // QP = 0 is not well supported, so default to (1, 51)
 param.iMaxQp = avctx->qmax >= 0 ? av_clip(avctx->qmax, 
1, 51) : 51;
 param.iMinQp = avctx->qmin >= 0 ? av_clip(avctx->qmin, 
1, param.iMaxQp) : 1;
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 06/10] lavc/libopenh264enc: set slice_mode option to deprecated

2020-04-03 Thread Linjie Fu
"slice mode" seems to be unnecessary since it could be determined by
-slices/max_nal_size.

default:SM_FIXEDSLCNUM_SLICE mode with cpu-number slices.
-slices N:  SM_FIXEDSLCNUM_SLICE mode with N slices.
-max_nal_size:  SM_SIZELIMITED_SLICE mode with limited size slices.

This could be removed later.

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 01a85fb..e89cedf 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -40,7 +40,7 @@
 typedef struct SVCContext {
 const AVClass *av_class;
 ISVCEncoder *encoder;
-int slice_mode;
+int slice_mode; // deprecated
 int loopfilter;
 char *profile;
 int max_nal_size;
@@ -54,11 +54,12 @@ typedef struct SVCContext {
 
 #define OFFSET(x) offsetof(SVCContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+#define DEPRECATED AV_OPT_FLAG_DEPRECATED
 static const AVOption options[] = {
 #if OPENH264_VER_AT_LEAST(1, 6)
-{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_FIXEDSLCNUM_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+{ "slice_mode", "set slice mode, use slices/max_nal_size", 
OFFSET(slice_mode), AV_OPT_TYPE_INT, { .i64 = SM_FIXEDSLCNUM_SLICE }, 
SM_SINGLE_SLICE, SM_RESERVED, VE|DEPRECATED, "slice_mode" },
 #else
-{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+{ "slice_mode", "set slice mode, use slices/max_nal_size", 
OFFSET(slice_mode), AV_OPT_TYPE_INT, { .i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, 
SM_RESERVED, VE|DEPRECATED, "slice_mode" },
 #endif
 { "fixed", "a fixed number of slices", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_FIXEDSLCNUM_SLICE }, 0, 0, VE, "slice_mode" },
 #if OPENH264_VER_AT_LEAST(1, 6)
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 02/10] lavc/libopenh264enc: fix the if-else coding style

2020-04-03 Thread Linjie Fu
Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 364926f..c7ae5b1 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -202,8 +202,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.sSpatialLayers[0].eAspectRatio = asp_idc[i];
 }
 param.sSpatialLayers[0].bAspectRatioPresent = true;
-}
-else {
+} else {
 param.sSpatialLayers[0].bAspectRatioPresent = false;
 }
 #endif
@@ -230,7 +229,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 if (s->slice_mode == SM_SIZELIMITED_SLICE) {
-if (s->max_nal_size){
+if (s->max_nal_size) {
 param.uiMaxNalSize = s->max_nal_size;
 #if OPENH264_VER_AT_LEAST(1, 6)
 param.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = 
s->max_nal_size;
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 03/10] lavc/libopenh264enc: add default gop size and bit rate

2020-04-03 Thread Linjie Fu
Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index c7ae5b1..3ff5be7 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -335,6 +335,8 @@ static int svc_encode_frame(AVCodecContext *avctx, AVPacket 
*avpkt,
 }
 
 static const AVCodecDefault svc_enc_defaults[] = {
+{ "b", "2M"},
+{ "g", "120"   },
 { "qmin",  "-1"},
 { "qmax",  "-1"},
 { NULL },
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 01/10] lavc/libopenh264enc: Add default qmin/qmax support

2020-04-03 Thread Linjie Fu
Set default QP range to (1, 51) instead of (2, 32).

QP = 0 is not well supported currently in libopenh264. If iMaxQp/iMinQp
equals 0, the QP range would be changed unexpectedly inside libopenh264
with a warning:

Warning:Change QP Range from(0,51) to (12,42)

[1] 

[2] 

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index ae6d17c..364926f 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -135,6 +135,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.iTargetBitrate = avctx->bit_rate;
 param.iMaxBitrate= FFMAX(avctx->rc_max_rate, 
avctx->bit_rate);
 param.iRCMode= RC_QUALITY_MODE;
+// QP = 0 is not well supported, so default to (1, 51)
+param.iMaxQp = avctx->qmax >= 0 ? av_clip(avctx->qmax, 
1, 51) : 51;
+param.iMinQp = avctx->qmin >= 0 ? av_clip(avctx->qmin, 
1, param.iMaxQp) : 1;
 param.iTemporalLayerNum  = 1;
 param.iSpatialLayerNum   = 1;
 param.bEnableDenoise = 0;
@@ -332,6 +335,12 @@ static int svc_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 return 0;
 }
 
+static const AVCodecDefault svc_enc_defaults[] = {
+{ "qmin",  "-1"},
+{ "qmax",  "-1"},
+{ NULL },
+};
+
 AVCodec ff_libopenh264_encoder = {
 .name   = "libopenh264",
 .long_name  = NULL_IF_CONFIG_SMALL("OpenH264 H.264 / AVC / MPEG-4 AVC 
/ MPEG-4 part 10"),
@@ -345,6 +354,7 @@ AVCodec ff_libopenh264_encoder = {
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
 AV_PIX_FMT_NONE },
+.defaults   = svc_enc_defaults,
 .priv_class = ,
 .wrapper_name   = "libopenh264",
 };
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 00/10] Patch set for the enhancement of libopenh264 encoder

2020-04-03 Thread Linjie Fu
Docs will be provided later.

Linjie Fu (10):
  lavc/libopenh264enc: Add default qmin/qmax support
[v2] fix the av_clip logic for iMinQp.
  lavc/libopenh264enc: fix the if-else coding style
  lavc/libopenh264enc: add default gop size and bit rate
  lavc/libopenh264enc: add bit rate control select support
  lavc/libopenh264enc: prompt slice number changing according to cpus
  lavc/libopenh264enc: set slice_mode option to deprecated
  lavc/libopenh264enc: separate svc_encode_init() into several functions
[v2] remove forward declarations.
New:
  lavc/libopenh264enc: add profile high option support
  lavc/libopenh264enc: allow specifying the profile through AVCodecContext
  lavc/libopenh264enc: replace cabac option with coder

 libavcodec/libopenh264enc.c | 361 ++--
 1 file changed, 246 insertions(+), 115 deletions(-)

-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH v2 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread lance . lmwang
From: Limin Wang 

make setting profile more user friendly

Signed-off-by: Limin Wang 
---
 doc/encoders.texi  |  8 
 libavcodec/mpeg12enc.c | 22 +-
 libavcodec/mpegvideo.h |  1 +
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index e23b6b3..5022b94 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2753,6 +2753,14 @@ For maximum compatibility, use @samp{component}.
 @item a53cc @var{boolean}
 Import closed captions (which must be ATSC compatible format) into output.
 Default is 1 (on).
+@item profile @var{integer}
+Select the mpeg2 profile to encode, possible values:
+@table @samp
+@item 422
+@item high
+@item main
+@item simple
+@end table
 @end table
 
 @section png
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 643ba81..2f4c889 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -156,23 +156,30 @@ static av_cold int encode_init(AVCodecContext *avctx)
 }
 }
 
-if (avctx->profile == FF_PROFILE_UNKNOWN) {
+if (avctx->profile != FF_PROFILE_UNKNOWN)
+s->profile = avctx->profile;
+
+if (s->profile == FF_PROFILE_UNKNOWN) {
 if (avctx->level != FF_LEVEL_UNKNOWN) {
 av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
 return -1;
 }
 /* Main or 4:2:2 */
 avctx->profile = s->chroma_format == CHROMA_420 ? 
FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
+s->profile = s->chroma_format == CHROMA_420 ? FF_PROFILE_MPEG2_MAIN : 
FF_PROFILE_MPEG2_422;
+} else if (s->profile < FF_PROFILE_MPEG2_422) {
+av_log(avctx, AV_LOG_ERROR, "Invalid mpeg2 profile set\n");
+return -1;
 }
 
 if (avctx->level == FF_LEVEL_UNKNOWN) {
-if (avctx->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
+if (s->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
 if (avctx->width <= 720 && avctx->height <= 608)
 avctx->level = 5;   /* Main */
 else
 avctx->level = 2;   /* High */
 } else {
-if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
+if (s->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
 av_log(avctx, AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color 
sampling\n");
 return -1;
@@ -321,9 +328,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 put_header(s, EXT_START_CODE);
 put_bits(>pb, 4, 1); // seq ext
 
-put_bits(>pb, 1, s->avctx->profile == FF_PROFILE_MPEG2_422); // 
escx 1 for 4:2:2 profile
+put_bits(>pb, 1, s->profile == FF_PROFILE_MPEG2_422); // escx 1 
for 4:2:2 profile
 
-put_bits(>pb, 3, s->avctx->profile); // profile
+put_bits(>pb, 3, s->profile); // profile
 put_bits(>pb, 4, s->avctx->level);   // level
 
 put_bits(>pb, 1, s->progressive_sequence);
@@ -1165,6 +1172,11 @@ static const AVOption mpeg2_options[] = {
 { "secam",NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_SECAM  },  0, 0, VE, "video_format" },
 { "mac",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_MAC},  0, 0, VE, "video_format" },
 { "unspecified",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_UNSPECIFIED},  0, 0, VE, "video_format" },
+{ "profile",  "Set the profile",  OFFSET(profile),   
AV_OPT_TYPE_INT,{ .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 
FF_PROFILE_MPEG2_SIMPLE, VE, "profile" },
+{ "422",  "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_422 }, 0, 0, VE, "profile" },
+{ "high", "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_HIGH}, 0, 0, VE, "profile" },
+{ "main", "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_MAIN}, 0, 0, VE, "profile" },
+{ "simple",   "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_SIMPLE  }, 0, 0, VE, "profile" },
 FF_MPV_COMMON_OPTS
 { NULL },
 };
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 29e692f..cee423e 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -456,6 +456,7 @@ typedef struct MpegEncContext {
 int progressive_sequence;
 int mpeg_f_code[2][2];
 int a53_cc;
+int profile;
 
 // picture structure defines are loaded from mpegutils.h
 int picture_structure;
-- 
2.9.5

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

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

Re: [FFmpeg-devel] [PATCH v1] fftools/ffmpeg: set AV_PKT_FLAG_KEY for the subtitle packet

2020-04-03 Thread Limin Wang
On Fri, Mar 27, 2020 at 01:47:10AM +0100, Michael Niedermayer wrote:
> On Thu, Mar 26, 2020 at 10:47:37AM +0100, Anton Khirnov wrote:
> > Quoting Andreas Rheinhardt (2020-03-20 17:51:41)
> > > Jan Ekström:
> > > > On Fri, Mar 20, 2020 at 5:45 PM  wrote:
> > > >>
> > > >> From: Limin Wang 
> > > >>
> > > >> This fixes webvtt segment output.
> > > >>
> > > >> Please testing with the following command and check the output:
> > > >> ./ffmpeg -i ../fate-suite/sub/MicroDVD_capability_tester.srt -f 
> > > >> segment -segment_time 10 \
> > > >> -segment_list_size 0  -segment_list sub.m3u8 -segment_format 
> > > >> webvtt -scodec webvtt sub-%d.vtt
> > > >>
> > > >>
> > > >> Signed-off-by: Limin Wang 
> > > >> ---
> > > >>  fftools/ffmpeg.c |  1 +
> > > >>  tests/ref/fate/binsub-movtextenc |  2 +-
> > > >>  tests/ref/fate/sub2video | 86 
> > > >>  3 files changed, 45 insertions(+), 44 deletions(-)
> > > >>
> > > >> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > > >> index aaaf241314..c5a2d0731d 100644
> > > >> --- a/fftools/ffmpeg.c
> > > >> +++ b/fftools/ffmpeg.c
> > > >> @@ -1054,6 +1054,7 @@ static void do_subtitle_out(OutputFile *of,
> > > >>  else
> > > >>  pkt.pts += av_rescale_q(sub->end_display_time, 
> > > >> (AVRational){ 1, 1000 }, ost->mux_timebase);
> > > >>  }
> > > >> +pkt.flags |= AV_PKT_FLAG_KEY;
> > > >>  pkt.dts = pkt.pts;
> > > >>  output_packet(of, , ost, 0);
> > > >>  }
> > > > 
> > > > I do wonder if this is just a case of people forgetting to set the
> > > > flag for the relevant packets in the relevant modules?
> > > > 
> > > > I'm not sure if all API users should be forced to handle this
> > > > separately. If the packets are decode'able by themselves, they should
> > > > be marked as such.
> > > > 
> > > > (Unfortunately, this probably means that all subtitle encoders and
> > > > text-based subtitle format demuxers would have to be updated where
> > > > this flag is not set)
> > > > 
> > > av_read_frame() already sets the AV_PKT_FLAG_KEY-flag for all subtitle
> > > packets (see is_intra_only() in libavformat/utils.c; the subtitle
> > > demuxer based around FFDemuxSubtitlesQueues actually have the flag set
> > > even before it reaches is_intra_only()). One could do something similar
> > > in libavformat/mux.c.
> > > But are we actually sure that all subtitle packets are decodable by
> > > themselves? IIRC this is not true for all PGS subtitles.
> > > 
> > > - Andreas
> > > 
> > > PS: The semantics of the AV_CODEC_PROP_INTRA_ONLY-flag seem to be based
> > > around the assumption that subtitle packets are always intra-only: It is
> > > only for video and audio-codecs only.
> > 
> > I would interpret it as simply not being defined for subtitles, rather
> > than saying they are all always intra only. So we can always add new
> > semantics for subtitles to it.
> 
> +1
I have updated the patch, please review whether it's expected.

> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> The real ebay dictionary, page 2
> "100% positive feedback" - "All either got their money back or didnt complain"
> "Best seller ever, very honest" - "Seller refunded buyer after failed scam"



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

2020-04-03 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mux.c| 16 
 tests/ref/fate/binsub-movtextenc |  2 +-
 tests/ref/fate/movenc| 50 +++
 tests/ref/fate/sub2video | 86 
 4 files changed, 85 insertions(+), 69 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index cc2d1e2..dc897c2 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -548,6 +548,17 @@ fail:
 return ret;
 }
 
+static int is_intra_only(enum AVCodecID id)
+{
+const AVCodecDescriptor *d = avcodec_descriptor_get(id);
+if (!d)
+return 0;
+if ((d->type == AVMEDIA_TYPE_VIDEO || d->type == AVMEDIA_TYPE_AUDIO) &&
+!(d->props & AV_CODEC_PROP_INTRA_ONLY))
+return 0;
+return 1;
+}
+
 #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
 
 /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but
@@ -664,6 +675,11 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, 
AVStream *st, AVPacket *
 frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * 
st->time_base.num);
 break;
 }
+
+/* update flags */
+if (is_intra_only(st->codecpar->codec_id))
+pkt->flags |= AV_PKT_FLAG_KEY;
+
 return 0;
 }
 FF_ENABLE_DEPRECATION_WARNINGS
diff --git a/tests/ref/fate/binsub-movtextenc b/tests/ref/fate/binsub-movtextenc
index 78c05f4..a8f94b7 100644
--- a/tests/ref/fate/binsub-movtextenc
+++ b/tests/ref/fate/binsub-movtextenc
@@ -1 +1 @@
-35adf776cd73e808186ae7124445f4b8
+fc6d07679ac1f718aa50de687924cd97
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 637a347..fb39b98 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -2,17 +2,17 @@ write_data len 36, time nopts, type header atom ftyp
 write_data len 2389, time nopts, type header atom -
 write_data len 788, time 100, type sync atom moof
 write_data len 110, time nopts, type trailer atom -
-66cf48604f039aa9a51711786f5c8778 3323 non-empty-moov
+5f401347fc3c771b819e2449d69d4861 3323 non-empty-moov
 write_data len 36, time nopts, type header atom ftyp
 write_data len 2721, time nopts, type header atom -
 write_data len 908, time 97, type sync atom moof
 write_data len 110, time nopts, type trailer atom -
-04b2e86f455af94f9258b8d66dbf71f5 3775 non-empty-moov-elst
+4267feee527adf8cd4f7b36ac0fc0872 3775 non-empty-moov-elst
 write_data len 36, time nopts, type header atom ftyp
 write_data len 2629, time nopts, type header atom -
 write_data len 908, time 100, type sync atom moof
 write_data len 110, time nopts, type trailer atom -
-e9f6fa032d6d8265d67aef5de81a48bf 3683 non-empty-moov-no-elst
+44077b9ad45f3e16fafe4e5ada54e9b0 3683 non-empty-moov-no-elst
 write_data len 24, time nopts, type header atom ftyp
 write_data len 1171, time nopts, type header atom -
 write_data len 728, time 0, type sync atom moof
@@ -20,35 +20,35 @@ write_data len 828, time nopts, type unknown atom -
 write_data len 728, time 99, type sync atom moof
 write_data len 812, time nopts, type unknown atom -
 write_data len 148, time nopts, type trailer atom -
-da105e0b2c19079519c6eed7d5a1151c 4439 ismv
+92ce825ff40505ec8676191705adb7e7 4439 ismv
 write_data len 36, time nopts, type header atom ftyp
 write_data len 1123, time nopts, type header atom -
 write_data len 796, time 0, type sync atom moof
 write_data len 788, time 100, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
-e6a4b15443d006efd727a80f6624b7db 2891 empty-moov
+08f4b3ad3a3ea224b2ee731476b9056b 2891 empty-moov
 write_data len 36, time nopts, type header atom ftyp
 write_data len 1123, time nopts, type header atom -
 write_data len 1068, time 0, type sync atom moof
 write_data len 908, time 100, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
-800f854aff2ac76dfaddebd0562c75b9 3283 empty-moov-no-elst
+d7a2dcb43eb0f95f92669f55fc7adeba 3283 empty-moov-no-elst
 write_data len 36, time nopts, type header atom ftyp
 write_data len 1123, time nopts, type header atom -
 write_data len 900, time -3, type sync atom moof
 write_data len 908, time 97, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
-eca1a945c9063dab0858af6b85925533 3115 empty-moov-no-elst-no-adjust
+ea70ca697306976879be408431c27aee 3115 empty-moov-no-elst-no-adjust
 write_data len 1159, time nopts, type header atom ftyp
 write_data len 796, time 0, type sync atom moof
 write_data len 788, time 100, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
-e6a4b15443d006efd727a80f6624b7db 2891 delay-moov
+08f4b3ad3a3ea224b2ee731476b9056b 2891 delay-moov
 write_data len 1231, time nopts, type header atom ftyp
 write_data len 916, time -3, type sync atom moof
 write_data len 908, time 97, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
-c2ecdbc80668fcee73f5a039e2dba579 3203 delay-moov-elst
+314cc3b6296f4ee583b328a34be50b2f 3203 

Re: [FFmpeg-devel] [PATCH 1/3] avformat/ilbc: Don't reimplement ff_raw_write_packet

2020-04-03 Thread Michael Niedermayer
On Thu, Apr 02, 2020 at 07:17:38PM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/ilbc.c | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.


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

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

Re: [FFmpeg-devel] [PATCH 3/3] avformat/dss: Remove unnecessary allocation

2020-04-03 Thread Michael Niedermayer
On Thu, Apr 02, 2020 at 07:17:40PM +0200, Andreas Rheinhardt wrote:
> Put a buffer with a known fixed size into the demuxer's context instead
> of allocating it separately. This also allows to remove the demuxer's
> read_close()-function.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/dss.c | 16 +---
>  1 file changed, 1 insertion(+), 15 deletions(-)

LGTM

thx

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

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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

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

Re: [FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread Hendrik Leppkes
On Fri, Apr 3, 2020 at 3:12 PM  wrote:
>
> From: Limin Wang 
>
> make setting profile more user friendly
>

Please make sure API users can still set it through avctx->profile,
otherwise this would be an API break.

- Hendrik
___
ffmpeg-devel mailing list
ffmpeg-devel@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 v1] avformat/concat: priv_data should be freed internally

2020-04-03 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/concat.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/concat.c b/libavformat/concat.c
index ea3bc1dfde..cfe14760eb 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -75,7 +75,6 @@ static av_cold int concat_open(URLContext *h, const char 
*uri, int flags)
 if (uri[i] == *AV_CAT_SEPARATOR) {
 /* integer overflow */
 if (++len == UINT_MAX / sizeof(*nodes)) {
-av_freep(>priv_data);
 return AVERROR(ENAMETOOLONG);
 }
 }
-- 
2.21.0

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

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

[FFmpeg-devel] [PATCH v1 2/2] avcodec/mpeg12enc: Support mpeg2 encoder profile with const options

2020-04-03 Thread lance . lmwang
From: Limin Wang 

make setting profile more user friendly

Signed-off-by: Limin Wang 
---
 doc/encoders.texi  |  8 
 libavcodec/mpeg12enc.c | 19 ++-
 libavcodec/mpegvideo.h |  1 +
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index e23b6b32fe..5022b9407e 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2753,6 +2753,14 @@ For maximum compatibility, use @samp{component}.
 @item a53cc @var{boolean}
 Import closed captions (which must be ATSC compatible format) into output.
 Default is 1 (on).
+@item profile @var{integer}
+Select the mpeg2 profile to encode, possible values:
+@table @samp
+@item 422
+@item high
+@item main
+@item simple
+@end table
 @end table
 
 @section png
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 643ba8165a..ef8757e5b7 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -156,23 +156,27 @@ static av_cold int encode_init(AVCodecContext *avctx)
 }
 }
 
-if (avctx->profile == FF_PROFILE_UNKNOWN) {
+if (s->profile == FF_PROFILE_UNKNOWN) {
 if (avctx->level != FF_LEVEL_UNKNOWN) {
 av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
 return -1;
 }
 /* Main or 4:2:2 */
 avctx->profile = s->chroma_format == CHROMA_420 ? 
FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
+s->profile = s->chroma_format == CHROMA_420 ? FF_PROFILE_MPEG2_MAIN : 
FF_PROFILE_MPEG2_422;
+} else if (s->profile < FF_PROFILE_MPEG2_422) {
+av_log(avctx, AV_LOG_ERROR, "Invalid mpeg2 profile set\n");
+return -1;
 }
 
 if (avctx->level == FF_LEVEL_UNKNOWN) {
-if (avctx->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
+if (s->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
 if (avctx->width <= 720 && avctx->height <= 608)
 avctx->level = 5;   /* Main */
 else
 avctx->level = 2;   /* High */
 } else {
-if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
+if (s->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
 av_log(avctx, AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color 
sampling\n");
 return -1;
@@ -321,9 +325,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 put_header(s, EXT_START_CODE);
 put_bits(>pb, 4, 1); // seq ext
 
-put_bits(>pb, 1, s->avctx->profile == FF_PROFILE_MPEG2_422); // 
escx 1 for 4:2:2 profile
+put_bits(>pb, 1, s->profile == FF_PROFILE_MPEG2_422); // escx 1 
for 4:2:2 profile
 
-put_bits(>pb, 3, s->avctx->profile); // profile
+put_bits(>pb, 3, s->profile); // profile
 put_bits(>pb, 4, s->avctx->level);   // level
 
 put_bits(>pb, 1, s->progressive_sequence);
@@ -1165,6 +1169,11 @@ static const AVOption mpeg2_options[] = {
 { "secam",NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_SECAM  },  0, 0, VE, "video_format" },
 { "mac",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_MAC},  0, 0, VE, "video_format" },
 { "unspecified",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 
VIDEO_FORMAT_UNSPECIFIED},  0, 0, VE, "video_format" },
+{ "profile",  "Set the profile",  OFFSET(profile),   
AV_OPT_TYPE_INT,{ .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 
FF_PROFILE_MPEG2_SIMPLE, VE, "profile" },
+{ "422",  "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_422 }, 0, 0, VE, "profile" },
+{ "high", "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_HIGH}, 0, 0, VE, "profile" },
+{ "main", "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_MAIN}, 0, 0, VE, "profile" },
+{ "simple",   "",   0, AV_OPT_TYPE_CONST,{ .i64 = 
FF_PROFILE_MPEG2_SIMPLE  }, 0, 0, VE, "profile" },
 FF_MPV_COMMON_OPTS
 { NULL },
 };
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 29e692f245..cee423eea1 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -456,6 +456,7 @@ typedef struct MpegEncContext {
 int progressive_sequence;
 int mpeg_f_code[2][2];
 int a53_cc;
+int profile;
 
 // picture structure defines are loaded from mpegutils.h
 int picture_structure;
-- 
2.21.0

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

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

[FFmpeg-devel] [PATCH v1 1/2] avcodec/mpeg12enc: Use FF_PROFILE_MPEG2_xxx macros

2020-04-03 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index b460e78a59..643ba8165a 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -162,17 +162,17 @@ static av_cold int encode_init(AVCodecContext *avctx)
 return -1;
 }
 /* Main or 4:2:2 */
-avctx->profile = s->chroma_format == CHROMA_420 ? 4 : 0;
+avctx->profile = s->chroma_format == CHROMA_420 ? 
FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
 }
 
 if (avctx->level == FF_LEVEL_UNKNOWN) {
-if (avctx->profile == 0) {  /* 4:2:2 */
+if (avctx->profile == FF_PROFILE_MPEG2_422) {   /* 4:2:2 */
 if (avctx->width <= 720 && avctx->height <= 608)
 avctx->level = 5;   /* Main */
 else
 avctx->level = 2;   /* High */
 } else {
-if (avctx->profile != 1 && s->chroma_format != CHROMA_420) {
+if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
 av_log(avctx, AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color 
sampling\n");
 return -1;
@@ -321,7 +321,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 put_header(s, EXT_START_CODE);
 put_bits(>pb, 4, 1); // seq ext
 
-put_bits(>pb, 1, s->avctx->profile == 0); // escx 1 for 4:2:2 
profile
+put_bits(>pb, 1, s->avctx->profile == FF_PROFILE_MPEG2_422); // 
escx 1 for 4:2:2 profile
 
 put_bits(>pb, 3, s->avctx->profile); // profile
 put_bits(>pb, 4, s->avctx->level);   // level
-- 
2.21.0

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

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

[FFmpeg-devel] [PATCH] ffplay: always show stats at all log levels if requested by user

2020-04-03 Thread Gyan Doshi
Since 3b491c5a500, stats would be hidden if loglevel was lower than
info, even if -stats was set.
---
 fftools/ffplay.c | 36 
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2ed4b22d3e..d529c60e81 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -40,6 +40,7 @@
 #include "libavutil/samplefmt.h"
 #include "libavutil/avassert.h"
 #include "libavutil/time.h"
+#include "libavutil/bprint.h"
 #include "libavformat/avformat.h"
 #include "libavdevice/avdevice.h"
 #include "libswscale/swscale.h"
@@ -326,7 +327,7 @@ static int display_disable;
 static int borderless;
 static int alwaysontop;
 static int startup_volume = 100;
-static int show_status = 1;
+static int show_status = -1;
 static int av_sync_type = AV_SYNC_AUDIO_MASTER;
 static int64_t start_time = AV_NOPTS_VALUE;
 static int64_t duration = AV_NOPTS_VALUE;
@@ -1692,6 +1693,7 @@ display:
 }
 is->force_refresh = 0;
 if (show_status) {
+AVBPrint buf;
 static int64_t last_time;
 int64_t cur_time;
 int aqsize, vqsize, sqsize;
@@ -1715,18 +1717,28 @@ display:
 av_diff = get_master_clock(is) - get_clock(>vidclk);
 else if (is->audio_st)
 av_diff = get_master_clock(is) - get_clock(>audclk);
-av_log(NULL, AV_LOG_INFO,
-   "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB 
f=%"PRId64"/%"PRId64"   \r",
-   get_master_clock(is),
-   (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? 
"M-V" : (is->audio_st ? "M-A" : "   ")),
-   av_diff,
-   is->frame_drops_early + is->frame_drops_late,
-   aqsize / 1024,
-   vqsize / 1024,
-   sqsize,
-   is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_dts : 0,
-   is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_pts : 0);
+
+av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
+av_bprintf(,
+  "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB 
f=%"PRId64"/%"PRId64"   \r",
+  get_master_clock(is),
+  (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? 
"M-V" : (is->audio_st ? "M-A" : "   ")),
+  av_diff,
+  is->frame_drops_early + is->frame_drops_late,
+  aqsize / 1024,
+  vqsize / 1024,
+  sqsize,
+  is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_dts : 0,
+  is->video_st ? 
is->viddec.avctx->pts_correction_num_faulty_pts : 0);
+
+if (show_status == 1 && AV_LOG_INFO > av_log_get_level())
+printf("%s", buf.str);
+else
+av_log(NULL, AV_LOG_INFO, "%s", buf.str);
+
 fflush(stdout);
+av_bprint_finalize(, NULL);
+
 last_time = cur_time;
 }
 }
-- 
2.26.0

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

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

Re: [FFmpeg-devel] [PATCH 7/7] lavc/libopenh264enc: separate svc_encode_init() into several functions

2020-04-03 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of Fu,
> Linjie
> Sent: Tuesday, March 31, 2020 23:59
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 7/7] lavc/libopenh264enc: separate
> svc_encode_init() into several functions
> 
> > From: ffmpeg-devel  On Behalf Of
> > James Almer
> > Sent: Tuesday, March 31, 2020 23:46
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH 7/7] lavc/libopenh264enc: separate
> > svc_encode_init() into several functions
> >
> > On 3/31/2020 12:33 PM, Linjie Fu wrote:
> > > Separate the initialization procedure into different functions.
> > >
> > > Make it more readable and easier to be extended.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > >  libavcodec/libopenh264enc.c | 302 +++---
> --
> > 
> > >  1 file changed, 186 insertions(+), 116 deletions(-)
> > >
> > > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > > index 692aba9..ab54454 100644
> > > --- a/libavcodec/libopenh264enc.c
> > > +++ b/libavcodec/libopenh264enc.c
> > > @@ -85,6 +85,11 @@ static const AVOption options[] = {
> > >  { NULL }
> > >  };
> > >
> > > +static av_cold int svc_encode_init_profile(AVCodecContext *avctx,
> > SEncParamExt *param);
> > > +static av_cold int svc_encode_init_rate_control(AVCodecContext
> *avctx,
> > SEncParamExt *param);
> > > +static av_cold int svc_encode_init_spatial_layer(AVCodecContext
> *avctx,
> > SEncParamExt *param);
> > > +static av_cold int svc_encode_init_params(AVCodecContext *avctx,
> > SEncParamExt *param);
> >
> > Why use forward declarations? Just put the functions right above
> > svc_encode_init().
> 
> It's seems to be easier/clearer for review the diffs, otherwise this would be
> mixed
> up.

Ping for the rest patches in this patch set.
Will update V2 soon with the forward declarations removed as suggested.

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

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/matroskaenc: Don't fail if reserved Cues space doesn't suffice

2020-04-03 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> When the user opted to write the Cues at the beginning, the Cues were
> simply written without checking in advance whether enough space has been
> reserved for them. If it wasn't enough, the data following the space
> reserved for the Cues was simply overwritten, corrupting the file.
> 
> This commit changes this by checking whether enough space has been
> reserved for the Cues before outputting anything. If it isn't enough,
> no Cues will be output at all and the file will be finalized normally,
> yet writing the trailer will nevertheless return an error to notify
> the user that his wish of having Cues at the front of the file hasn't
> been fulfilled.
> 
> This change opens new usecases for this option: It is now safe to use
> this option to e.g. record live streams or to use it when muxing the
> output of an expensive encoding, because when the reserved space turns
> out to be insufficient, one ends up with a file that just lacks Cues
> but is otherwise fine.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> v2: Now returning an error if the space reserved for the Cues does not
> suffice. (The earlier version had the drawback that the return value did
> not inform them of failure to write the Cues at the front due to the
> insufficient space reserved.) Apart from that the file is finalized normally.
> 
> I intend to apply this soon (tomorrow) if no one objects.
> 
>  doc/muxers.texi   |  5 ++-
>  libavformat/matroskaenc.c | 86 +--
>  2 files changed, 50 insertions(+), 41 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index d304181671..3be1c89416 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -1352,8 +1352,9 @@ index at the beginning of the file.
>  
>  If this option is set to a non-zero value, the muxer will reserve a given 
> amount
>  of space in the file header and then try to write the cues there when the 
> muxing
> -finishes. If the available space does not suffice, muxing will fail. A safe 
> size
> -for most use cases should be about 50kB per hour of video.
> +finishes. If the reserved space does not suffice, no Cues will be written, 
> the
> +file will be finalized and writing the trailer will return an error.
> +A safe size for most use cases should be about 50kB per hour of video.
>  
>  Note that cues are only written if the output is seekable and this option 
> will
>  have no effect if it is not.
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 5dae53026d..22cc693720 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -500,23 +500,15 @@ static int mkv_add_cuepoint(MatroskaMuxContext *mkv, 
> int stream, int tracknum, i
>  return 0;
>  }
>  
> -static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track 
> *tracks, int num_tracks)
> +static int mkv_assemble_cues(AVStream **streams, AVIOContext *dyn_cp,
> + mkv_cues *cues, mkv_track *tracks, int 
> num_tracks)
>  {
> -MatroskaMuxContext *mkv = s->priv_data;
> -AVIOContext *dyn_cp, *pb = s->pb, *cuepoint;
> -int64_t currentpos;
> +AVIOContext *cuepoint;
>  int ret;
>  
> -currentpos = avio_tell(pb);
> -ret = start_ebml_master_crc32(_cp, mkv);
> -if (ret < 0)
> -return ret;
> -
>  ret = avio_open_dyn_buf();
> -if (ret < 0) {
> -ffio_free_dyn_buf(_cp);
> +if (ret < 0)
>  return ret;
> -}
>  
>  for (mkv_cuepoint *entry = cues->entries, *end = entry + 
> cues->num_entries;
>   entry < end;) {
> @@ -535,7 +527,7 @@ static int64_t mkv_write_cues(AVFormatContext *s, 
> mkv_cues *cues, mkv_track *tra
>  int idx = entry->stream_idx;
>  
>  av_assert0(idx >= 0 && idx < num_tracks);
> -if (tracks[idx].has_cue && s->streams[idx]->codecpar->codec_type 
> != AVMEDIA_TYPE_SUBTITLE)
> +if (tracks[idx].has_cue && streams[idx]->codecpar->codec_type != 
> AVMEDIA_TYPE_SUBTITLE)
>  continue;
>  tracks[idx].has_cue = 1;
>  track_positions = start_ebml_master(cuepoint, 
> MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
> @@ -551,9 +543,8 @@ static int64_t mkv_write_cues(AVFormatContext *s, 
> mkv_cues *cues, mkv_track *tra
>  ffio_reset_dyn_buf(cuepoint);
>  }
>  ffio_free_dyn_buf();
> -end_ebml_master_crc32(pb, _cp, mkv, MATROSKA_ID_CUES);
>  
> -return currentpos;
> +return 0;
>  }
>  
>  static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, 
> AVCodecParameters *par)
> @@ -2464,7 +2455,7 @@ static int mkv_write_trailer(AVFormatContext *s)
>  {
>  MatroskaMuxContext *mkv = s->priv_data;
>  AVIOContext *pb = s->pb;
> -int64_t currentpos, cuespos;
> +int64_t currentpos;
>  int ret;
>  
>  // check if we have an audio packet cached
> @@ -2487,35 +2478,52 @@ static int mkv_write_trailer(AVFormatContext *s)
>  
>  
>  if 

Re: [FFmpeg-devel] [PATCH] fate/matroska: Add test for updating CodecPrivate from packet sidedata

2020-04-03 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> containing updated extradata, in this case a new FLAC streaminfo.
> Furthermore, it also tests that the Matroska muxer is able to preserve
> uncommon channel layouts by adding Vorbis comments to the CodecPrivate.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> This is in particular intended to test patch [1] (using fewer frames
> for the last track ensures that (after the removal of the seekbacks in
> mkv_check_new_extra_data()) the end position won't be at the end of the
> buffer when writing the final version of the Tracks element; but this
> won't be a problem after the switch to avio_get_dyn_buf() in the commit
> before [1].)
> 
> [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/256208.html
> 
Applied.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/hnm: Only keep and parse what is needed later

2020-04-03 Thread Andreas Rheinhardt
Paul B Mahol:
> ok if fate passed and it is covered.
> 
> On 3/21/20, Andreas Rheinhardt  wrote:
>> The hnm demuxer's context struct contained lots of fields that are
>> write-only variables or that are not used outside of parsing the header
>> and that can therefore be replaced by local variables of hnm_read_header().
>> This commit removes all of these from the context; the second type has
>> been replaced by local variables.
>>
>> An AVPacket (that was initialized when reading the header and for which
>> dead code to unreference it existed in hnm_read_close()) is among the
>> removed things. Removing it allowed to remove hnm_read_close()
>> altogether and also removes another instance of usage of sizeof(AVPacket).
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavformat/hnm.c | 63 +--
>>  1 file changed, 12 insertions(+), 51 deletions(-)
>>
>> diff --git a/libavformat/hnm.c b/libavformat/hnm.c
>> index 31221553a4..f06add5cf8 100644
>> --- a/libavformat/hnm.c
>> +++ b/libavformat/hnm.c
>> @@ -37,19 +37,9 @@
>>  #define HNM4_CHUNK_ID_SD 17491
>>
>>  typedef struct Hnm4DemuxContext {
>> -uint8_t version;
>> -uint16_t width;
>> -uint16_t height;
>> -uint32_t filesize;
>>  uint32_t frames;
>> -uint32_t taboffset;
>> -uint16_t bits;
>> -uint16_t channels;
>> -uint32_t framesize;
>>  uint32_t currentframe;
>> -int64_t pts;
>>  uint32_t superchunk_remaining;
>> -AVPacket vpkt;
>>  } Hnm4DemuxContext;
>>
>>  static int hnm_probe(const AVProbeData *p)
>> @@ -69,55 +59,37 @@ static int hnm_read_header(AVFormatContext *s)
>>  {
>>  Hnm4DemuxContext *hnm = s->priv_data;
>>  AVIOContext *pb = s->pb;
>> +unsigned width, height;
>>  AVStream *vst;
>>  int ret;
>>
>> -/* default context members */
>> -hnm->pts = 0;
>> -av_init_packet(>vpkt);
>> -hnm->vpkt.data = NULL;
>> -hnm->vpkt.size = 0;
>> -
>> -hnm->superchunk_remaining = 0;
>> -
>>  avio_skip(pb, 8);
>> -hnm->width = avio_rl16(pb);
>> -hnm->height= avio_rl16(pb);
>> -hnm->filesize  = avio_rl32(pb);
>> +width  = avio_rl16(pb);
>> +height = avio_rl16(pb);
>> +avio_rl32(pb); // filesize
>>  hnm->frames= avio_rl32(pb);
>> -hnm->taboffset = avio_rl32(pb);
>> -hnm->bits  = avio_rl16(pb);
>> -hnm->channels  = avio_rl16(pb);
>> -hnm->framesize = avio_rl32(pb);
>> -avio_skip(pb, 32);
>> +avio_skip(pb, 44);
>>
>> -hnm->currentframe = 0;
>> -
>> -if (hnm->width  < 256 || hnm->width  > 640 ||
>> -hnm->height < 150 || hnm->height > 480) {
>> +if (width  < 256 || width  > 640 ||
>> +height < 150 || height > 480) {
>>  av_log(s, AV_LOG_ERROR,
>> -   "invalid resolution: %ux%u\n", hnm->width, hnm->height);
>> +   "invalid resolution: %ux%u\n", width, height);
>>  return AVERROR_INVALIDDATA;
>>  }
>>
>> -// TODO: find a better way to detect HNM4A
>> -if (hnm->width == 640)
>> -hnm->version = 0x4a;
>> -else
>> -hnm->version = 0x40;
>> -
>>  if (!(vst = avformat_new_stream(s, NULL)))
>>  return AVERROR(ENOMEM);
>>
>>  vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>>  vst->codecpar->codec_id   = AV_CODEC_ID_HNM4_VIDEO;
>>  vst->codecpar->codec_tag  = 0;
>> -vst->codecpar->width  = hnm->width;
>> -vst->codecpar->height = hnm->height;
>> +vst->codecpar->width  = width;
>> +vst->codecpar->height = height;
>>  if ((ret = ff_alloc_extradata(vst->codecpar, 1)) < 0)
>>  return ret;
>>
>> -vst->codecpar->extradata[0] = hnm->version;
>> +// TODO: find a better way to detect HNM4A
>> +vst->codecpar->extradata[0] = width == 640 ? 0x4a : 0x40;
>>
>>  vst->start_time = 0;
>>
>> @@ -186,16 +158,6 @@ static int hnm_read_packet(AVFormatContext *s, AVPacket
>> *pkt)
>>  return ret;
>>  }
>>
>> -static int hnm_read_close(AVFormatContext *s)
>> -{
>> -Hnm4DemuxContext *hnm = s->priv_data;
>> -
>> -if (hnm->vpkt.size > 0)
>> -av_packet_unref(>vpkt);
>> -
>> -return 0;
>> -}
>> -
>>  AVInputFormat ff_hnm_demuxer = {
>>  .name   = "hnm",
>>  .long_name  = NULL_IF_CONFIG_SMALL("Cryo HNM v4"),
>> @@ -203,6 +165,5 @@ AVInputFormat ff_hnm_demuxer = {
>>  .read_probe = hnm_probe,
>>  .read_header= hnm_read_header,
>>  .read_packet= hnm_read_packet,
>> -.read_close = hnm_read_close,
>>  .flags  = AVFMT_NO_BYTE_SEEK | AVFMT_NOGENSEARCH |
>> AVFMT_NOBINSEARCH
>>  };
>> --
>> 2.20.1

Thanks, applied.

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

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

Re: [FFmpeg-devel] [PATCH v6 0/2] Pro Pinball Series Soundbank demuxer + decoder.

2020-04-03 Thread Zane van Iperen
On Sun, 29 Mar 2020 17:18:08 +
"Zane van Iperen"  wrote:

> Adds support for the soundbank files used by the Pro Pinball series
> of games.
> 
> Please CC for review.
> 
> v6:
>   - fix tools/probetest failure
> 
> v5:
>   - add probe function
>   - add flag #define's
> 
> v4:
>   - fix adpcm index table type
> 
> v3:
>   - fix potential memory leak if read_header() fails
>   - fix a buffer overread
>   - attempt seek before updating state
>   - remove unneeded check
>   - naming fixes
> 
> v2:
>   - Add sanity checks in header fields
>   - Formatting and comment fixes
>   - Change the struct names to match the files
> 
> Zane van Iperen (2):
>   avcodec: add support for Cunning Developments' ADPCM
>   avformat: add demuxer for Pro Pinball Series' Soundbanks
> 
>  Changelog|   2 +
>  doc/general.texi |   1 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/adpcm.c   |  33 +
>  libavcodec/adpcm_data.c  |  13 ++
>  libavcodec/adpcm_data.h  |   2 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/avcodec.h |   1 +
>  libavcodec/codec_desc.c  |   7 ++
>  libavcodec/version.h |   4 +-
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/pp_bnk.c | 263
> +++ libavformat/version.h|
> 2 +- 14 files changed, 329 insertions(+), 3 deletions(-)
>  create mode 100644 libavformat/pp_bnk.c
> 
> --
> 2.17.1
> 

Hi all,

Could I please have some reviews on this?

If everything's good I have FATE tests and samples ready, which I will
send upon merge.

I have a few minor changes but they're just slight comment changes,
which aren't worth sending as a v7. I can send them as a separate patch
afterwards.

Zane

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

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

[FFmpeg-devel] [PATCH 1/1] libavformat/rtsp: Pass protocol options for udp multicast

2020-04-03 Thread Wolfgang Haupt
Protocol options like buffer_size need to be passed to the
underlying transport implementation for udp multicasts as well.
---
 libavformat/rtsp.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index a69484d78b..dbf626eb13 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1616,6 +1616,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const 
char *host, int port,
 char url[1024], namebuf[50], optbuf[20] = "";
 struct sockaddr_storage addr;
 int port, ttl;
+AVDictionary *opts = map_to_opts(rt);
 
 if (reply->transports[0].destination.ss_family) {
 addr  = reply->transports[0].destination;
@@ -1633,10 +1634,12 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, 
const char *host, int port,
 ff_url_join(url, sizeof(url), "rtp", NULL, namebuf,
 port, "%s", optbuf);
 if (ffurl_open_whitelist(_st->rtp_handle, url, 
AVIO_FLAG_READ_WRITE,
-   >interrupt_callback, NULL, 
s->protocol_whitelist, s->protocol_blacklist, NULL) < 0) {
+   >interrupt_callback, , 
s->protocol_whitelist, s->protocol_blacklist, NULL) < 0) {
 err = AVERROR_INVALIDDATA;
+av_dict_free();
 goto fail;
 }
+av_dict_free();
 break;
 }
 }
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/rtsp: fix rtsp multicasts

2020-04-03 Thread Wolfgang Haupt

Hey,

is someone up to review this patch?

It's an attempt to fix rtsp streams that use udp multicasts as the 
underlying

transmission protocol.
The idea was taken from live555 as the said stream worked in VLC.

It still applies cleanly on current master.


Best Regards,
Wolfgang

On 18.10.19 18:59, Wolfgang Haupt wrote:

If an rtsp server offers a udp multicast
address as response of a DESCRIBE command
the rtsp client is expected to issue
SETUP with "Transport: RTP/AVP/UDP;multicast".
Some rtsp servers bail out otherwise.
---
  libavformat/rtsp.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 859defa592..3f0cbfc98b 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1913,6 +1913,9 @@ redirect:
  && (rt->rtsp_flags & RTSP_FLAG_PREFER_TCP))
  lower_transport = RTSP_LOWER_TRANSPORT_TCP;
  
+if (ff_is_multicast_address((struct sockaddr*)>rtsp_streams[rt->nb_rtsp_streams-1]->sdp_ip))

+lower_transport = RTSP_LOWER_TRANSPORT_UDP_MULTICAST;
+
  err = ff_rtsp_make_setup_request(s, host, port, lower_transport,
   rt->server_type == RTSP_SERVER_REAL ?
   real_challenge : NULL);



___
ffmpeg-devel mailing list
ffmpeg-devel@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 03/14] pthread_frame: merge the functionality for normal decoder init and init_thread_copy

2020-04-03 Thread Anton Khirnov
Quoting David Bryant (2020-04-03 07:14:21)
> On 4/2/20 2:13 AM, Anton Khirnov wrote:
> > Quoting David Bryant (2020-04-01 23:35:13)
> >> On 3/31/20 2:47 AM, Anton Khirnov wrote:
> > Looking at wavpack, the code looks suspicious to me. You allocate one
> > dsdctx per channel at init, but AFAIU the number of channels can change
> > at each frame.
> >
>  Multichannel WavPack consists of sequences of stereo or mono WavPack 
>  blocks that include flags indicating whether they are the
>  beginning or end of a "frame" or "packet". This allows the number of 
>  channels available to be essentially unlimited, however the
>  total number of channels in a stream may not change. When decoding, if a 
>  sequence of blocks generates more or less than the
>  correct number of channels, this is flagged as an error and overrun is 
>  prevented (see libavcodec/wavpack.c, line 1499 and line
>  1621).
> >>> If my reading of the code is correct, line 1499 only checks for overflow
> >>> of the channel count read for the current sequence. That channel count
> >>> is exported to AVCodeContext in the block starting on line 1464 and
> >>> I don't see any checks for whether it is equal to the initial one.
> >>>
> >> Full disclosure: I did not write the WavPack decoder. I understand _how_ 
> >> it works, but I don't necessarily understand _why_ it
> >> was written the way it was due to gaps in my knowledge of the FFmpeg 
> >> internals, and there are certainly things in there that
> >> don't look quite right to me.
> >>
> >> That said, I have tested it thoroughly and it handles everything I throw 
> >> at it, and I have extended it to handle the DSD mode
> >> without anything unexpected happening. And of course it seems to handle 
> >> extensive fuzzing, and the recent error was related to
> >> my DSD change, suggesting that the core it pretty robust. My inclination 
> >> has been to not "fix" anything that wasn't broken.
> >>
> >> Yes, that channel count stuff is a little difficult to follow. I could 
> >> experiment with streams that abruptly change channel
> >> configuration, but again I'm hesitant to change code that's worked so well 
> >> so long.
> > I can easily get the decoder to crash even in single-threaded mode. Just
> > make the demuxer always say the stream is mono, then try decoding your
> > DSD sample.
> 
> Okay, I reproduced that. However, I'm not sure it's really that serious 
> because the demuxer and the decoder use basically the
> same logic to determine that number of channels, so it would be tricky to 
> craft a file that caused the demuxer to calculate 1
> channel and the decoder to reach a different result, which is probably why 
> the fuzzers have not been able to do so.

I disagree - this is just as serious as any other crash on invalid data.

The decoder must not ever crash for arbitrary input data. It cannot
assume that it's always going to be provided valid input or that it's
always used with some specific demuxer. The caller might not be using
libavformat at all, libavcodec should work with any source of data.

Besides, I can reproduce the crash with no code modification necessary
by muxing your sample into Matroska and then hex-editing the file to say
it has only one channel.

> 
> That said, it would not be hard to have the decoder save away the initial 
> channel count from avctx, never overwrite it, and
> verify that all superblocks match that count. I don't know off hand whether 
> that would break anything though. Is it guaranteed
> that avctx->channels is correct during the call to decode_init(), even if 
> it's being demuxed from Matroska, for example? If so,
> why is the WavPack decoder _ever_ writing to the avctx channel count?

The question is what you define as correct. The initial value provided
by the caller is supposed to be the caller's best guess at the correct
(initial) value. It may come from a demuxer, or from the Delphic Oracle.
The decoder doesn't know.

For some codecs, the relevant parameters are not specified in the
bistream, so they have no choice but to use the caller's value. That is
not the case for WavPack, since the channel count IS written in the
bistream. So I think it's best to ignore the caller-provided value and
always use the one we get from the data.

> 
> >
> > Also, I looked at the specification PDF you linked in the previous email
> > and I see nothing in it that explicitly forbids the channel count from
> > changing from one "superblock" to the next. It seems to me like you
> > could just concatenate wavpack files with different channel counts and
> > get a valid wavpack file.
> >
> You're right, I could not find that being explicitly forbidden. Nevertheless, 
> it _is_ forbidden for any stream parameters to
> change (e.g. data format, sampling rate, channel count or mapping) and both 
> libwavpack and the FFmpeg demuxer enforce this (see
> libavformat/wvdec.c starting at line 211), or at least gracefully fail