[FFmpeg-devel] [PATCH 2/2] swscale/tests/swscale: use codes < 128 for indicating erros

2020-07-16 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 845ced61bb..9c0b5a4b11 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -248,7 +248,7 @@ end:
 if (dstStride[i])
 av_free(dst[i]);
 
-return res;
+return res & 127;
 }
 
 static void selfTest(const uint8_t * const ref[4], int refStride[4],
-- 
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 1/2] avcodec/tdsc: Fix tile checks

2020-07-16 Thread Michael Niedermayer
Fixes: out of array access
Fixes: crash.asf

Found-by: anton listov 
Reviewed-by: anton listov 
Signed-off-by: Michael Niedermayer 
---
 libavcodec/tdsc.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index eaea41c1f5..3617911071 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -390,7 +390,7 @@ static int tdsc_decode_tiles(AVCodecContext *avctx, int 
number_tiles)
 for (i = 0; i < number_tiles; i++) {
 int tile_size;
 int tile_mode;
-int x, y, w, h;
+int x, y, x2, y2, w, h;
 int ret;
 
 if (bytestream2_get_bytes_left(&ctx->gbc) < 4 ||
@@ -408,20 +408,19 @@ static int tdsc_decode_tiles(AVCodecContext *avctx, int 
number_tiles)
 bytestream2_skip(&ctx->gbc, 4); // unknown
 x = bytestream2_get_le32(&ctx->gbc);
 y = bytestream2_get_le32(&ctx->gbc);
-w = bytestream2_get_le32(&ctx->gbc) - x;
-h = bytestream2_get_le32(&ctx->gbc) - y;
+x2 = bytestream2_get_le32(&ctx->gbc);
+y2 = bytestream2_get_le32(&ctx->gbc);
 
-if (x >= ctx->width || y >= ctx->height) {
+if (x < 0 || y < 0 || x2 <= x || y2 <= y ||
+x2 > ctx->width || y2 > ctx->height
+) {
 av_log(avctx, AV_LOG_ERROR,
-   "Invalid tile position (%d.%d outside %dx%d).\n",
-   x, y, ctx->width, ctx->height);
-return AVERROR_INVALIDDATA;
-}
-if (x + w > ctx->width || y + h > ctx->height) {
-av_log(avctx, AV_LOG_ERROR,
-   "Invalid tile size %dx%d\n", w, h);
+   "Invalid tile position (%d.%d %d.%d outside %dx%d).\n",
+   x, y, x2, y2, ctx->width, ctx->height);
 return AVERROR_INVALIDDATA;
 }
+w = x2 - x;
+h = y2 - y;
 
 ret = av_reallocp(&ctx->tilebuffer, tile_size);
 if (!ctx->tilebuffer)
-- 
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 2/2] swscale/tests/swscale: use codes < 128 for indicating erros

2020-07-16 Thread Martin Storsjö

On Thu, 16 Jul 2020, Michael Niedermayer wrote:


Signed-off-by: Michael Niedermayer 
---
libswscale/tests/swscale.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 845ced61bb..9c0b5a4b11 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -248,7 +248,7 @@ end:
if (dstStride[i])
av_free(dst[i]);

-return res;
+return res & 127;
}


Is there a valuable distinction between the different return values in 
this test tool so far? Because this code will e.g. fail to return a proper 
error return code if res happens to be -128.


Otherwise this could be made into e.g. "return !!res;" or something like 
that.


// Martin

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

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

Re: [FFmpeg-devel] [PATCH v5 1/6] ffbuild: Refine MIPS handling

2020-07-16 Thread Shiyou Yin
Attachment patch include all changes corresponding to my following comments, 
for your reference.

>-Original Message-
>From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
>On Behalf Of
>Jiaxun Yang
>Sent: Thursday, July 2, 2020 11:46 PM
>To: ffmpeg-devel@ffmpeg.org
>Cc: Jiaxun Yang
>Subject: [FFmpeg-devel] [PATCH v5 1/6] ffbuild: Refine MIPS handling
>
>To enable runtime detection for MIPS, we need to refine ffbuild
>part to support buildding these feature together.
>
>Firstly, we fixed configure, let it probe native ability of toolchain
>to decide wether a feature can to be enabled, also clearly marked
>the conflictions between loongson2 & loongson3 and Release 6 & rest.
>
>Secondly, we compile MMI and MSA C sources with their own flags to ensure
>their flags won't pollute the whole program and generate illegal code.
>
>Signed-off-by: Jiaxun Yang 
>
>--
>v5: Minor fixes
>---
> configure| 180 +++
> ffbuild/common.mak   |  10 ++-
> libavcodec/mips/Makefile |   3 +-
> 3 files changed, 118 insertions(+), 75 deletions(-)
>
>diff --git a/configure b/configure
>index 7495f35faa..385a9e5f5f 100755
>--- a/configure
>+++ b/configure
>@@ -2551,7 +2551,7 @@ mips64r6_deps="mips"
> mipsfpu_deps="mips"
> mipsdsp_deps="mips"
> mipsdspr2_deps="mips"
>-mmi_deps="mips"
>+mmi_deps_any="loongson2 loongson3"
> msa_deps="mipsfpu"
> msa2_deps="msa"
>
>@@ -5002,8 +5002,6 @@ elif enabled bfin; then
>
> elif enabled mips; then
>
>-cpuflags="-march=$cpu"
>-
> if [ "$cpu" != "generic" ]; then
> disable mips32r2
> disable mips32r5
>@@ -5012,19 +5010,61 @@ elif enabled mips; then
> disable mips64r6
> disable loongson2
> disable loongson3
>+disable mipsdsp
>+disable mipsdspr2
>+disable msa
>+disable mmi
>+
>+cpuflags="-march=$cpu"
>
> case $cpu in
>-24kc|24kf*|24kec|34kc|1004kc|24kef*|34kf*|1004kf*|74kc|74kf)
>+# General ISA levels
>+mips1|mips3)
>+;;
>+mips32r2)
>+enable msa
> enable mips32r2
>-disable msa
> ;;
>-p5600|i6400|p6600)
>-disable mipsdsp
>-disable mipsdspr2
>+mips32r5)
>+enable msa
>+enable mips32r2
>+enable mips32r5
> ;;
>-loongson*)
>-enable loongson2
>+mips64r2|mips64r5)
>+enable msa
>+enable mmi
>+enable mips64r2
> enable loongson3
>+;;
>+# Cores from MIPS(MTI)
>+24kc)
>+disable mipsfpu
>+enable mips32r2
>+;;
>+24kf*|24kec|34kc|74Kc|1004kc)
>+enable mips32r2
>+;;
>+24kef*|34kf*|1004kf*)
>+enable mipsdsp
>+enable mips32r2
>+;;
>+p5600)
>+enable msa
>+enable mips32r2
>+enable mips32r5
>+check_cflags "-mtune=p5600" && check_cflags "-msched-weight 
>-mload-store-pairs-funroll-loops"
>+;;
>+i6400)
>+enable mips64r6
>+check_cflags "-mtune=i6400 -mabi=64" && check_cflags 
>"-msched-weight-mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
>+;;
>+p6600)
>+enable mips64r6
>+check_cflags "-mtune=p6600 -mabi=64" && check_cflags 
>"-msched-weight-mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
>+;;
>+# Cores from Loongson
>+loongson2e|loongson2f|loongson3*)
>+enable mmi
> enable local_aligned
> enable simd_align_16
> enable fast_64bit
>@@ -5032,75 +5072,44 @@ elif enabled mips; then
> enable fast_cmov
> enable fast_unaligned
> disable aligned_stack
>-disable mipsdsp
>-disable mipsdspr2
> # When gcc version less than 5.3.0, add 
> -fno-expensive-optimizations flag.
>-if [ $cc == gcc ]; then
>-gcc_version=$(gcc -dumpversion)
>-if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort 
>-rV | head -n 1)" =="$gcc_version" ]; then
>-expensive_optimization_flag=""
>-else
>+if test "$cc_type" = "gcc"; then
>+case $gcc_basever in
>+2|2.*|3.*|4.*|5.0|5.1|5.2)
> 
> expensive_optimization_flag="-fno-expensive-optimizations"
>-fi
>+;;
>+*)
>+expensive_optimization_flag=""
>+ 

Re: [FFmpeg-devel] [PATCH v2 2/4] libavcodec/jpeg2000 Fix PCRL Progression Order check

2020-07-16 Thread Michael Niedermayer
On Tue, Jul 14, 2020 at 10:13:14PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> The PCRL progression checks were incomplete. This patch
> modifes completes the check. Tested on p1_05.j2k.
> ---
>  libavcodec/jpeg2000dec.c | 23 +++
>  1 file changed, 15 insertions(+), 8 deletions(-)

will apply

thx

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

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



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

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

Re: [FFmpeg-devel] [PATCH 2/2] swscale/tests/swscale: use codes < 128 for indicating erros

2020-07-16 Thread Nicolas George
Michael Niedermayer (12020-07-16):
> Signed-off-by: Michael Niedermayer 
> ---
>  libswscale/tests/swscale.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
> index 845ced61bb..9c0b5a4b11 100644
> --- a/libswscale/tests/swscale.c
> +++ b/libswscale/tests/swscale.c
> @@ -248,7 +248,7 @@ end:
>  if (dstStride[i])
>  av_free(dst[i]);
>  
> -return res;
> +return res & 127;
>  }
>  
>  static void selfTest(const uint8_t * const ref[4], int refStride[4],

This looks fragile: there is no local guarantee that res is not a
multiple of 128, and changes in other parts of the code could have that
effect.

Better change the ultimate return value of main to !!res IMHO.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 2/2] swscale/tests/swscale: use codes < 128 for indicating erros

2020-07-16 Thread Michael Niedermayer
On Thu, Jul 16, 2020 at 10:57:27AM +0300, Martin Storsjö wrote:
> On Thu, 16 Jul 2020, Michael Niedermayer wrote:
> 
> > Signed-off-by: Michael Niedermayer 
> > ---
> > libswscale/tests/swscale.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
> > index 845ced61bb..9c0b5a4b11 100644
> > --- a/libswscale/tests/swscale.c
> > +++ b/libswscale/tests/swscale.c
> > @@ -248,7 +248,7 @@ end:
> > if (dstStride[i])
> > av_free(dst[i]);
> > 
> > -return res;
> > +return res & 127;
> > }
> 
> Is there a valuable distinction between the different return values in this
> test tool so far? Because this code will e.g. fail to return a proper error
> return code if res happens to be -128.

currently no difference


> 
> Otherwise this could be made into e.g. "return !!res;" or something like
> that.

ok will push with that

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 1/3] nvenc: use runtime api version to support old drivers

2020-07-16 Thread Timo Rothenpieler

On 16.07.2020 04:16, Wang Bin wrote:



What happens if a struct
gets updated, and ffmpeg wants to use the new fields when available,
like happened plenty of times?


Upgrade nvEncodeAPI.h like we've already done. Part of reserved bits will
become a struct member and have a name. These bits will be recognized on
new drivers but ignored on old ones.


So if someone relies on one of the new fields, be it for quality 
settings or something, it will then silently be ignored?
This needs some kind of guard for every single field, with an 
appropriate error message if a feature newer than what's supported has 
been used.


I'm really not sure if this is all worth it. It will massively blow up 
the code and make it harder and harder to maintain with every version.

___
ffmpeg-devel mailing list
ffmpeg-devel@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/hls: add supporting fMP4(CMAF) format to seek on HLS demuxer

2020-07-16 Thread Dongwon Kim

HLS spec RFC 8216(https://tools.ietf.org/html/rfc8216) version 7 added 
supporting fMP4(CMAF) format for segment. However, when requesting seek 
operation,
the hls demuxer doesn't work properly due to previous implementation of the HLS 
demuxer was only for supporting MPEG-TS format for segment.

So, I added procedure to reopen segment format on HLS demuxer when seeking 
requested. It's quite similar to MPEG-DASH demuxer(libavformat/dashdec.c) 
seeking procedure, as you know, MPEG-DASH also support fMP4(CMAF) format for 
fragment as default. Refer to 
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/dashdec.c#L1904.


Please test with below command:

Server:
$ ffmpeg -y -i {input} -vcodec libx264 \
-force_key_frames 30 \
-sc_threshold 0 \
-acodec aac \
-hls_segment_type fmp4 \
-hls_time 6 \
-hls_playlist_type vod \
-map 0:a -map 0:v -f hls \
-var_stream_map "a:0,agroup:aud,default:yes v:0,agroup:aud" \
-hls_segment_filename "segment_%v_%03d.m4s" \
-master_pl_name playlist.m3u8 \
hlscmaf_%v.m3u8


Player:
$ ffplay playlist.m3u8



On 20. 7. 15. 오후 4:20, Dongwon Kim wrote:
> Signed-off-by: Dongwon Kim 
> ---
>   libavformat/hls.c | 67 +++
>   1 file changed, 67 insertions(+)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index ba17c4ed96..561b42ea6b 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -2139,6 +2139,68 @@ static int compare_ts_with_wrapdetect(int64_t ts_a, 
> struct playlist *pls_a,
>   return av_compare_mod(scaled_ts_a, scaled_ts_b, 1LL << 33);
>   }
>   +static int reopen_demux_for_component(AVFormatContext *s, struct playlist 
> *pls)
> +{
> +ff_const59 AVInputFormat *in_fmt = NULL;
> +AVDictionary  *in_fmt_opts = NULL;
> +uint8_t *avio_ctx_buffer  = NULL;
> +int ret = 0;
> +
> +if (pls->ctx) {
> +av_freep(&pls->pb.buffer);
> +memset(&pls->pb, 0x00, sizeof(AVIOContext));
> +pls->ctx->pb = NULL;
> +avformat_close_input(&pls->ctx);
> +pls->ctx = NULL;
> +}
> +
> +if (ff_check_interrupt(&s->interrupt_callback)) {
> +ret = AVERROR_EXIT;
> +goto fail;
> +}
> +
> +if (!(pls->ctx = avformat_alloc_context())) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +
> +avio_ctx_buffer  = av_malloc(INITIAL_BUFFER_SIZE);
> +if (!avio_ctx_buffer ) {
> +ret = AVERROR(ENOMEM);
> +avformat_free_context(pls->ctx);
> +pls->ctx = NULL;
> +goto fail;
> +}
> +ffio_init_context(&pls->pb, avio_ctx_buffer , INITIAL_BUFFER_SIZE, 0, 
> pls, read_data, NULL, NULL);
> +pls->pb.seekable = 0;
> +
> +if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0)
> +goto fail;
> +
> +pls->ctx->flags = AVFMT_FLAG_CUSTOM_IO;
> +ret = av_probe_input_buffer(&pls->pb, &in_fmt, "", NULL, 0, 0);
> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Error when loading segment, playlist %d\n", 
> pls->cur_seq_no);
> +avformat_free_context(pls->ctx);
> +pls->ctx = NULL;
> +goto fail;
> +}
> +
> +pls->ctx->pb = &pls->pb;
> +pls->ctx->io_open  = nested_io_open;
> +
> +ret = avformat_open_input(&pls->ctx, "", in_fmt, &in_fmt_opts);
> +av_dict_free(&in_fmt_opts);
> +if (ret < 0)
> +goto fail;
> +ret = avformat_find_stream_info(pls->ctx, NULL);
> +if (ret < 0)
> +goto fail;
> +
> +fail:
> +return ret;
> +}
> +
>   static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
>   {
>   HLSContext *c = s->priv_data;
> @@ -2351,6 +2413,11 @@ static int hls_read_seek(AVFormatContext *s, int 
> stream_index,
>   pls->seek_stream_index = -1;
>   pls->seek_flags |= AVSEEK_FLAG_ANY;
>   }
> +
> +if (pls->ctx && pls->ctx->iformat && strcmp(pls->ctx->iformat->name, 
> "mov,mp4,m4a,3gp,3g2,mj2") == 0) {
> +pls->init_sec_buf_read_offset = 0;
> +reopen_demux_for_component(s, pls);
> +}
>   }
> c->cur_timestamp = seek_timestamp;

___
ffmpeg-devel mailing list
ffmpeg-devel@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 v5 4/6] libavcodec: Enable runtime detection for MIPS MMI & MSA

2020-07-16 Thread Shiyou Yin
>-Original Message-
>From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
>On Behalf Of
>Jiaxun Yang
>Sent: Thursday, July 2, 2020 11:46 PM
>To: ffmpeg-devel@ffmpeg.org
>Cc: Jiaxun Yang
>Subject: [FFmpeg-devel] [PATCH v5 4/6] libavcodec: Enable runtime detection 
>for MIPS MMI & MSA
>
>Apply optimized functions according to cpuflags.
>MSA is usually put after MMI as it's generally faster than MMI.
>
>Signed-off-by: Jiaxun Yang 
>--

>diff --git a/libavcodec/mips/wmv2dsp_mips.h b/libavcodec/mips/wmv2dsp_mips.h
>index 22894c505d..f7313460fb 100644
>--- a/libavcodec/mips/wmv2dsp_mips.h
>+++ b/libavcodec/mips/wmv2dsp_mips.h
>@@ -23,7 +23,7 @@
>
> #include "libavcodec/wmv2dsp.h"
>
>-void ff_wmv2_idct_add_mmi(uint8_t *dest, int line_size, int16_t *block);
>-void ff_wmv2_idct_put_mmi(uint8_t *dest, int line_size, int16_t *block);
>+void ff_wmv2_idct_add_mmi(uint8_t *dest, long int line_size, int16_t *block);
>+void ff_wmv2_idct_put_mmi(uint8_t *dest, long int line_size, int16_t *block);
>

Type of line_size should be ptrdiff_t.

> #endif /* AVCODEC_MIPS_WMV2DSP_MIPS_H */
>diff --git a/libavcodec/mips/wmv2dsp_mmi.c b/libavcodec/mips/wmv2dsp_mmi.c
>index 1f6ccb299b..8796ebe195 100644
>--- a/libavcodec/mips/wmv2dsp_mmi.c
>+++ b/libavcodec/mips/wmv2dsp_mmi.c
>@@ -95,7 +95,7 @@ static void wmv2_idct_col_mmi(short * b)
> b[56] = (a0 + a2 - a1 - a5 + 8192) >> 14;
> }
>
>-void ff_wmv2_idct_add_mmi(uint8_t *dest, int line_size, int16_t *block)
>+void ff_wmv2_idct_add_mmi(uint8_t *dest, long int line_size, int16_t *block)
> {
> int i;
> double ftmp[11];
>@@ -212,7 +212,7 @@ void ff_wmv2_idct_add_mmi(uint8_t *dest, int line_size, 
>int16_t *block)
> );
> }
>
>-void ff_wmv2_idct_put_mmi(uint8_t *dest, int line_size, int16_t *block)
>+void ff_wmv2_idct_put_mmi(uint8_t *dest, long int line_size, int16_t *block)

Type of line_size in this two functions should be ptrdiff_t.

> {
> int i;
> double ftmp[8];


___
ffmpeg-devel mailing list
ffmpeg-devel@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] Ticket 5012

2020-07-16 Thread Gautam Ramakrishnan
Hi All,

I was going through the bug tracker for a list of bugs associated with
jpeg2000. Looking at issue 5012, is there a good utility for solving
this issue? To whomever it may concern, please do let me know your
opinion on this.

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

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

Re: [FFmpeg-devel] [PATCH v5 5/6] libavcodec: MIPS: MMI: Fix type mismatches

2020-07-16 Thread Shiyou Yin
>-Original Message-
>From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
>On Behalf Of
>Jiaxun Yang
>Sent: Thursday, July 2, 2020 11:46 PM
>To: ffmpeg-devel@ffmpeg.org
>Cc: Jiaxun Yang
>Subject: [FFmpeg-devel] [PATCH v5 5/6] libavcodec: MIPS: MMI: Fix type 
>mismatches
>
>GCC complains about them.
>
>Signed-off-by: Jiaxun Yang 
>---
> libavcodec/mips/h264dsp_mips.h  | 18 +-
> libavcodec/mips/h264dsp_mmi.c   | 18 +-
> libavcodec/mips/xvid_idct_mmi.c |  4 ++--
> libavcodec/mips/xvididct_mips.h |  4 ++--
> 4 files changed, 22 insertions(+), 22 deletions(-)
>
>diff --git a/libavcodec/mips/h264dsp_mips.h b/libavcodec/mips/h264dsp_mips.h
>index 21b7de06f0..7b2a9fabe5 100644
>--- a/libavcodec/mips/h264dsp_mips.h
>+++ b/libavcodec/mips/h264dsp_mips.h
>@@ -357,23 +357,23 @@ void ff_h264_biweight_pixels4_8_mmi(uint8_t *dst, 
>uint8_t *src,
>
> void ff_deblock_v_chroma_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha, int 
> beta,
> int8_t *tc0);
>-void ff_deblock_v_chroma_intra_8_mmi(uint8_t *pix, int stride, int alpha,
>+void ff_deblock_v_chroma_intra_8_mmi(uint8_t *pix, ptrdiff_t stride, int 
>alpha,
> int beta);
>-void ff_deblock_h_chroma_8_mmi(uint8_t *pix, int stride, int alpha, int beta,
>+void ff_deblock_h_chroma_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha, int 
>beta,
> int8_t *tc0);
>-void ff_deblock_h_chroma_intra_8_mmi(uint8_t *pix, int stride, int alpha,
>+void ff_deblock_h_chroma_intra_8_mmi(uint8_t *pix, ptrdiff_t stride, int 
>alpha,
> int beta);
>-void ff_deblock_v_luma_8_mmi(uint8_t *pix, int stride, int alpha, int beta,
>+void ff_deblock_v_luma_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha, int 
>beta,
> int8_t *tc0);
>-void ff_deblock_v_luma_intra_8_mmi(uint8_t *pix, int stride, int alpha,
>+void ff_deblock_v_luma_intra_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha,
> int beta);
>-void ff_deblock_h_luma_8_mmi(uint8_t *pix, int stride, int alpha, int beta,
>+void ff_deblock_h_luma_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha, int 
>beta,
> int8_t *tc0);
>-void ff_deblock_h_luma_intra_8_mmi(uint8_t *pix, int stride, int alpha,
>+void ff_deblock_h_luma_intra_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha,
> int beta);
>-void ff_deblock_v8_luma_8_mmi(uint8_t *pix, int stride, int alpha, int beta,
>+void ff_deblock_v8_luma_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha, int 
>beta,
> int8_t *tc0);
>-void ff_deblock_v8_luma_intra_8_mmi(uint8_t *pix, int stride, int alpha,
>+void ff_deblock_v8_luma_intra_8_mmi(uint8_t *pix, ptrdiff_t stride, int alpha,
> int beta);
>
> void ff_put_h264_qpel16_mc00_mmi(uint8_t *dst, const uint8_t *src,
>diff --git a/libavcodec/mips/h264dsp_mmi.c b/libavcodec/mips/h264dsp_mmi.c
>index 0459711b82..7a60ee7c2b 100644
>--- a/libavcodec/mips/h264dsp_mmi.c
>+++ b/libavcodec/mips/h264dsp_mmi.c
>@@ -1433,7 +1433,7 @@ void ff_h264_biweight_pixels4_8_mmi(uint8_t *dst, 
>uint8_t *src,
> }
> }
>
>-void ff_deblock_v8_luma_8_mmi(uint8_t *pix, int stride, int alpha, int beta,
>+void ff_deblock_v8_luma_8_mmi(uint8_t *pix, pixdiff_t stride, int alpha, int 
>beta,


Typo. should be ptrdiff_t.



___
ffmpeg-devel mailing list
ffmpeg-devel@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/hls: add supporting fMP4(CMAF) format to seek on HLS demuxer

2020-07-16 Thread vectronic


> On 16 Jul 2020, at 10:36, Dongwon Kim  wrote:
> 
> 
> HLS spec RFC 8216(https://tools.ietf.org/html/rfc8216) version 7 added 
> supporting fMP4(CMAF) format for segment. However, when requesting seek 
> operation,
> the hls demuxer doesn't work properly due to previous implementation of the 
> HLS demuxer was only for supporting MPEG-TS format for segment.
> 
> So, I added procedure to reopen segment format on HLS demuxer when seeking 
> requested. It's quite similar to MPEG-DASH demuxer(libavformat/dashdec.c) 
> seeking procedure, as you know, MPEG-DASH also support fMP4(CMAF) format for 
> fragment as default. Refer to 
> https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/dashdec.c#L1904.
> 
> 
> Please test with below command:
> 
> Server:
> $ ffmpeg -y -i {input} -vcodec libx264 \
>-force_key_frames 30 \
>-sc_threshold 0 \
>-acodec aac \
>-hls_segment_type fmp4 \
>-hls_time 6 \
>-hls_playlist_type vod \
>-map 0:a -map 0:v -f hls \
>-var_stream_map "a:0,agroup:aud,default:yes v:0,agroup:aud" \
>-hls_segment_filename "segment_%v_%03d.m4s" \
>-master_pl_name playlist.m3u8 \
>hlscmaf_%v.m3u8
> 
> 
> Player:
> $ ffplay playlist.m3u8
> 
> 
> 
> On 20. 7. 15. 오후 4:20, Dongwon Kim wrote:
>> Signed-off-by: Dongwon Kim 
>> ---
>>  libavformat/hls.c | 67 +++
>>  1 file changed, 67 insertions(+)
>> 
>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>> index ba17c4ed96..561b42ea6b 100644
>> --- a/libavformat/hls.c
>> +++ b/libavformat/hls.c
>> @@ -2139,6 +2139,68 @@ static int compare_ts_with_wrapdetect(int64_t ts_a, 
>> struct playlist *pls_a,
>>  return av_compare_mod(scaled_ts_a, scaled_ts_b, 1LL << 33);
>>  }
>>  +static int reopen_demux_for_component(AVFormatContext *s, struct playlist 
>> *pls)
>> +{
>> +ff_const59 AVInputFormat *in_fmt = NULL;
>> +AVDictionary  *in_fmt_opts = NULL;
>> +uint8_t *avio_ctx_buffer  = NULL;
>> +int ret = 0;
>> +
>> +if (pls->ctx) {
>> +av_freep(&pls->pb.buffer);
>> +memset(&pls->pb, 0x00, sizeof(AVIOContext));
>> +pls->ctx->pb = NULL;
>> +avformat_close_input(&pls->ctx);
>> +pls->ctx = NULL;
>> +}
>> +
>> +if (ff_check_interrupt(&s->interrupt_callback)) {
>> +ret = AVERROR_EXIT;
>> +goto fail;
>> +}
>> +
>> +if (!(pls->ctx = avformat_alloc_context())) {
>> +ret = AVERROR(ENOMEM);
>> +goto fail;
>> +}
>> +
>> +avio_ctx_buffer  = av_malloc(INITIAL_BUFFER_SIZE);
>> +if (!avio_ctx_buffer ) {
>> +ret = AVERROR(ENOMEM);
>> +avformat_free_context(pls->ctx);
>> +pls->ctx = NULL;
>> +goto fail;
>> +}
>> +ffio_init_context(&pls->pb, avio_ctx_buffer , INITIAL_BUFFER_SIZE, 0, 
>> pls, read_data, NULL, NULL);
>> +pls->pb.seekable = 0;
>> +
>> +if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0)
>> +goto fail;
>> +
>> +pls->ctx->flags = AVFMT_FLAG_CUSTOM_IO;
>> +ret = av_probe_input_buffer(&pls->pb, &in_fmt, "", NULL, 0, 0);
>> +if (ret < 0) {
>> +av_log(s, AV_LOG_ERROR, "Error when loading segment, playlist 
>> %d\n", pls->cur_seq_no);
>> +avformat_free_context(pls->ctx);
>> +pls->ctx = NULL;
>> +goto fail;
>> +}
>> +
>> +pls->ctx->pb = &pls->pb;
>> +pls->ctx->io_open  = nested_io_open;
>> +
>> +ret = avformat_open_input(&pls->ctx, "", in_fmt, &in_fmt_opts);
>> +av_dict_free(&in_fmt_opts);
>> +if (ret < 0)
>> +goto fail;
>> +ret = avformat_find_stream_info(pls->ctx, NULL);
>> +if (ret < 0)
>> +goto fail;
>> +
>> +fail:
>> +return ret;
>> +}
>> +
>>  static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
>>  {
>>  HLSContext *c = s->priv_data;
>> @@ -2351,6 +2413,11 @@ static int hls_read_seek(AVFormatContext *s, int 
>> stream_index,
>>  pls->seek_stream_index = -1;
>>  pls->seek_flags |= AVSEEK_FLAG_ANY;
>>  }
>> +
>> +if (pls->ctx && pls->ctx->iformat && 
>> strcmp(pls->ctx->iformat->name, "mov,mp4,m4a,3gp,3g2,mj2") == 0) {
>> +pls->init_sec_buf_read_offset = 0;
>> +reopen_demux_for_component(s, pls);
>> +}
>>  }
>>c->cur_timestamp = seek_timestamp;
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe”.

I have previously submitted another means of achieving this here:

https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1018 


My approach was to mirror in mp4 demux the same support that mpeg2ts has for 
detecting a position reset on the stream. And to improve the seek semantics in 
HLS demux.

Some older history here:

https://trac.ffmpeg.org/tick

[FFmpeg-devel] [RFC][GSoC][PATCH v2 1/6] avformat/abr: Adaptive Bitrate support

2020-07-16 Thread Hongcheng Zhong
From: spartazhc 

Add abr module for hls/dash.

v1 fixed:
1. add an "ff" prefix to the protocol name to mark it internal.
2. use 1.2f for float constant 1.2.
3. simplify abr_seek for we just need AVSEEK_SIZE only.

v2 fixed:
1. fix error return
2. simplify abr_seek

Signed-off-by: spartazhc 
---
 doc/protocols.texi  |   7 ++
 libavformat/Makefile|   1 +
 libavformat/abr.c   | 249 
 libavformat/protocols.c |   1 +
 4 files changed, 258 insertions(+)
 create mode 100644 libavformat/abr.c

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 64ad3f05d6..ffbb36147e 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -51,6 +51,13 @@ in microseconds.
 
 A description of the currently available protocols follows.
 
+@section abr
+
+Adaptive bitrate sub-protocol work for hls/dash.
+
+The abr protocol takes stream information from hls/dash as input,
+use bandwidth estimation to decide whether to switch or not.
+
 @section amqp
 
 Advanced Message Queueing Protocol (AMQP) version 0-9-1 is a broker based
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 26af859a28..7d74e45d2a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -595,6 +595,7 @@ OBJS-$(CONFIG_CACHE_PROTOCOL)+= cache.o
 OBJS-$(CONFIG_CONCAT_PROTOCOL)   += concat.o
 OBJS-$(CONFIG_CRYPTO_PROTOCOL)   += crypto.o
 OBJS-$(CONFIG_DATA_PROTOCOL) += data_uri.o
+OBJS-$(CONFIG_FFABR_PROTOCOL)+= abr.o
 OBJS-$(CONFIG_FFRTMPCRYPT_PROTOCOL)  += rtmpcrypt.o rtmpdigest.o rtmpdh.o
 OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
 OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
diff --git a/libavformat/abr.c b/libavformat/abr.c
new file mode 100644
index 00..7699b9baef
--- /dev/null
+++ b/libavformat/abr.c
@@ -0,0 +1,249 @@
+/*
+ * Adaptive Bitrate Module for HLS / DASH
+ * Copyright (c) 2020 Hongcheng Zhong
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "libavutil/opt.h"
+#include "libavutil/time.h"
+#include "libavutil/avstring.h"
+#include "url.h"
+#include 
+
+enum ABRFormatType {
+ABR_TYPE_HLS,
+ABR_TYPE_DASH
+};
+
+typedef struct variant_bitrate {
+int value;
+int index;
+} variant_bitrate;
+
+typedef struct ABRContext {
+AVClass *class;
+URLContext *hd;
+AVDictionary *abr_params;
+AVDictionary *abr_metadata;
+enum ABRFormatType format;
+int cur_pls;
+int can_switch;
+int n_variants;
+variant_bitrate *variants_bitrate;
+int index;
+int n_throughputs;
+float *throughputs;
+} ABRContext;
+
+static float harmonic_mean(int num, float* arr)
+{
+float tmp = 0;
+
+if (num <= 0) return 0;
+
+for (size_t i = 0; i < num; i++) {
+tmp += 1 / arr[i];
+}
+
+return num / tmp;
+}
+
+static int hls_param_parse(ABRContext *c, const char *key, const char *value)
+{
+if (!av_strcasecmp(key, "cur_pls")) {
+c->cur_pls = atoi(value);
+} else if (!av_strcasecmp(key, "can_switch")) {
+c->can_switch = atoi(value);
+} else if (!av_strcasecmp(key, "n_variants")) {
+c->n_variants = atoi(value);
+c->variants_bitrate = av_mallocz(sizeof(variant_bitrate) * 
c->n_variants);
+if (!c->variants_bitrate)
+return AVERROR(ENOMEM);
+} else if (av_strstart(key, "variant_bitrate", NULL)) {
+c->variants_bitrate[c->index].value = atoi(value);
+c->variants_bitrate[c->index].index = c->index;
+c->index++;
+} else if (!av_strcasecmp(key, "n_throughputs")) {
+c->n_throughputs = atoi(value);
+c->index = 0;
+if (c->n_throughputs > 0) {
+c->throughputs = av_malloc(sizeof(float) * c->n_throughputs);
+if (!c->throughputs)
+return AVERROR(ENOMEM);
+}
+} else if (av_strstart(key, "throughputs", NULL))
+c->throughputs[c->index++] = atof(value);
+return 0;
+}
+
+static int dash_param_parse(ABRContext *c, const char *key, const char *value)
+{
+return 0;
+}
+
+static int abr_param_parse(ABRContext *c, enum ABRFormatType type, const char 
*key, const char *value)
+{
+if (type == ABR_TYPE_HLS) {
+hls_param_parse(c, key, va

[FFmpeg-devel] [RFC][GSoC][PATCH v2 3/6] avformat/hls: use abr to switch streams

2020-07-16 Thread Hongcheng Zhong
From: spartazhc 

When abr is enable, it will take over the task to call http to
download segments, and will return a switch-request for hls to
switch streams.
For reason not to waste segments that have been downloaded,
switch will become effective after old segments is used out.
Abr cannot work with http_persistent option, and currently use
http_multiple.

v1 fixed:
1. fix memory leak

v2 fixed:
1. check malloc result and return AVERROR(ENOMEM)
2. define ABR_THROUGHPUT_FIFO_LEN instead of hardcode

Signed-off-by: spartazhc 
---
 doc/demuxers.texi |   3 +
 libavformat/hls.c | 237 --
 2 files changed, 234 insertions(+), 6 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 3c15ab9eee..4cdbd95962 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -321,6 +321,9 @@ available in a metadata key named "variant_bitrate".
 It accepts the following options:
 
 @table @option
+@item abr
+enable abr to switch streams.
+
 @item live_start_index
 segment index to start live streams at (negative values are from the end).
 
diff --git a/libavformat/hls.c b/libavformat/hls.c
index ba17c4ed96..0b297303d8 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -47,6 +47,7 @@
 #define MPEG_TIME_BASE 9
 #define MPEG_TIME_BASE_Q (AVRational){1, MPEG_TIME_BASE}
 
+#define ABR_THROUGHPUT_FIFO_LEN 20
 /*
  * An apple http stream consists of a playlist with media segment files,
  * played sequentially. There may be several playlists with the same
@@ -189,6 +190,15 @@ struct variant {
 char subtitles_group[MAX_FIELD_LEN];
 };
 
+struct throughput {
+int n_throughputs;
+
+/* throughputs are in kbps */
+float throughput_fifo[ABR_THROUGHPUT_FIFO_LEN];
+int head;
+int tail;
+};
+
 typedef struct HLSContext {
 AVClass *class;
 AVFormatContext *ctx;
@@ -213,8 +223,36 @@ typedef struct HLSContext {
 int http_multiple;
 int http_seekable;
 AVIOContext *playlist_pb;
+
+int abr;
+struct throughput *throughputs;
+int can_switch;
+int switch_request2;
+int switch_delay;
+int64_t switch_timestamp;
+int64_t delta_timestamp;
+int cur_pls;
 } HLSContext;
 
+static struct segment *next_segment(struct playlist *pls);
+static int open_input(HLSContext *c, struct playlist *pls, struct segment 
*seg, AVIOContext **in);
+
+static void sync_cur_seq(HLSContext *c) {
+int i;
+for (i = 0; i < c->n_playlists; i++) {
+struct playlist *pls = c->playlists[i];
+pls->cur_seq_no = c->cur_seq_no;
+}
+}
+
+static struct segment *next2_segment(struct playlist *pls)
+{
+int n = pls->cur_seq_no - pls->start_seq_no + 2;
+if (n >= pls->n_segments)
+return NULL;
+return pls->segments[n];
+}
+
 static void free_segment_dynarray(struct segment **segments, int n_segments)
 {
 int i;
@@ -624,6 +662,31 @@ static int open_url_keepalive(AVFormatContext *s, 
AVIOContext **pb,
 #endif
 }
 
+static int update_throughputs(struct throughput *thr, float time, int pb_size)
+{
+if (pb_size <= 0 || time <= 0)
+return AVERROR(EINVAL);
+if (thr->n_throughputs < ABR_THROUGHPUT_FIFO_LEN) {
+++thr->n_throughputs;
+} else {
+++thr->head;
+}
+thr->throughput_fifo[thr->tail] = (float)(pb_size) / time;
+thr->tail = (thr->tail + 1) % ABR_THROUGHPUT_FIFO_LEN;
+return 0;
+}
+
+static int64_t get_switch_timestamp(HLSContext *c, struct playlist *pls)
+{
+int64_t pos = c->first_timestamp == AV_NOPTS_VALUE ?
+  0 : c->first_timestamp;
+
+for (int i = 0; i < pls->cur_seq_no + 2; i++) {
+pos += pls->segments[i]->duration;
+}
+return pos;
+}
+
 static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
 AVDictionary *opts, AVDictionary *opts2, int *is_http_out)
 {
@@ -639,6 +702,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 } else if (av_strstart(url, "data", NULL)) {
 if (url[4] == '+' || url[4] == ':')
 proto_name = avio_find_protocol_name(url + 5);
+} else if (av_strstart(url, "ffabr", NULL)) {
+if (url[5] == '+' || url[5] == ':')
+proto_name = avio_find_protocol_name(url + 6);
 }
 
 if (!proto_name)
@@ -669,6 +735,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 ;
 else if (av_strstart(url, "data", NULL) && !strncmp(proto_name, url + 5, 
strlen(proto_name)) && url[5 + strlen(proto_name)] == ':')
 ;
+else if (av_strstart(url, "ffabr", NULL) && !strncmp(proto_name, url + 6, 
strlen(proto_name)) && url[6 + strlen(proto_name)] == ':')
+;
 else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
 return AVERROR_INVALIDDATA;
 
@@ -690,6 +758,43 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 } else {
 ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
 }
+i

[FFmpeg-devel] [RFC][GSoC][PATCH v2 4/6] ffplay: add an option to enable abr

2020-07-16 Thread Hongcheng Zhong
From: spartazhc 

Add abr option, ffplay can play hls using abr by:
ffplay -i http://xxx/master.m3u8 -abr

Structure ABRList is added to save stream type and index, it is
used to allow packet_queue_put function to put pkt which from same
type(for example: video pkt) but different stream index to queue.

v1 fixed:
None.

v2 fixed:
1. check malloc result and return error message

Signed-off-by: spartazhc 
---
 doc/ffplay.texi  |   2 +
 fftools/ffplay.c | 151 ---
 2 files changed, 144 insertions(+), 9 deletions(-)

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index f3761bb12e..6a24542cda 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -46,6 +46,8 @@ Disable audio.
 Disable video.
 @item -sn
 Disable subtitles.
+@item -abr
+Enable adaptive bitrate for hls/dash.
 @item -ss @var{pos}
 Seek to @var{pos}. Note that in most formats it is not possible to seek
 exactly, so @command{ffplay} will seek to the nearest seek point to
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index d673b8049a..bcee507f40 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -201,6 +201,15 @@ typedef struct Decoder {
 SDL_Thread *decoder_tid;
 } Decoder;
 
+typedef struct ABRList {
+int **audio_list;
+int audios;
+int **video_list;
+int videos;
+int **sub_list;
+int subs;
+} ABRList;
+
 typedef struct VideoState {
 SDL_Thread *read_tid;
 AVInputFormat *iformat;
@@ -305,6 +314,8 @@ typedef struct VideoState {
 int last_video_stream, last_audio_stream, last_subtitle_stream;
 
 SDL_cond *continue_read_thread;
+
+ABRList *abr_list;
 } VideoState;
 
 /* options specified by the user */
@@ -356,6 +367,7 @@ static char *afilters = NULL;
 static int autorotate = 1;
 static int find_stream_info = 1;
 static int filter_nbthreads = 0;
+static int abr = 0;
 
 /* current context */
 static int is_full_screen;
@@ -1262,6 +1274,29 @@ static void stream_component_close(VideoState *is, int 
stream_index)
 }
 }
 
+static void free_abr_dynarray(int **list, int num)
+{
+for (int i = 0; i < num; i++) {
+av_free(list[i]);
+}
+}
+
+static void free_abr_list(ABRList *abrlist)
+{
+if (abrlist->audios) {
+free_abr_dynarray(abrlist->audio_list, abrlist->audios);
+av_freep(&abrlist->audio_list);
+}
+if (abrlist->videos) {
+free_abr_dynarray(abrlist->video_list, abrlist->videos);
+av_freep(&abrlist->video_list);
+}
+if (abrlist->subs) {
+free_abr_dynarray(abrlist->sub_list, abrlist->subs);
+av_freep(&abrlist->sub_list);
+}
+}
+
 static void stream_close(VideoState *is)
 {
 /* XXX: use a special url_shutdown call to abort parse cleanly */
@@ -2753,6 +2788,67 @@ static int is_realtime(AVFormatContext *s)
 return 0;
 }
 
+static av_cold int abr_init_list(VideoState *is)
+{
+int stream_index, *tmp;
+AVStream *st;
+int nb_streams = is->ic->nb_streams;
+ABRList *abrlist = is->abr_list;
+
+for (stream_index = 0; stream_index < nb_streams; stream_index++) {
+st = is->ic->streams[stream_index];
+tmp = av_memdup(&stream_index, sizeof(int));
+if (!tmp)
+return AVERROR(ENOMEM);
+switch (st->codecpar->codec_type) {
+case AVMEDIA_TYPE_AUDIO:
+av_dynarray_add(&abrlist->audio_list, &abrlist->audios, tmp);
+break;
+case AVMEDIA_TYPE_VIDEO:
+av_dynarray_add(&abrlist->video_list, &abrlist->videos, tmp);
+break;
+case AVMEDIA_TYPE_SUBTITLE:
+av_dynarray_add(&abrlist->sub_list, &abrlist->subs, tmp);
+break;
+default:
+av_free(tmp);
+break;
+}
+}
+return 0;
+}
+
+static int abr_check_list(ABRList *abr_list, enum AVMediaType type, int st)
+{
+int **st_list;
+int n_st;
+switch (type) {
+case AVMEDIA_TYPE_AUDIO:
+st_list = abr_list->audio_list;
+n_st = abr_list->audios;
+break;
+case AVMEDIA_TYPE_VIDEO:
+st_list = abr_list->video_list;
+n_st = abr_list->videos;
+break;
+case AVMEDIA_TYPE_SUBTITLE:
+st_list = abr_list->sub_list;
+n_st = abr_list->subs;
+break;
+default:
+break;
+}
+if (!st_list)
+return 0;
+for (int i = 0; i < n_st; i++) {
+if (*st_list[i] == st)
+return 1;
+}
+return 0;
+}
+
+
+
 /* this thread gets the stream from the disk or the network */
 static int read_thread(void *arg)
 {
@@ -2789,6 +2885,8 @@ static int read_thread(void *arg)
 av_dict_set(&format_opts, "scan_all_pmts", "1", 
AV_DICT_DONT_OVERWRITE);
 scan_all_pmts_set = 1;
 }
+if (abr)
+av_dict_set(&format_opts, "abr", "1", 0);
 err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
 if (err < 0) {

[FFmpeg-devel] [RFC][GSoC][PATCH v2 2/6] avformat/http: Add abr to whitelist

2020-07-16 Thread Hongcheng Zhong
From: spartazhc 

add abr protocol to http's whitelist

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

diff --git a/libavformat/http.c b/libavformat/http.c
index 6c39da1a8b..b77517ff51 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1815,7 +1815,7 @@ const URLProtocol ff_http_protocol = {
 .priv_data_size  = sizeof(HTTPContext),
 .priv_data_class = &http_context_class,
 .flags   = URL_PROTOCOL_FLAG_NETWORK,
-.default_whitelist   = "http,https,tls,rtp,tcp,udp,crypto,httpproxy,data"
+.default_whitelist   = 
"http,https,tls,rtp,tcp,udp,crypto,httpproxy,data,ffabr"
 };
 #endif /* CONFIG_HTTP_PROTOCOL */
 
-- 
2.27.0

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

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

[FFmpeg-devel] [RFC][GSoC][PATCH v2 5/6] avformat/utils: add av_packet_buffer_filter to filter packet_buffer

2020-07-16 Thread Hongcheng Zhong
From: spartazhc 

Add av_packet_buffer_filter to remove AVPackets whose stream_index is not
in st_index list. st_index has length of AVMEDIA_TYPE_NB, contains
the stream_index of all these media types.

Generally s->internal->packet_buffer may have pkts from different
stream, and stream_index will be used to discard pkt that is not
needed. But in case of abr, several streams may pass the stream_index
check. So we need a function to remove AVPackets not needed in pktl
added by hls_read_header.

v1 fixed:
1. rename function name *_clean to *_filter
2. fix memory leak in ff_packet_buffer_filter
3. update the doc

Signed-off-by: spartazhc 
---
 libavformat/avformat.h | 12 ++
 libavformat/internal.h | 16 +
 libavformat/utils.c| 54 ++
 libavformat/version.h  |  2 +-
 4 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index e91e7f1d33..c796fd0391 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2474,6 +2474,18 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts, int
  */
 int avformat_flush(AVFormatContext *s);
 
+/**
+ * Filter the packet buffer list of the AVFormatContext, remove the AVPackets
+ * do not need according to st_index.
+ * Only filter the packet_buffer list.
+ *
+ * @param s media file handle
+ * @param st_index the stream_index list which is needed
+ *st_index has length of AVMEDIA_TYPE_NB
+ *in index AVMEDIA_TYPE_XXX contains the stream_index needed of type 
XXX
+ */
+int av_packet_buffer_filter(AVFormatContext *s, int *st_index);
+
 /**
  * Start playing a network-based stream (e.g. RTSP stream) at the
  * current position.
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 17a6ab07d3..58ebcb2e35 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -772,6 +772,22 @@ int ff_packet_list_get(AVPacketList **head, AVPacketList 
**tail,
  */
 void ff_packet_list_free(AVPacketList **head, AVPacketList **tail);
 
+/**
+ * Remove the AVPackets do not need in the packet buffer list.
+ * For each type in AVMediaType, at most keep one stream and
+ * the others will be removed.
+ *
+ * @param head List head element
+ * @param tail List tail element
+ * @param st_index the stream_index list which is needed
+ *st_index has length of AVMEDIA_TYPE_NB
+ *in index AVMEDIA_TYPE_XXX contains the stream_index needed of type 
XXX
+ * @return 0 on success. Success is guaranteed
+ * if the packet list is not empty.
+ */
+int ff_packet_buffer_filter(AVPacketList **head, AVPacketList **tail,
+int *st_index);
+
 void avpriv_register_devices(const AVOutputFormat * const o[], const 
AVInputFormat * const i[]);
 
 #endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 807d9f10cb..7674e4ea3d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1565,6 +1565,60 @@ int ff_packet_list_get(AVPacketList **pkt_buffer,
 return 0;
 }
 
+/**
+ * return 1 if needed
+ */
+static int ff_check_st_index(int st, int *st_index)
+{
+for (int i = 0; i < AVMEDIA_TYPE_NB; ++i) {
+if (st_index[i] == st)
+return 1;
+}
+return 0;
+}
+
+int ff_packet_buffer_filter(AVPacketList **pkt_buffer,
+ AVPacketList **pkt_buffer_end,
+ int   *st_index)
+{
+AVPacketList *pktl, *pktn;
+av_assert0(*pkt_buffer);
+pktl = *pkt_buffer;
+pktn = pktl->next;
+
+/* num >= 2 */
+while (pktn) {
+if (!ff_check_st_index(pktn->pkt.stream_index, st_index)) {
+av_packet_unref(&pktn->pkt);
+pktl->next = pktn->next;
+av_freep(&pktn);
+pktn = pktl->next;
+} else {
+pktl = pktn;
+pktn = pktn->next;
+}
+}
+*pkt_buffer_end = pktl;
+/* first one*/
+pktl = *pkt_buffer;
+if (!ff_check_st_index(pktl->pkt.stream_index, st_index)) {
+av_packet_unref(&pktl->pkt);
+*pkt_buffer = pktl->next;
+if (!pktl->next)
+*pkt_buffer_end = NULL;
+av_freep(&pktl);
+}
+
+return 0;
+}
+
+int av_packet_buffer_filter(AVFormatContext *s, int *st_index)
+{
+int ret = ff_packet_buffer_filter(&s->internal->packet_buffer,
+   &s->internal->packet_buffer_end, st_index);
+return ret;
+}
+
 static int64_t ts_to_samples(AVStream *st, int64_t ts)
 {
 return av_rescale(ts, st->time_base.num * st->codecpar->sample_rate, 
st->time_base.den);
diff --git a/libavformat/version.h b/libavformat/version.h
index 75c03fde0a..c17727cf73 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  48
-#define LIBAVFORMAT_VERSIO

[FFmpeg-devel] [RFC][GSoC][PATCH v2 6/6] ffplay: add av_packet_buffer_filter to filter packet buffer

2020-07-16 Thread Hongcheng Zhong
From: spartazhc 

hls_read_header will add all streams to s->internal->packet_buffer.
Use av_packet_buffer_filter to remove the AVPackets from other streams that
are not needed, otherwise abr will allow them to be added to ffplay's
packet_queue.

Signed-off-by: spartazhc 
---
 fftools/ffplay.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index bcee507f40..ba71dbb38e 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3018,6 +3018,10 @@ static int read_thread(void *arg)
 
 /* clean packet list filled in hls_read_header if abr is enabled */
 if (abr) {
+ret = av_packet_buffer_filter(ic, st_index);
+if (ret < 0) {
+av_log(NULL, AV_LOG_WARNING, "Failed to clean av_packet\n");
+}
 is->abr_list = av_mallocz(sizeof(ABRList));
 if (!is->abr_list) {
 ret = AVERROR(ENOMEM);
-- 
2.27.0

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

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

Re: [FFmpeg-devel] Ticket 5012

2020-07-16 Thread Moritz Barsnick
On Thu, Jul 16, 2020 at 17:10:06 +0530, Gautam Ramakrishnan wrote:
> I was going through the bug tracker for a list of bugs associated with
> jpeg2000. Looking at issue 5012, is there a good utility for solving
> this issue?

What do you mean with utility? I suppose you just need to implement
JPEG2000 support according to RFC 5371 in libavformat/rtpenc.c, perhaps
a modification of libavformat/rtpenc_jpeg.c (but perhaps not, I didn't
compare the requirements, JPEG2000 in RTP looks a bit more complex).

(In case you're wondering about the issue itself: The error message is
old, a modern ffmpeg properly says:
  [rtp @ 0xd906c0] Unsupported codec jpeg2000
  Could not write header for output file #0 (incorrect codec parameters ?): 
Operation not permitted
  Error initializing output stream 0:0 --
)

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@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][GSoC][PATCH v2 5/6] avformat/utils: add av_packet_buffer_filter to filter packet_buffer

2020-07-16 Thread James Almer
On 7/16/2020 9:51 AM, Hongcheng Zhong wrote:
> From: spartazhc 
> 
> Add av_packet_buffer_filter to remove AVPackets whose stream_index is not
> in st_index list. st_index has length of AVMEDIA_TYPE_NB, contains
> the stream_index of all these media types.
> 
> Generally s->internal->packet_buffer may have pkts from different
> stream, and stream_index will be used to discard pkt that is not
> needed. But in case of abr, several streams may pass the stream_index
> check. So we need a function to remove AVPackets not needed in pktl
> added by hls_read_header.
> 
> v1 fixed:
> 1. rename function name *_clean to *_filter
> 2. fix memory leak in ff_packet_buffer_filter
> 3. update the doc
> 
> Signed-off-by: spartazhc 
> ---
>  libavformat/avformat.h | 12 ++
>  libavformat/internal.h | 16 +
>  libavformat/utils.c| 54 ++
>  libavformat/version.h  |  2 +-
>  4 files changed, 83 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index e91e7f1d33..c796fd0391 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -2474,6 +2474,18 @@ int avformat_seek_file(AVFormatContext *s, int 
> stream_index, int64_t min_ts, int
>   */
>  int avformat_flush(AVFormatContext *s);
>  
> +/**
> + * Filter the packet buffer list of the AVFormatContext, remove the AVPackets
> + * do not need according to st_index.

"Not needed", here and below.

> + * Only filter the packet_buffer list.
> + *
> + * @param s media file handle
> + * @param st_index the stream_index list which is needed
> + *st_index has length of AVMEDIA_TYPE_NB
> + *in index AVMEDIA_TYPE_XXX contains the stream_index needed of type 
> XXX

From an API user PoV, what does this function do? What is a "packet
buffer list"? How do i know what this does and how do i know when i need it?

> + */
> +int av_packet_buffer_filter(AVFormatContext *s, int *st_index);

No, av_packet_* is a libavcodec namespace for AVPacket helpers. You
can't use it here.

> +
>  /**
>   * Start playing a network-based stream (e.g. RTSP stream) at the
>   * current position.
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index 17a6ab07d3..58ebcb2e35 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -772,6 +772,22 @@ int ff_packet_list_get(AVPacketList **head, AVPacketList 
> **tail,
>   */
>  void ff_packet_list_free(AVPacketList **head, AVPacketList **tail);
>  
> +/**
> + * Remove the AVPackets do not need in the packet buffer list.
> + * For each type in AVMediaType, at most keep one stream and
> + * the others will be removed.
> + *
> + * @param head List head element
> + * @param tail List tail element
> + * @param st_index the stream_index list which is needed
> + *st_index has length of AVMEDIA_TYPE_NB
> + *in index AVMEDIA_TYPE_XXX contains the stream_index needed of type 
> XXX
> + * @return 0 on success. Success is guaranteed
> + * if the packet list is not empty.
> + */
> +int ff_packet_buffer_filter(AVPacketList **head, AVPacketList **tail,
> +int *st_index);
> +
>  void avpriv_register_devices(const AVOutputFormat * const o[], const 
> AVInputFormat * const i[]);
>  
>  #endif /* AVFORMAT_INTERNAL_H */
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 807d9f10cb..7674e4ea3d 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1565,6 +1565,60 @@ int ff_packet_list_get(AVPacketList **pkt_buffer,
>  return 0;
>  }
>  
> +/**
> + * return 1 if needed
> + */
> +static int ff_check_st_index(int st, int *st_index)

Static functions don't use the ff_ prefix.

> +{
> +for (int i = 0; i < AVMEDIA_TYPE_NB; ++i) {
> +if (st_index[i] == st)
> +return 1;
> +}
> +return 0;
> +}
> +
> +int ff_packet_buffer_filter(AVPacketList **pkt_buffer,
> + AVPacketList **pkt_buffer_end,
> + int   *st_index)
> +{
> +AVPacketList *pktl, *pktn;
> +av_assert0(*pkt_buffer);
> +pktl = *pkt_buffer;
> +pktn = pktl->next;
> +
> +/* num >= 2 */
> +while (pktn) {
> +if (!ff_check_st_index(pktn->pkt.stream_index, st_index)) {
> +av_packet_unref(&pktn->pkt);
> +pktl->next = pktn->next;
> +av_freep(&pktn);
> +pktn = pktl->next;
> +} else {
> +pktl = pktn;
> +pktn = pktn->next;
> +}
> +}
> +*pkt_buffer_end = pktl;
> +/* first one*/
> +pktl = *pkt_buffer;
> +if (!ff_check_st_index(pktl->pkt.stream_index, st_index)) {
> +av_packet_unref(&pktl->pkt);
> +*pkt_buffer = pktl->next;
> +if (!pktl->next)
> +*pkt_buffer_end = NULL;
> +av_freep(&pktl);
> +}

Why are you not using the existing packet list helpers for this?

> +
> +return 0;
> +}
> +
> +int av_packet_buffer_filter(AVFormatContext *s

[FFmpeg-devel] [PATCH] libaomenc: enable 8, 10 and 12 bit RGB encoding

2020-07-16 Thread Lynne
RGB pixel formats are one occasion where by pixel format we mean 
pixel format, primaries, transfer characteristic, and matrix coeffs,
so we have to manually set them as they're set to unspecified by
default, despite there only being a single possible combination.

Patch attached.

>From 83652d61b7da6fea486b1533fa39d23411f7cde9 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 16 Jul 2020 11:39:05 +0100
Subject: [PATCH] libaomenc: enable 8, 10 and 12 bit RGB encoding

RGB pixel formats are one occasion where by pixel format we mean
pixel format, primaries, transfer characteristic, and matrix coeffs,
so we have to manually set them as they're set to unspecified by
default, despite there only being a single possible combination.
---
 libavcodec/libaomenc.c | 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 2ecb3de3a7..0d6a376ef0 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -310,6 +310,7 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
 *img_fmt = AOM_IMG_FMT_I422;
 return 0;
 case AV_PIX_FMT_YUV444P:
+case AV_PIX_FMT_GBRP:
 enccfg->g_profile = FF_PROFILE_AV1_HIGH;
 *img_fmt = AOM_IMG_FMT_I444;
 return 0;
@@ -338,9 +339,13 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
 break;
 case AV_PIX_FMT_YUV444P10:
 case AV_PIX_FMT_YUV444P12:
+case AV_PIX_FMT_GBRP10:
+case AV_PIX_FMT_GBRP12:
 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
-enccfg->g_bit_depth = enccfg->g_input_bit_depth =
-avctx->pix_fmt == AV_PIX_FMT_YUV444P10 ? 10 : 12;
+enccfg->g_bit_depth = enccfg->g_input_bit_depth = 10;
+if (avctx->pix_fmt == AV_PIX_FMT_YUV444P12 ||
+avctx->pix_fmt == AV_PIX_FMT_GBRP12)
+enccfg->g_bit_depth = enccfg->g_input_bit_depth = 12;
 enccfg->g_profile =
 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL;
 *img_fmt = AOM_IMG_FMT_I44416;
@@ -749,9 +754,16 @@ static av_cold int aom_init(AVCodecContext *avctx,
 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);
-codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
+if (avctx->pix_fmt == AV_PIX_FMT_GBRP || avctx->pix_fmt == AV_PIX_FMT_GBRP10 ||
+avctx->pix_fmt == AV_PIX_FMT_GBRP12) {
+codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);
+codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);
+codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, AVCOL_TRC_IEC61966_2_1);
+} else {
+codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
+codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
+codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
+}
 if (ctx->aq_mode >= 0)
 codecctl_int(avctx, AV1E_SET_AQ_MODE, ctx->aq_mode);
 if (ctx->frame_parallel >= 0)
@@ -1077,6 +1089,7 @@ static const enum AVPixelFormat av1_pix_fmts[] = {
 AV_PIX_FMT_YUV420P,
 AV_PIX_FMT_YUV422P,
 AV_PIX_FMT_YUV444P,
+AV_PIX_FMT_GBRP,
 AV_PIX_FMT_NONE
 };
 
@@ -1084,12 +1097,15 @@ static const enum AVPixelFormat av1_pix_fmts_highbd[] = {
 AV_PIX_FMT_YUV420P,
 AV_PIX_FMT_YUV422P,
 AV_PIX_FMT_YUV444P,
+AV_PIX_FMT_GBRP,
 AV_PIX_FMT_YUV420P10,
 AV_PIX_FMT_YUV422P10,
 AV_PIX_FMT_YUV444P10,
 AV_PIX_FMT_YUV420P12,
 AV_PIX_FMT_YUV422P12,
 AV_PIX_FMT_YUV444P12,
+AV_PIX_FMT_GBRP10,
+AV_PIX_FMT_GBRP12,
 AV_PIX_FMT_NONE
 };
 
-- 
2.28.0.rc0

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

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

[FFmpeg-devel] [PATCH] avcodec: add RPZA encoder

2020-07-16 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/rpzaenc.c   | 857 +
 3 files changed, 859 insertions(+)
 create mode 100644 libavcodec/rpzaenc.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 18353da549..a01c64e066 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -578,6 +578,7 @@ OBJS-$(CONFIG_ROQ_ENCODER) += roqvideoenc.o 
roqvideo.o elbg.o
 OBJS-$(CONFIG_ROQ_DPCM_DECODER)+= dpcm.o
 OBJS-$(CONFIG_ROQ_DPCM_ENCODER)+= roqaudioenc.o
 OBJS-$(CONFIG_RPZA_DECODER)+= rpza.o
+OBJS-$(CONFIG_RPZA_ENCODER)+= rpzaenc.o
 OBJS-$(CONFIG_RSCC_DECODER)+= rscc.o
 OBJS-$(CONFIG_RV10_DECODER)+= rv10.o
 OBJS-$(CONFIG_RV10_ENCODER)+= rv10enc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a5048290f7..d9ce0e649e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -266,6 +266,7 @@ extern AVCodec ff_rawvideo_decoder;
 extern AVCodec ff_rl2_decoder;
 extern AVCodec ff_roq_encoder;
 extern AVCodec ff_roq_decoder;
+extern AVCodec ff_rpza_encoder;
 extern AVCodec ff_rpza_decoder;
 extern AVCodec ff_rscc_decoder;
 extern AVCodec ff_rv10_encoder;
diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c
new file mode 100644
index 00..7270386c28
--- /dev/null
+++ b/libavcodec/rpzaenc.c
@@ -0,0 +1,857 @@
+/*
+ * Quicktime RPZA Video Encoder.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file rpzaenc.c
+ * QT RPZA Video Encoder by Todd Kirby  and David Adler
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "avcodec.h"
+#include "internal.h"
+#include "put_bits.h"
+
+typedef struct RpzaContext {
+AVClass *avclass;
+
+int skip_frame_thresh;
+int start_one_color_thresh;
+int continue_one_color_thresh;
+int sixteen_color_thresh;
+
+AVFrame *prev_frame;// buffer for previous source frame
+PutBitContext pb;   // buffer for encoded frame data.
+
+int frame_width;// width in pixels of source frame
+int frame_height;   // height in pixesl of source frame
+
+int first_frame;// flag set to one when the first frame is being 
processed
+// so that comparisons with previous frame data in 
not attempted
+} RpzaContext;
+
+typedef enum channel_offset {
+RED = 2,
+GREEN = 1,
+BLUE = 0,
+} channel_offset;
+
+typedef struct rgb {
+uint8_t r;
+uint8_t g;
+uint8_t b;
+} rgb;
+
+#define SQR(x) ((x) * (x))
+
+/* 15 bit components */
+#define GET_CHAN(color, chan) ((color) >> ((chan) * 5) & 0x1F)
+#define R(color) GET_CHAN(color, RED)
+#define G(color) GET_CHAN(color, GREEN)
+#define B(color) GET_CHAN(color, BLUE)
+
+typedef struct BlockInfo {
+int row;
+int col;
+int block_width;
+int block_height;
+int image_width;
+int image_height;
+int block_index;
+uint16_t start;
+int rowstride;
+int blocks_per_row;
+int total_blocks;
+} BlockInfo;
+
+static void get_colors(uint8_t *min, uint8_t *max, uint8_t color4[4][3])
+{
+uint8_t step;
+
+color4[0][0] = min[0];
+color4[0][1] = min[1];
+color4[0][2] = min[2];
+
+color4[3][0] = max[0];
+color4[3][1] = max[1];
+color4[3][2] = max[2];
+
+// red components
+step = (color4[3][0] - color4[0][0] + 1) / 3;
+color4[1][0] = color4[0][0] + step;
+color4[2][0] = color4[3][0] - step;
+
+// green components
+step = (color4[3][1] - color4[0][1] + 1) / 3;
+color4[1][1] = color4[0][1] + step;
+color4[2][1] = color4[3][1] - step;
+
+// blue components
+step = (color4[3][2] - color4[0][2] + 1) / 3;
+color4[1][2] = color4[0][2] + step;
+color4[2][2] = color4[3][2] - step;
+}
+
+/* Fill BlockInfo struct with information about a 4x4 block of the image */
+static int get_block_info(BlockInfo *bi, int block)
+{
+bi->row = block / bi->blocks_per_row;
+bi->col = block % bi->blocks_per_row;
+
+// test for right edge block
+if (bi->col == bi->blocks_per_row - 1 && (bi->image_width % 4) != 0) {
+bi->block_width = bi->image_width % 4;
+

[FFmpeg-devel] [PATCH] adtsenc: Add ability to specify MPEG ID

2020-07-16 Thread Marvin Scholz
---

This stills lacks docs, as I first want an overall opinion on this
approach or possible other solutions I should choose for this.

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

diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index 9e285752eb..601d923526 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -40,6 +40,7 @@ typedef struct ADTSContext {
 int pce_size;
 int apetag;
 int id3v2tag;
+int mpeg_id;
 uint8_t pce_data[MAX_PCE_SIZE];
 } ADTSContext;
 
@@ -136,7 +137,7 @@ static int adts_write_frame_header(ADTSContext *ctx,
 
 /* adts_fixed_header */
 put_bits(&pb, 12, 0xfff);   /* syncword */
-put_bits(&pb, 1, 0);/* ID */
+put_bits(&pb, 1, ctx->mpeg_id); /* ID */
 put_bits(&pb, 2, 0);/* layer */
 put_bits(&pb, 1, 1);/* protection_absent */
 put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */
@@ -214,6 +215,9 @@ static int adts_write_trailer(AVFormatContext *s)
 static const AVOption options[] = {
 { "write_id3v2",  "Enable ID3v2 tag writing", OFFSET(id3v2tag), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, ENC},
 { "write_apetag", "Enable APE tag writing",   OFFSET(apetag),   
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, ENC},
+{ "mpeg_id", "Select which MPEG ID to write", OFFSET(mpeg_id),  
AV_OPT_TYPE_INT,  {.i64 = 0}, 0, 1, ENC, "mpeg_id"},
+{ "MPEG4",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 0},  0, 0, ENC, 
"mpeg_id" },
+{ "MPEG2",  NULL, 0, AV_OPT_TYPE_CONST,  {.i64 = 1},  0, 0, ENC, 
"mpeg_id" },
 { NULL },
 };
 
-- 
2.24.3 (Apple Git-128)

___
ffmpeg-devel mailing list
ffmpeg-devel@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] adtsenc: Add ability to specify MPEG ID

2020-07-16 Thread Kieran Kunhya
On Thu, 16 Jul 2020 at 16:25, Marvin Scholz  wrote:

> ---
>
> This stills lacks docs, as I first want an overall opinion on this
> approach or possible other solutions I should choose for this.
>

What uses this?

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] adtsenc: Add ability to specify MPEG ID

2020-07-16 Thread Marvin Scholz



On 16 Jul 2020, at 17:27, Kieran Kunhya wrote:

On Thu, 16 Jul 2020 at 16:25, Marvin Scholz  
wrote:



---

This stills lacks docs, as I first want an overall opinion on this
approach or possible other solutions I should choose for this.



What uses this?


It's needed when concatenating streams with existing ADTS streams that 
have the same parameters,

except for the differing MPEG ID.
Such a stream would be invalid if the MPEG IDs are different as then the 
fixed header part of

the ADTS header changes mid-stream, which is not allowed.

FFmpeg does not care and still works fine for such broken streams but 
some other players do

and will break trying to play such streams.
I could not find any reason for the choice of used MPEG ID in FFmpeg, 
and in the specifications
it was not clear to me either if there is even one "right" one to be 
used, so the best

way to solve this seemed to allow to choose it.



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] [RFC][GSoC][PATCH v2 5/6] avformat/utils: add av_packet_buffer_filter to filter packet_buffer

2020-07-16 Thread Andreas Rheinhardt
Hongcheng Zhong:
> From: spartazhc 
> 
> Add av_packet_buffer_filter to remove AVPackets whose stream_index is not
> in st_index list. st_index has length of AVMEDIA_TYPE_NB, contains
> the stream_index of all these media types.
> 
> Generally s->internal->packet_buffer may have pkts from different
> stream, and stream_index will be used to discard pkt that is not
> needed. But in case of abr, several streams may pass the stream_index
> check. So we need a function to remove AVPackets not needed in pktl
> added by hls_read_header.
> 
> v1 fixed:
> 1. rename function name *_clean to *_filter
> 2. fix memory leak in ff_packet_buffer_filter
> 3. update the doc
> 
> Signed-off-by: spartazhc 
> ---
>  libavformat/avformat.h | 12 ++
>  libavformat/internal.h | 16 +
>  libavformat/utils.c| 54 ++
>  libavformat/version.h  |  2 +-
>  4 files changed, 83 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index e91e7f1d33..c796fd0391 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -2474,6 +2474,18 @@ int avformat_seek_file(AVFormatContext *s, int 
> stream_index, int64_t min_ts, int
>   */
>  int avformat_flush(AVFormatContext *s);
>  
> +/**
> + * Filter the packet buffer list of the AVFormatContext, remove the AVPackets
> + * do not need according to st_index.
> + * Only filter the packet_buffer list.
> + *
> + * @param s media file handle
> + * @param st_index the stream_index list which is needed
> + *st_index has length of AVMEDIA_TYPE_NB
> + *in index AVMEDIA_TYPE_XXX contains the stream_index needed of type 
> XXX

This is obviously designed with only the next patch in mind. And this is
wrong. Use a proper parameter for the length.

> + */
> +int av_packet_buffer_filter(AVFormatContext *s, int *st_index);

const int *

> +
>  /**
>   * Start playing a network-based stream (e.g. RTSP stream) at the
>   * current position.
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index 17a6ab07d3..58ebcb2e35 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -772,6 +772,22 @@ int ff_packet_list_get(AVPacketList **head, AVPacketList 
> **tail,
>   */
>  void ff_packet_list_free(AVPacketList **head, AVPacketList **tail);
>  
> +/**
> + * Remove the AVPackets do not need in the packet buffer list.
> + * For each type in AVMediaType, at most keep one stream and
> + * the others will be removed.
> + *
> + * @param head List head element
> + * @param tail List tail element
> + * @param st_index the stream_index list which is needed
> + *st_index has length of AVMEDIA_TYPE_NB
> + *in index AVMEDIA_TYPE_XXX contains the stream_index needed of type 
> XXX
> + * @return 0 on success. Success is guaranteed
> + * if the packet list is not empty.
> + */
> +int ff_packet_buffer_filter(AVPacketList **head, AVPacketList **tail,
> +int *st_index);

const int *

> +
>  void avpriv_register_devices(const AVOutputFormat * const o[], const 
> AVInputFormat * const i[]);
>  
>  #endif /* AVFORMAT_INTERNAL_H */
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 807d9f10cb..7674e4ea3d 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1565,6 +1565,60 @@ int ff_packet_list_get(AVPacketList **pkt_buffer,
>  return 0;
>  }
>  
> +/**
> + * return 1 if needed
> + */
> +static int ff_check_st_index(int st, int *st_index)
> +{
> +for (int i = 0; i < AVMEDIA_TYPE_NB; ++i) {
> +if (st_index[i] == st)
> +return 1;
> +}
> +return 0;
> +}
> +
> +int ff_packet_buffer_filter(AVPacketList **pkt_buffer,
> + AVPacketList **pkt_buffer_end,
> + int   *st_index)
> +{
> +AVPacketList *pktl, *pktn;
> +av_assert0(*pkt_buffer);
> +pktl = *pkt_buffer;
> +pktn = pktl->next;
> +
> +/* num >= 2 */
> +while (pktn) {
> +if (!ff_check_st_index(pktn->pkt.stream_index, st_index)) {
> +av_packet_unref(&pktn->pkt);
> +pktl->next = pktn->next;
> +av_freep(&pktn);
> +pktn = pktl->next;
> +} else {
> +pktl = pktn;
> +pktn = pktn->next;
> +}
> +}
> +*pkt_buffer_end = pktl;
> +/* first one*/
> +pktl = *pkt_buffer;
> +if (!ff_check_st_index(pktl->pkt.stream_index, st_index)) {
> +av_packet_unref(&pktl->pkt);
> +*pkt_buffer = pktl->next;
> +if (!pktl->next)
> +*pkt_buffer_end = NULL;
> +av_freep(&pktl);
> +}
> +
> +return 0;
> +}
> +
> +int av_packet_buffer_filter(AVFormatContext *s, int *st_index)
> +{
> +int ret = ff_packet_buffer_filter(&s->internal->packet_buffer,
> +   &s->internal->packet_buffer_end, 
> st_index);
> +return ret;
> +}
> +
>  static int64_t ts_to_samples(AVStream *st, int64_t 

Re: [FFmpeg-devel] [RFC][GSoC][PATCH v1 6/6] ffplay: add av_packet_buffer_filter to filter packet buffer

2020-07-16 Thread Andreas Rheinhardt
Hongcheng Zhong:
> From: spartazhc 
> 
> hls_read_header will add all streams to s->internal->packet_buffer.
> Use av_packet_buffer_filter to remove the AVPackets from other streams that
> are not needed, otherwise abr will allow them to be added to ffplay's
> packet_queue.
> 
> Signed-off-by: spartazhc 
> ---
>  fftools/ffplay.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index b17b75fa8f..832e97d910 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -3018,6 +3018,10 @@ static int read_thread(void *arg)
>  
>  /* clean packet list filled in hls_read_header if abr is enabled */
>  if (abr) {
> +ret = av_packet_buffer_filter(ic, st_index);
> +if (ret < 0) {
> +av_log(NULL, AV_LOG_WARNING, "Failed to clean av_packet\n");
> +}
>  is->abr_list = av_mallocz(sizeof(ABRList));
>  ret = abr_init_list(is);
>  if (ret < 0) {
> 
Do we need this new function at all? Can't we not just set
AVStream.discard to AVDISCARD_ALL for the streams we don't want and
modify av_read_frame() to make sure that it never outputs packets
belonging to a stream that ought to be discarded?

- 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] adtsenc: Add ability to specify MPEG ID

2020-07-16 Thread Hendrik Leppkes
On Thu, Jul 16, 2020 at 5:28 PM Kieran Kunhya  wrote:
>
> On Thu, 16 Jul 2020 at 16:25, Marvin Scholz  wrote:
>
> > ---
> >
> > This stills lacks docs, as I first want an overall opinion on this
> > approach or possible other solutions I should choose for this.
> >
>
> What uses this?
>

In my experience some older devices also require the type set to MPEG2.

For the patch itself -
Its generally a good idea to be able to specify it, but i'm not sure
about the option chosen. Its a single bit value for swapping between
mpeg2 and mpeg4, maybe it should just be boolean?

- 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] [RFC][GSoC][PATCH v2 1/6] avformat/abr: Adaptive Bitrate support

2020-07-16 Thread Andreas Rheinhardt
Hongcheng Zhong:
> From: spartazhc 
> 
> Add abr module for hls/dash.
> 
> v1 fixed:
> 1. add an "ff" prefix to the protocol name to mark it internal.
> 2. use 1.2f for float constant 1.2.
> 3. simplify abr_seek for we just need AVSEEK_SIZE only.
> 
> v2 fixed:
> 1. fix error return
> 2. simplify abr_seek
> 

The commit message should describe what this commit does; the version
history should not be part of the commit message and should be added

> Signed-off-by: spartazhc 
> ---

below the --- here.

>  doc/protocols.texi  |   7 ++
>  libavformat/Makefile|   1 +
>  libavformat/abr.c   | 249 
>  libavformat/protocols.c |   1 +
>  4 files changed, 258 insertions(+)
>  create mode 100644 libavformat/abr.c
> 
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index 64ad3f05d6..ffbb36147e 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -51,6 +51,13 @@ in microseconds.
>  
>  A description of the currently available protocols follows.
>  
> +@section abr
> +
> +Adaptive bitrate sub-protocol work for hls/dash.
> +
> +The abr protocol takes stream information from hls/dash as input,
> +use bandwidth estimation to decide whether to switch or not.
> +
>  @section amqp
>  
>  Advanced Message Queueing Protocol (AMQP) version 0-9-1 is a broker based
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 26af859a28..7d74e45d2a 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -595,6 +595,7 @@ OBJS-$(CONFIG_CACHE_PROTOCOL)+= cache.o
>  OBJS-$(CONFIG_CONCAT_PROTOCOL)   += concat.o
>  OBJS-$(CONFIG_CRYPTO_PROTOCOL)   += crypto.o
>  OBJS-$(CONFIG_DATA_PROTOCOL) += data_uri.o
> +OBJS-$(CONFIG_FFABR_PROTOCOL)+= abr.o
>  OBJS-$(CONFIG_FFRTMPCRYPT_PROTOCOL)  += rtmpcrypt.o rtmpdigest.o rtmpdh.o
>  OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
>  OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
> diff --git a/libavformat/abr.c b/libavformat/abr.c
> new file mode 100644
> index 00..7699b9baef
> --- /dev/null
> +++ b/libavformat/abr.c
> @@ -0,0 +1,249 @@
> +/*
> + * Adaptive Bitrate Module for HLS / DASH
> + * Copyright (c) 2020 Hongcheng Zhong
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "avformat.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/time.h"
> +#include "libavutil/avstring.h"
> +#include "url.h"
> +#include 
> +
> +enum ABRFormatType {
> +ABR_TYPE_HLS,
> +ABR_TYPE_DASH
> +};
> +
> +typedef struct variant_bitrate {
> +int value;
> +int index;
> +} variant_bitrate;
> +
> +typedef struct ABRContext {
> +AVClass *class;

const AVClass *

> +URLContext *hd;
> +AVDictionary *abr_params;
> +AVDictionary *abr_metadata;
> +enum ABRFormatType format;
> +int cur_pls;
> +int can_switch;
> +int n_variants;
> +variant_bitrate *variants_bitrate;
> +int index;
> +int n_throughputs;
> +float *throughputs;
> +} ABRContext;
> +
> +static float harmonic_mean(int num, float* arr)

const float *arr

> +{
> +float tmp = 0;
> +
> +if (num <= 0) return 0;
> +
> +for (size_t i = 0; i < num; i++) {
> +tmp += 1 / arr[i];
> +}
> +
> +return num / tmp;
> +}
> +
> +static int hls_param_parse(ABRContext *c, const char *key, const char *value)
> +{
> +if (!av_strcasecmp(key, "cur_pls")) {
> +c->cur_pls = atoi(value);

The behaviour of atoi is undefined if the parsed value is too big. Use
something else. (Furthermore, you might also error out on something like
"42bar" where atoi would just return 42.)

> +} else if (!av_strcasecmp(key, "can_switch")) {
> +c->can_switch = atoi(value);
> +} else if (!av_strcasecmp(key, "n_variants")) {
> +c->n_variants = atoi(value);
> +c->variants_bitrate = av_mallocz(sizeof(variant_bitrate) * 
> c->n_variants);

Missing overflow check.

> +if (!c->variants_bitrate)
> +return AVERROR(ENOMEM);
> +} else if (av_strstart(key, "variant_bitrate", NULL)) {
> +c->variants_bitrate[c->index].value = atoi(value);
> +c->variants_bitrate[c->index].index = c->index;
> +c->index++;

This pre

Re: [FFmpeg-devel] [PATCH v2 3/4] libavcodec/jpeg2000 Fix RPCL Progression order check

2020-07-16 Thread Michael Niedermayer
On Tue, Jul 14, 2020 at 10:13:15PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> The RPCL progression order check was incomplete. This
> patch completes the check. Tested on p1_07.j2k.
> ---
>  libavcodec/jpeg2000dec.c | 18 --
>  1 file changed, 12 insertions(+), 6 deletions(-)

will apply

thx

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

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



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

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

Re: [FFmpeg-devel] Ticket 5012

2020-07-16 Thread Gautam Ramakrishnan
On Thu, Jul 16, 2020 at 6:26 PM Moritz Barsnick  wrote:
>
> On Thu, Jul 16, 2020 at 17:10:06 +0530, Gautam Ramakrishnan wrote:
> > I was going through the bug tracker for a list of bugs associated with
> > jpeg2000. Looking at issue 5012, is there a good utility for solving
> > this issue?
>
> What do you mean with utility? I suppose you just need to implement
> JPEG2000 support according to RFC 5371 in libavformat/rtpenc.c, perhaps
> a modification of libavformat/rtpenc_jpeg.c (but perhaps not, I didn't
> compare the requirements, JPEG2000 in RTP looks a bit more complex).
>
> (In case you're wondering about the issue itself: The error message is
> old, a modern ffmpeg properly says:
>   [rtp @ 0xd906c0] Unsupported codec jpeg2000
>   Could not write header for output file #0 (incorrect codec parameters ?): 
> Operation not permitted
>   Error initializing output stream 0:0 --
> )
>
> Moritz

Thanks Moritz, I'll work on adding this feature.



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

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

Re: [FFmpeg-devel] [PATCH] avformat/mov: fix atom type to string conversion

2020-07-16 Thread Michael Niedermayer
On Sun, Jul 12, 2020 at 12:26:58AM +0800, Zhao Zhili wrote:
> The conversion was endian-dependent, and it may contain non-printable
> characters.
> ---
>  libavformat/mov.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)

will apply

thx

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

Those who are best at talking, realize last or never when they are wrong.


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] Ticket 5012

2020-07-16 Thread Gautam Ramakrishnan
On Thu, Jul 16, 2020 at 10:10 PM Gautam Ramakrishnan
 wrote:
>
> On Thu, Jul 16, 2020 at 6:26 PM Moritz Barsnick  wrote:
> >
> > On Thu, Jul 16, 2020 at 17:10:06 +0530, Gautam Ramakrishnan wrote:
> > > I was going through the bug tracker for a list of bugs associated with
> > > jpeg2000. Looking at issue 5012, is there a good utility for solving
> > > this issue?
> >
> > What do you mean with utility? I suppose you just need to implement
> > JPEG2000 support according to RFC 5371 in libavformat/rtpenc.c, perhaps
> > a modification of libavformat/rtpenc_jpeg.c (but perhaps not, I didn't
> > compare the requirements, JPEG2000 in RTP looks a bit more complex).
> >
> > (In case you're wondering about the issue itself: The error message is
> > old, a modern ffmpeg properly says:
> >   [rtp @ 0xd906c0] Unsupported codec jpeg2000
> >   Could not write header for output file #0 (incorrect codec parameters ?): 
> > Operation not permitted
> >   Error initializing output stream 0:0 --
> > )
> >
> > Moritz
>
> Thanks Moritz, I'll work on adding this feature.
How could I get access to some stream/file for testing this feature if
I implement this?



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

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

Re: [FFmpeg-devel] [PATCH] libavcodec/h264dec: export block type in H.264

2020-07-16 Thread Yongle Lin
On Wed, Jul 15, 2020 at 4:37 PM Mark Thompson  wrote:

> On 15/07/2020 22:05, Yongle Lin wrote:
> > ---
> >   libavcodec/h264dec.c | 14 ++
> >   1 file changed, 14 insertions(+)
> >
> > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> > index 1e2ca68449..b3de5290d0 100644
> > --- a/libavcodec/h264dec.c
> > +++ b/libavcodec/h264dec.c
> > @@ -816,6 +816,20 @@ static int h264_export_enc_params(AVFrame *f,
> H264Picture *p)
> >   b->h = 16;
> >
> >   b->delta_qp = p->qscale_table[mb_xy] - par->qp;
> > +
> > +int mb_type = p->mb_type[mb_xy];
> > +if (IS_PCM(mb_type))
> > +b->flags |= AV_VIDEO_ENC_BLOCK_INTRA;
>
> Can you explain your definition of what makes a block "intra"?  If you
> really do mean to only include PCM blocks then maybe it should have a
> different name, because that isn't what I would expect.
>

I think intra is the block that uses no reference frame to predict? The
purpose of exporting this data is to enable visualization of block type
which has been deprecated since version 58. And previously it only
supported MPEG video and I want to make it more general to other codecs as
well.
Probably I should include  IS_PCM, IS_INTRA
&& IS_ACPRED(mb_type), IS_INTRA16x16, IS_INTRA4x4 as "intra" type for H.264?


> > +if (IS_SKIP(mb_type))
> > +b->flags |= AV_VIDEO_ENC_BLOCK_SKIP; > +if
> (!USES_LIST(mb_type, 1))
> > +b->ref[0] = p->ref_index[0];
> > +else if (!USES_LIST(mb_type, 0))
> > +b->ref[0] = p->ref_index[1];
> > +else {
> > +b->ref[0] = p->ref_index[0];
> > +b->ref[1] = p->ref_index[1];
>
> I don't think ref_index is anything to do with what you think it is.
>
> Also note that code of this form must be insufficient due to the lack
> dependence on both the slice and the block.  (Slice headers define the two
> reference picture lists, and blocks within a slice
> choose pictures from those lists.)
>

I am not good at H.264. I read the source code and because there isn't too
much comments I thought ref_index is the thing I want. I will try to
correct it to be the index of the L0, L1 picture.


> > +}
> >   }
> >
> >   return 0;
> >
>
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Best,
Yongle
___
ffmpeg-devel mailing list
ffmpeg-devel@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] Ticket 5012

2020-07-16 Thread Carl Eugen Hoyos
Am Do., 16. Juli 2020 um 19:42 Uhr schrieb Gautam Ramakrishnan
:

> How could I get access to some stream/file for testing this feature if
> I implement this?

GStreamer should allow you to test your implementation.

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] Support HDR10+ metadata for HEVC

2020-07-16 Thread Mohammad Izadi
From: Mohammad Izadi 

---
 libavcodec/avpacket.c |   1 +
 libavcodec/decode.c   |   1 +
 libavcodec/hevc_sei.c |  40 +++---
 libavcodec/hevc_sei.h |   5 ++
 libavcodec/hevcdec.c  |   7 ++
 libavcodec/internal.h |   9 +++
 libavcodec/packet.h   |   9 +++
 libavcodec/utils.c| 180 ++
 libavcodec/version.h  |   2 +-
 9 files changed, 241 insertions(+), 13 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index dce26cb31a..8307032335 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -394,6 +394,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:return "Content light level 
metadata";
 case AV_PKT_DATA_SPHERICAL:  return "Spherical Mapping";
 case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
+case AV_PKT_DATA_DYNAMIC_HDR_PLUS:   return "HDR10+ Dynamic 
Metadata (SMPTE 2094-40)";
 case AV_PKT_DATA_ENCRYPTION_INIT_INFO:   return "Encryption 
initialization data";
 case AV_PKT_DATA_ENCRYPTION_INFO:return "Encryption info";
 case AV_PKT_DATA_AFD:return "Active Format 
Description data";
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index de9c079f9d..cd3286f7fb 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1698,6 +1698,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, 
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
 { AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
 { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC },
+{ AV_PKT_DATA_DYNAMIC_HDR_PLUS,   
AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
 { AV_PKT_DATA_ICC_PROFILE,AV_FRAME_DATA_ICC_PROFILE },
 };
 
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index a4ec65dc1a..096c414d91 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -25,6 +25,12 @@
 #include "golomb.h"
 #include "hevc_ps.h"
 #include "hevc_sei.h"
+#include "internal.h"
+
+static const uint8_t usa_country_code = 0xB5;
+static const uint16_t smpte_provider_code = 0x003C;
+static const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
+static const uint16_t smpte2094_40_application_identifier = 0x04;
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb)
 {
@@ -242,8 +248,8 @@ static int 
decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, GetBitC
 static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, 
GetBitContext *gb,
  int size)
 {
-uint32_t country_code;
-uint32_t user_identifier;
+uint8_t country_code;
+uint16_t provider_code;
 
 if (size < 7)
 return AVERROR(EINVAL);
@@ -255,18 +261,27 @@ static int 
decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitConte
 size--;
 }
 
-skip_bits(gb, 8);
-skip_bits(gb, 8);
-
-user_identifier = get_bits_long(gb, 32);
-
-switch (user_identifier) {
-case MKBETAG('G', 'A', '9', '4'):
+provider_code = get_bits(gb, 16);
+
+if (country_code == usa_country_code &&
+provider_code == smpte_provider_code) {
+// A/341 Amendment – 2094-40
+uint16_t provider_oriented_code = get_bits(gb, 16);
+uint8_t application_identifier = get_bits(gb, 8);
+if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
+application_identifier == smpte2094_40_application_identifier) {
+int err = ff_read_itu_t_t35_to_dynamic_hdr_plus(gb, 
s->dynamic_hdr_plus.info);
+if (err < 0 && s->dynamic_hdr_plus.info) {
+av_buffer_unref(&s->dynamic_hdr_plus.info);
+}
+return err;
+}
+} else {
+uint32_t  user_identifier = get_bits_long(gb, 32);
+if(user_identifier == MKBETAG('G', 'A', '9', '4'))
 return decode_registered_user_data_closed_caption(&s->a53_caption, 
gb, size);
-default:
-skip_bits_long(gb, size * 8);
-break;
 }
+skip_bits_long(gb, size * 8);
 return 0;
 }
 
@@ -453,4 +468,5 @@ void ff_hevc_reset_sei(HEVCSEI *s)
 av_buffer_unref(&s->unregistered.buf_ref[i]);
 s->unregistered.nb_buf_ref = 0;
 av_freep(&s->unregistered.buf_ref);
+av_buffer_unref(&s->dynamic_hdr_plus.info);
 }
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 5ee7a4796d..e9e2d46ed4 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -104,6 +104,10 @@ typedef struct HEVCSEIMasteringDisplay {
 uint32_t min_luminance;
 } HEVCSEIMasteringDisplay;
 
+typedef struct HEVCSEIDynamicHDRPlus {
+AVBufferRef *info;
+} HEVCSEIDynamicHDRPlus;
+
 typedef struct HEVCSEIContentLight {
 int present;

[FFmpeg-devel] [PATCH] [RFC] libavcodec/hevc_refs: Clear DPB of old frames

2020-07-16 Thread Kieran Kunhya
During glitching or looping streams, old frames remain in the DPB.
The decoder incorrectly thinks that the DPB contains the right number of
buffered frames to output and reordering breaks badly

Any non-cosmetic comments welcome.

Kieran


0001-RFC-libavcodec-hevc_refs-Clear-DPB-of-old-frames.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] adtsenc: Add ability to specify MPEG ID

2020-07-16 Thread Marvin Scholz


On 16 Jul 2020, at 18:11, Hendrik Leppkes wrote:

> On Thu, Jul 16, 2020 at 5:28 PM Kieran Kunhya  wrote:
>>
>> On Thu, 16 Jul 2020 at 16:25, Marvin Scholz  wrote:
>>
>>> ---
>>>
>>> This stills lacks docs, as I first want an overall opinion on this
>>> approach or possible other solutions I should choose for this.
>>>
>>
>> What uses this?
>>
>
> In my experience some older devices also require the type set to MPEG2.
>
> For the patch itself -
> Its generally a good idea to be able to specify it, but i'm not sure
> about the option chosen. Its a single bit value for swapping between
> mpeg2 and mpeg4, maybe it should just be boolean?
>

Sure, thats of course possible too. I have no strong opinions about that
at all. (It's just mostly that it could not come up with a good idea
for a boolean option name for this)

> - 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 mailing list
ffmpeg-devel@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] Support HDR10+ metadata for HEVC

2020-07-16 Thread Carl Eugen Hoyos
Am Do., 16. Juli 2020 um 21:24 Uhr schrieb Mohammad Izadi
:

> -user_identifier = get_bits_long(gb, 32);
> -
> -switch (user_identifier) {
> -case MKBETAG('G', 'A', '9', '4'):

Why did you have to change this existing code?

Could you elaborate a little on the use-cases this patch supports (and
does not support) in the commit message?

A micro version bump should be sufficient.

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] Support HDR10+ metadata for HEVC

2020-07-16 Thread James Almer
On 7/16/2020 4:23 PM, Mohammad Izadi wrote:
> From: Mohammad Izadi 
> 
> ---
>  libavcodec/avpacket.c |   1 +
>  libavcodec/decode.c   |   1 +
>  libavcodec/hevc_sei.c |  40 +++---
>  libavcodec/hevc_sei.h |   5 ++
>  libavcodec/hevcdec.c  |   7 ++
>  libavcodec/internal.h |   9 +++
>  libavcodec/packet.h   |   9 +++
>  libavcodec/utils.c| 180 ++
>  libavcodec/version.h  |   2 +-
>  9 files changed, 241 insertions(+), 13 deletions(-)
> 
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index dce26cb31a..8307032335 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -394,6 +394,7 @@ const char *av_packet_side_data_name(enum 
> AVPacketSideDataType type)
>  case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:return "Content light level 
> metadata";
>  case AV_PKT_DATA_SPHERICAL:  return "Spherical Mapping";
>  case AV_PKT_DATA_A53_CC: return "A53 Closed 
> Captions";
> +case AV_PKT_DATA_DYNAMIC_HDR_PLUS:   return "HDR10+ Dynamic 
> Metadata (SMPTE 2094-40)";
>  case AV_PKT_DATA_ENCRYPTION_INIT_INFO:   return "Encryption 
> initialization data";
>  case AV_PKT_DATA_ENCRYPTION_INFO:return "Encryption info";
>  case AV_PKT_DATA_AFD:return "Active Format 
> Description data";
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index de9c079f9d..cd3286f7fb 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1698,6 +1698,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, 
> AVFrame *frame)
>  { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, 
> AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
>  { AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
> AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
>  { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC },
> +{ AV_PKT_DATA_DYNAMIC_HDR_PLUS,   
> AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
>  { AV_PKT_DATA_ICC_PROFILE,AV_FRAME_DATA_ICC_PROFILE 
> },
>  };
>  
> diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
> index a4ec65dc1a..096c414d91 100644
> --- a/libavcodec/hevc_sei.c
> +++ b/libavcodec/hevc_sei.c
> @@ -25,6 +25,12 @@
>  #include "golomb.h"
>  #include "hevc_ps.h"
>  #include "hevc_sei.h"
> +#include "internal.h"
> +
> +static const uint8_t usa_country_code = 0xB5;
> +static const uint16_t smpte_provider_code = 0x003C;
> +static const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
> +static const uint16_t smpte2094_40_application_identifier = 0x04;

No global state, please. You can just use the values in question and add
a comment next to them to describe their meaning, like it's done for a
lot other values in this file.

>  
>  static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
> GetBitContext *gb)
>  {
> @@ -242,8 +248,8 @@ static int 
> decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, GetBitC
>  static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, 
> GetBitContext *gb,
>   int size)
>  {
> -uint32_t country_code;
> -uint32_t user_identifier;
> +uint8_t country_code;
> +uint16_t provider_code;
>  
>  if (size < 7)
>  return AVERROR(EINVAL);
> @@ -255,18 +261,27 @@ static int 
> decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitConte
>  size--;
>  }
>  
> -skip_bits(gb, 8);
> -skip_bits(gb, 8);
> -
> -user_identifier = get_bits_long(gb, 32);
> -
> -switch (user_identifier) {
> -case MKBETAG('G', 'A', '9', '4'):
> +provider_code = get_bits(gb, 16);
> +
> +if (country_code == usa_country_code &&
> +provider_code == smpte_provider_code) {
> +// A/341 Amendment – 2094-40
> +uint16_t provider_oriented_code = get_bits(gb, 16);
> +uint8_t application_identifier = get_bits(gb, 8);
> +if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
> +application_identifier == smpte2094_40_application_identifier) {
> +int err = ff_read_itu_t_t35_to_dynamic_hdr_plus(gb, 
> s->dynamic_hdr_plus.info);
> +if (err < 0 && s->dynamic_hdr_plus.info) {
> +av_buffer_unref(&s->dynamic_hdr_plus.info);
> +}
> +return err;
> +}
> +} else {
> +uint32_t  user_identifier = get_bits_long(gb, 32);
> +if(user_identifier == MKBETAG('G', 'A', '9', '4'))
>  return 
> decode_registered_user_data_closed_caption(&s->a53_caption, gb, size);
> -default:
> -skip_bits_long(gb, size * 8);
> -break;
>  }
> +skip_bits_long(gb, size * 8);
>  return 0;
>  }
>  
> @@ -453,4 +468,5 @@ void ff_hevc_reset_sei(HEVCSEI *s)
>  av_buffer_unref(&s->unregistered.buf_ref[i]);
>  s->unregistered.nb_buf_ref = 0;
>  av_freep(&s->unregistered.buf_ref);

Re: [FFmpeg-devel] [PATCH] Support HDR10+ metadata for HEVC

2020-07-16 Thread James Almer
On 7/16/2020 4:29 PM, Carl Eugen Hoyos wrote:
> Am Do., 16. Juli 2020 um 21:24 Uhr schrieb Mohammad Izadi
> :
> 
>> -user_identifier = get_bits_long(gb, 32);
>> -
>> -switch (user_identifier) {
>> -case MKBETAG('G', 'A', '9', '4'):
> 
> Why did you have to change this existing code?
> 
> Could you elaborate a little on the use-cases this patch supports (and
> does not support) in the commit message?
> 
> A micro version bump should be sufficient.

It adds a new AVPacketSideDataType enum entry, so minor is correct.

> 
> 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 mailing list
ffmpeg-devel@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] Support HDR10+ metadata for HEVC

2020-07-16 Thread Steinar H. Gunderson
On Thu, Jul 16, 2020 at 06:34:31PM -0300, James Almer wrote:
>>  static AVMutex codec_mutex = AV_MUTEX_INITIALIZER;
>> +static const uint8_t usa_country_code = 0xB5;
>> +static const uint16_t smpte_provider_code = 0x003C;
>> +static const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
>> +static const uint16_t smpte2094_40_application_identifier = 0x04;
>> +static const int64_t luminance_den = 1;
>> +static const int32_t peak_luminance_den = 15;
>> +static const int64_t rgb_den = 10;
>> +static const int32_t fraction_pixel_den = 1000;
>> +static const int32_t knee_point_den = 4095;
>> +static const int32_t bezier_anchor_den = 1023;
>> +static const int32_t saturation_weight_den = 8;
> Same, no global state.

It's not state if it can't be changed.

/* Steinar */
-- 
Homepage: https://www.sesse.net/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 2/2] avutil/fixed_dsp: Fix integer overflows in butterflies_fixed_c()

2020-07-16 Thread Michael Niedermayer
Fixes: signed integer overflow: 0 - -2147483648 cannot be represented in type 
'int'
Fixes: 
23646/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5480991098667008

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

diff --git a/libavutil/fixed_dsp.c b/libavutil/fixed_dsp.c
index 8c018581df..f1b195f184 100644
--- a/libavutil/fixed_dsp.c
+++ b/libavutil/fixed_dsp.c
@@ -134,9 +134,10 @@ static int scalarproduct_fixed_c(const int *v1, const int 
*v2, int len)
 return (int)(p >> 31);
 }
 
-static void butterflies_fixed_c(int *v1, int *v2, int len)
+static void butterflies_fixed_c(int *v1s, int *v2, int len)
 {
 int i;
+unsigned int *v1 = v1s;
 
 for (i = 0; i < len; i++){
 int t = v1[i] - v2[i];
-- 
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 1/2] avcodec/tiff: Fix default white level

2020-07-16 Thread Michael Niedermayer
According to the spec bits per sample should be used

Fix invalid shift with bpp=32
Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 
23507/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4815432665268224

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/tiff.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 18b327e800..e0733f54d9 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1883,8 +1883,14 @@ again:
 if (is_dng) {
 int bps;
 
+if (s->bpp % s->bppcount)
+return AVERROR_INVALIDDATA;
+bps = s->bpp / s->bppcount;
+if (bps < 8 || bps > 32)
+return AVERROR_INVALIDDATA;
+
 if (s->white_level == 0)
-s->white_level = (1 << s->bpp) - 1; /* Default value as per the 
spec */
+s->white_level = (1LL << bps) - 1; /* Default value as per the 
spec */
 
 if (s->white_level <= s->black_level) {
 av_log(avctx, AV_LOG_ERROR, "BlackLevel (%"PRId32") must be less 
than WhiteLevel (%"PRId32")\n",
@@ -1892,11 +1898,6 @@ again:
 return AVERROR_INVALIDDATA;
 }
 
-if (s->bpp % s->bppcount)
-return AVERROR_INVALIDDATA;
-bps = s->bpp / s->bppcount;
-if (bps < 8 || bps > 32)
-return AVERROR_INVALIDDATA;
 if (s->planar)
 return AVERROR_PATCHWELCOME;
 }
-- 
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 3/4] avcodec/filter_units_bsf: Use separate contexts for reading/writing

2020-07-16 Thread Mark Thompson

On 08/07/2020 02:29, James Almer wrote:

Based on code from 235a5734e0

Signed-off-by: James Almer 
---
  libavcodec/filter_units_bsf.c | 23 ++-
  1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/libavcodec/filter_units_bsf.c b/libavcodec/filter_units_bsf.c
index 354594ac50..14960761d2 100644
--- a/libavcodec/filter_units_bsf.c
+++ b/libavcodec/filter_units_bsf.c
@@ -29,7 +29,8 @@
  typedef struct FilterUnitsContext {
  const AVClass *class;
  
-CodedBitstreamContext *cbc;

+CodedBitstreamContext *input;
+CodedBitstreamContext *output;
  CodedBitstreamFragment fragment;
  
  const char *pass_types;

@@ -112,7 +113,7 @@ static int filter_units_filter(AVBSFContext *bsf, AVPacket 
*pkt)
  if (ctx->mode == NOOP)
  return 0;
  
-err = ff_cbs_read_packet(ctx->cbc, frag, pkt);

+err = ff_cbs_read_packet(ctx->input, frag, pkt);
  if (err < 0) {
  av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
  goto fail;
@@ -134,7 +135,7 @@ static int filter_units_filter(AVBSFContext *bsf, AVPacket 
*pkt)
  goto fail;
  }
  
-err = ff_cbs_write_packet(ctx->cbc, pkt, frag);

+err = ff_cbs_write_packet(ctx->output, pkt, frag);
  if (err < 0) {
  av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
  goto fail;
@@ -179,22 +180,25 @@ static int filter_units_init(AVBSFContext *bsf)
  return 0;
  }
  
-err = ff_cbs_init(&ctx->cbc, bsf->par_in->codec_id, bsf);

+err = ff_cbs_init(&ctx->input, bsf->par_in->codec_id, bsf);
+if (err < 0)
+return err;
+err = ff_cbs_init(&ctx->output, bsf->par_in->codec_id, bsf);
  if (err < 0)
  return err;
  
  // Don't actually decompose anything, we only want the unit data.

-ctx->cbc->decompose_unit_types= ctx->type_list;
-ctx->cbc->nb_decompose_unit_types = 0;
+ctx->input->decompose_unit_types= ctx->type_list;
+ctx->input->nb_decompose_unit_types = 0;
  
  if (bsf->par_in->extradata) {

  CodedBitstreamFragment *frag = &ctx->fragment;
  
-err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in);

+err = ff_cbs_read_extradata(ctx->input, frag, bsf->par_in);
  if (err < 0) {
  av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
  } else {
-err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag);
+err = ff_cbs_write_extradata(ctx->output, bsf->par_out, frag);
  if (err < 0)
  av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
  }
@@ -212,7 +216,8 @@ static void filter_units_close(AVBSFContext *bsf)
  av_freep(&ctx->type_list);
  
  ff_cbs_fragment_free(&ctx->fragment);

-ff_cbs_close(&ctx->cbc);
+ff_cbs_close(&ctx->input);
+ff_cbs_close(&ctx->output);
  }
  
  #define OFFSET(x) offsetof(FilterUnitsContext, x)




Given that it never decomposes anything, I don't think that has any effect?  
Possibly it's a good idea to be consistent anyway - I don't really mind.

The other three patches in this series look right to me in any case.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@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/hls: add supporting EXT-X-DISCONTINUITY tag

2020-07-16 Thread Dongwon Kim
Signed-off-by: Dongwon Kim 
---
 libavformat/hls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c index ba17c4ed96..5e331ab68f 
100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -810,6 +810,8 @@ static int parse_playlist(HLSContext *c, const char *url,
 ff_parse_key_value(ptr, (ff_parse_key_val_cb) 
handle_rendition_args,
&info);
 new_rendition(c, &info, url);
+} else if (av_strstart(line, "#EXT-X-DISCONTINUITY", &ptr)) {
+c->ctx->iformat->flags |= AVFMT_TS_DISCONT;
 } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
 ret = ensure_playlist(c, &pls, url);
 if (ret < 0)
@@ -2406,7 +2408,7 @@ AVInputFormat ff_hls_demuxer = {
 .long_name  = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
 .priv_class = &hls_class,
 .priv_data_size = sizeof(HLSContext),
-.flags  = AVFMT_NOGENSEARCH | AVFMT_TS_DISCONT,
+.flags  = AVFMT_NOGENSEARCH,
 .read_probe = hls_probe,
 .read_header= hls_read_header,
 .read_packet= hls_read_packet,
--
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH 3/4] avcodec/filter_units_bsf: Use separate contexts for reading/writing

2020-07-16 Thread James Almer
On 7/16/2020 8:05 PM, Mark Thompson wrote:
> On 08/07/2020 02:29, James Almer wrote:
>> Based on code from 235a5734e0
>>
>> Signed-off-by: James Almer 
>> ---
>>   libavcodec/filter_units_bsf.c | 23 ++-
>>   1 file changed, 14 insertions(+), 9 deletions(-)
>>
>> diff --git a/libavcodec/filter_units_bsf.c
>> b/libavcodec/filter_units_bsf.c
>> index 354594ac50..14960761d2 100644
>> --- a/libavcodec/filter_units_bsf.c
>> +++ b/libavcodec/filter_units_bsf.c
>> @@ -29,7 +29,8 @@
>>   typedef struct FilterUnitsContext {
>>   const AVClass *class;
>>   -    CodedBitstreamContext *cbc;
>> +    CodedBitstreamContext *input;
>> +    CodedBitstreamContext *output;
>>   CodedBitstreamFragment fragment;
>>     const char *pass_types;
>> @@ -112,7 +113,7 @@ static int filter_units_filter(AVBSFContext *bsf,
>> AVPacket *pkt)
>>   if (ctx->mode == NOOP)
>>   return 0;
>>   -    err = ff_cbs_read_packet(ctx->cbc, frag, pkt);
>> +    err = ff_cbs_read_packet(ctx->input, frag, pkt);
>>   if (err < 0) {
>>   av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
>>   goto fail;
>> @@ -134,7 +135,7 @@ static int filter_units_filter(AVBSFContext *bsf,
>> AVPacket *pkt)
>>   goto fail;
>>   }
>>   -    err = ff_cbs_write_packet(ctx->cbc, pkt, frag);
>> +    err = ff_cbs_write_packet(ctx->output, pkt, frag);
>>   if (err < 0) {
>>   av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
>>   goto fail;
>> @@ -179,22 +180,25 @@ static int filter_units_init(AVBSFContext *bsf)
>>   return 0;
>>   }
>>   -    err = ff_cbs_init(&ctx->cbc, bsf->par_in->codec_id, bsf);
>> +    err = ff_cbs_init(&ctx->input, bsf->par_in->codec_id, bsf);
>> +    if (err < 0)
>> +    return err;
>> +    err = ff_cbs_init(&ctx->output, bsf->par_in->codec_id, bsf);
>>   if (err < 0)
>>   return err;
>>     // Don't actually decompose anything, we only want the unit data.
>> -    ctx->cbc->decompose_unit_types    = ctx->type_list;
>> -    ctx->cbc->nb_decompose_unit_types = 0;
>> +    ctx->input->decompose_unit_types    = ctx->type_list;
>> +    ctx->input->nb_decompose_unit_types = 0;
>>     if (bsf->par_in->extradata) {
>>   CodedBitstreamFragment *frag = &ctx->fragment;
>>   -    err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in);
>> +    err = ff_cbs_read_extradata(ctx->input, frag, bsf->par_in);
>>   if (err < 0) {
>>   av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
>>   } else {
>> -    err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag);
>> +    err = ff_cbs_write_extradata(ctx->output, bsf->par_out,
>> frag);
>>   if (err < 0)
>>   av_log(bsf, AV_LOG_ERROR, "Failed to write
>> extradata.\n");
>>   }
>> @@ -212,7 +216,8 @@ static void filter_units_close(AVBSFContext *bsf)
>>   av_freep(&ctx->type_list);
>>     ff_cbs_fragment_free(&ctx->fragment);
>> -    ff_cbs_close(&ctx->cbc);
>> +    ff_cbs_close(&ctx->input);
>> +    ff_cbs_close(&ctx->output);
>>   }
>>     #define OFFSET(x) offsetof(FilterUnitsContext, x)
>>
> 
> Given that it never decomposes anything, I don't think that has any
> effect?

Mmh, you're right. Should have realized it when i looked at the
decompose disabling part and noticed i didn't need to duplicate it.

>  Possibly it's a good idea to be consistent anyway - I don't
> really mind.
> 
> The other three patches in this series look right to me in any case.

Will push the rest and drop this one. Thanks.

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

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

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

Re: [FFmpeg-devel] [PATCH] avformat/hls: add supporting EXT-X-DISCONTINUITY tag

2020-07-16 Thread Dongwon Kim
I modified setting AVFMT_TS_DISCONT flag on HLS input format depending on 
whether "EXT-X-DISCONTINUITY" existed or not in M3U8.
previous, commits are set "AVFMT_TS_DISCONT" flag unconditionally, whether 
"EXT-X-DISCONTINUITY" existed or not, as below
https://github.com/FFmpeg/FFmpeg/commit/d6ac6650b911f0957e69545d7fc25be6b7728705#diff-0e876d29bdcae30d9d256f04bc8795db

So, I added checking and parsing "EXT-X-DISCONTINUITY" syntax, and if only it 
exists then set AVFMT_TS_DISCONT flag.


On Fri, Jul 17, 2020 at 12:43:05AM +, Dongwon Kim wrote:
> Signed-off-by: Dongwon Kim 
> ---
>  libavformat/hls.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c index 
> ba17c4ed96..5e331ab68f 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -810,6 +810,8 @@ static int parse_playlist(HLSContext *c, const char *url,
>  ff_parse_key_value(ptr, (ff_parse_key_val_cb) 
> handle_rendition_args,
> &info);
>  new_rendition(c, &info, url);
> +} else if (av_strstart(line, "#EXT-X-DISCONTINUITY", &ptr)) {
> +c->ctx->iformat->flags |= AVFMT_TS_DISCONT;
>  } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
>  ret = ensure_playlist(c, &pls, url);
>  if (ret < 0)
> @@ -2406,7 +2408,7 @@ AVInputFormat ff_hls_demuxer = {
>  .long_name  = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
>  .priv_class = &hls_class,
>  .priv_data_size = sizeof(HLSContext),
> -.flags  = AVFMT_NOGENSEARCH | AVFMT_TS_DISCONT,
> +.flags  = AVFMT_NOGENSEARCH,
>  .read_probe = hls_probe,
>  .read_header= hls_read_header,
>  .read_packet= hls_read_packet,
> --
> 2.25.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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] libaomenc: enable 8, 10 and 12 bit RGB encoding

2020-07-16 Thread James Almer
On 7/16/2020 7:46 AM, Lynne wrote:
> RGB pixel formats are one occasion where by pixel format we mean 
> pixel format, primaries, transfer characteristic, and matrix coeffs,
> so we have to manually set them as they're set to unspecified by
> default, despite there only being a single possible combination.
> 
> Patch attached.

[...]

> From 83652d61b7da6fea486b1533fa39d23411f7cde9 Mon Sep 17 00:00:00 2001
> From: Lynne 
> Date: Thu, 16 Jul 2020 11:39:05 +0100
> Subject: [PATCH] libaomenc: enable 8, 10 and 12 bit RGB encoding
> 
> RGB pixel formats are one occasion where by pixel format we mean
> pixel format, primaries, transfer characteristic, and matrix coeffs,
> so we have to manually set them as they're set to unspecified by
> default, despite there only being a single possible combination.
> ---
>  libavcodec/libaomenc.c | 26 +-
>  1 file changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index 2ecb3de3a7..0d6a376ef0 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -310,6 +310,7 @@ static int set_pix_fmt(AVCodecContext *avctx, 
> aom_codec_caps_t codec_caps,
>  *img_fmt = AOM_IMG_FMT_I422;
>  return 0;
>  case AV_PIX_FMT_YUV444P:
> +case AV_PIX_FMT_GBRP:
>  enccfg->g_profile = FF_PROFILE_AV1_HIGH;
>  *img_fmt = AOM_IMG_FMT_I444;
>  return 0;
> @@ -338,9 +339,13 @@ static int set_pix_fmt(AVCodecContext *avctx, 
> aom_codec_caps_t codec_caps,
>  break;
>  case AV_PIX_FMT_YUV444P10:
>  case AV_PIX_FMT_YUV444P12:
> +case AV_PIX_FMT_GBRP10:
> +case AV_PIX_FMT_GBRP12:
>  if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
> -enccfg->g_bit_depth = enccfg->g_input_bit_depth =
> -avctx->pix_fmt == AV_PIX_FMT_YUV444P10 ? 10 : 12;
> +enccfg->g_bit_depth = enccfg->g_input_bit_depth = 10;
> +if (avctx->pix_fmt == AV_PIX_FMT_YUV444P12 ||
> +avctx->pix_fmt == AV_PIX_FMT_GBRP12)
> +enccfg->g_bit_depth = enccfg->g_input_bit_depth = 12;
>  enccfg->g_profile =
>  enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : 
> FF_PROFILE_AV1_PROFESSIONAL;
>  *img_fmt = AOM_IMG_FMT_I44416;
> @@ -749,9 +754,16 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  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);
> -codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
> +if (avctx->pix_fmt == AV_PIX_FMT_GBRP || avctx->pix_fmt == 
> AV_PIX_FMT_GBRP10 ||
> +avctx->pix_fmt == AV_PIX_FMT_GBRP12) {

It may be cleaner here and above if you instead use
av_pix_fmt_desc_get() in the function then look at desc->comp[0]->depth
for bitdepth and and desc->flags & AV_PIX_FMT_FLAG_RGB for RGB, instead
of all these if checks for a dozen pixfmts.

Should be ok either way.

> +codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);
> +codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);
> +codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, 
> AVCOL_TRC_IEC61966_2_1);
> +} else {
> +codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, 
> avctx->color_primaries);
> +codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
> +codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, 
> avctx->color_trc);
> +}
>  if (ctx->aq_mode >= 0)
>  codecctl_int(avctx, AV1E_SET_AQ_MODE, ctx->aq_mode);
>  if (ctx->frame_parallel >= 0)
> @@ -1077,6 +1089,7 @@ static const enum AVPixelFormat av1_pix_fmts[] = {
>  AV_PIX_FMT_YUV420P,
>  AV_PIX_FMT_YUV422P,
>  AV_PIX_FMT_YUV444P,
> +AV_PIX_FMT_GBRP,
>  AV_PIX_FMT_NONE
>  };
>  
> @@ -1084,12 +1097,15 @@ static const enum AVPixelFormat av1_pix_fmts_highbd[] 
> = {
>  AV_PIX_FMT_YUV420P,
>  AV_PIX_FMT_YUV422P,
>  AV_PIX_FMT_YUV444P,
> +AV_PIX_FMT_GBRP,
>  AV_PIX_FMT_YUV420P10,
>  AV_PIX_FMT_YUV422P10,
>  AV_PIX_FMT_YUV444P10,
>  AV_PIX_FMT_YUV420P12,
>  AV_PIX_FMT_YUV422P12,
>  AV_PIX_FMT_YUV444P12,
> +AV_PIX_FMT_GBRP10,
> +AV_PIX_FMT_GBRP12,
>  AV_PIX_FMT_NONE
>  };
>  
> -- 
> 2.28.0.rc0
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@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/hls: add supporting EXT-X-DISCONTINUITY tag

2020-07-16 Thread DW Kim
I modified setting AVFMT_TS_DISCONT flag on HLS input format depending on
whether "EXT-X-DISCONTINUITY" existed or not in M3U8.
previous, commits is set AVFMT_TS_DISCONT flag unconditionally, whether
"EXT-X-DISCONTINUITY" existed or not, as below
https://github.com/FFmpeg/FFmpeg/commit/d6ac6650b911f0957e69545d7fc25be6b7728705#diff-0e876d29bdcae30d9d256f04bc8795db

So, I added checking and parsing "EXT-X-DISCONTINUITY" syntax, and if it
exists then set AVFMT_TS_DISCONT flag.


2020년 7월 17일 (금) 오전 9:43, 김동원님(Dongwon Kim) 님이 작성:

> Signed-off-by: Dongwon Kim 
> ---
>  libavformat/hls.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c index
> ba17c4ed96..5e331ab68f 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -810,6 +810,8 @@ static int parse_playlist(HLSContext *c, const char
> *url,
>  ff_parse_key_value(ptr, (ff_parse_key_val_cb)
> handle_rendition_args,
> &info);
>  new_rendition(c, &info, url);
> +} else if (av_strstart(line, "#EXT-X-DISCONTINUITY", &ptr)) {
> +c->ctx->iformat->flags |= AVFMT_TS_DISCONT;
>  } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
>  ret = ensure_playlist(c, &pls, url);
>  if (ret < 0)
> @@ -2406,7 +2408,7 @@ AVInputFormat ff_hls_demuxer = {
>  .long_name  = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
>  .priv_class = &hls_class,
>  .priv_data_size = sizeof(HLSContext),
> -.flags  = AVFMT_NOGENSEARCH | AVFMT_TS_DISCONT,
> +.flags  = AVFMT_NOGENSEARCH,
>  .read_probe = hls_probe,
>  .read_header= hls_read_header,
>  .read_packet= hls_read_packet,
> --
> 2.25.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avcodec/libdav1d: use av_image_get_buffer_size() to calculate frame size

2020-07-16 Thread James Almer
Calling av_image_fill_arrays() with NULL as src argument may result in UB.

Signed-off-by: James Almer 
---
It will still happen even after this patch because of the current
av_image_get_buffer_size() implementation, but will stop being the case after
the patchset by Brian Kim is applied.

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

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index bbb3ec1e6c..132d344296 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -66,12 +66,11 @@ static int libdav1d_picture_allocator(Dav1dPicture *p, void 
*cookie)
 {
 Libdav1dContext *dav1d = cookie;
 enum AVPixelFormat format = pix_fmt[p->p.layout][p->seq_hdr->hbd];
-int ret, linesize[4], h = FFALIGN(p->p.h, 128);
+int ret, linesize[4], h = FFALIGN(p->p.h, 128), w = FFALIGN(p->p.w, 128);
 uint8_t *aligned_ptr, *data[4];
 AVBufferRef *buf;
 
-ret = av_image_fill_arrays(data, linesize, NULL, format, FFALIGN(p->p.w, 
128),
-   h, DAV1D_PICTURE_ALIGNMENT);
+ret = av_image_get_buffer_size(format, w, h, DAV1D_PICTURE_ALIGNMENT);
 if (ret < 0)
 return ret;
 
@@ -94,7 +93,8 @@ static int libdav1d_picture_allocator(Dav1dPicture *p, void 
*cookie)
 // Use the extra DAV1D_PICTURE_ALIGNMENT padding bytes in the buffer to 
align it
 // if required.
 aligned_ptr = (uint8_t *)FFALIGN((uintptr_t)buf->data, 
DAV1D_PICTURE_ALIGNMENT);
-ret = av_image_fill_pointers(data, format, h, aligned_ptr, linesize);
+ret = av_image_fill_arrays(data, linesize, aligned_ptr, format, w, h,
+   DAV1D_PICTURE_ALIGNMENT);
 if (ret < 0) {
 av_buffer_unref(&buf);
 return ret;
-- 
2.27.0

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

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

Re: [FFmpeg-devel] [PATCH] avformat/hls: add supporting EXT-X-DISCONTINUITY tag

2020-07-16 Thread Andreas Rheinhardt
김동원님(Dongwon Kim):
> Signed-off-by: Dongwon Kim 
> ---
>  libavformat/hls.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c index 
> ba17c4ed96..5e331ab68f 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -810,6 +810,8 @@ static int parse_playlist(HLSContext *c, const char *url,
>  ff_parse_key_value(ptr, (ff_parse_key_val_cb) 
> handle_rendition_args,
> &info);
>  new_rendition(c, &info, url);
> +} else if (av_strstart(line, "#EXT-X-DISCONTINUITY", &ptr)) {
> +c->ctx->iformat->flags |= AVFMT_TS_DISCONT;
>  } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
>  ret = ensure_playlist(c, &pls, url);
>  if (ret < 0)
> @@ -2406,7 +2408,7 @@ AVInputFormat ff_hls_demuxer = {
>  .long_name  = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
>  .priv_class = &hls_class,
>  .priv_data_size = sizeof(HLSContext),
> -.flags  = AVFMT_NOGENSEARCH | AVFMT_TS_DISCONT,
> +.flags  = AVFMT_NOGENSEARCH,
>  .read_probe = hls_probe,
>  .read_header= hls_read_header,
>  .read_packet= hls_read_packet,
> --
> 2.25.1
> 
You are modifying the AVInputFormat, not the AVFormatContext. The former
is shared among all AVFormatContexts for hls demuxing and it is actually
meant to be const (and may become const at the next major bump).

- 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/7] Add support for encoding adpcm_ima_apm and muxing to apm.

2020-07-16 Thread Zane van Iperen
On Wed, 08 Jul 2020 12:54:46 +
"Zane van Iperen"  wrote:

> v6: [8]
> * split out header and extradata fixes
> * add more-descriptive commit messages
> * fix bit_rate overflow

Ping 2.

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

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

[FFmpeg-devel] [PATCH 2/3] avcodec/v4l2_m2m_enc: buffer frame if it cannot be enqueued

2020-07-16 Thread Andriy Gelman
From: Andriy Gelman 

Currently if the frame buffers are full, the frame is unrefed and
dropped.  Instead buffer the frame so that it is enqueued in the
following v4l2_receive_packet() call.  The behavior was observed on
DragonBoard 410c.

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_m2m.c | 1 +
 libavcodec/v4l2_m2m_enc.c | 8 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index d8d872ea099..6b545045100 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t 
*context)
 sem_destroy(&s->refsync);
 
 close(s->fd);
+av_frame_unref(s->frame);
 av_frame_free(&s->frame);
 
 av_free(s);
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 56df4286add..6d74c4c083d 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -295,16 +295,20 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
AVPacket *avpkt)
 if (s->draining)
 goto dequeue;
 
+if (!frame->buf[0]) {
 ret = ff_encode_get_frame(avctx, frame);
 if (ret < 0 && ret != AVERROR_EOF)
 return ret;
 
 if (ret == AVERROR_EOF)
 frame = NULL;
+}
 
 ret = v4l2_send_frame(avctx, frame);
-av_frame_unref(frame);
-if (ret < 0)
+if (ret != AVERROR(EAGAIN))
+av_frame_unref(frame);
+
+if (ret < 0 && ret != AVERROR(EAGAIN))
 return ret;
 
 if (!output->streamon) {
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 3/3] avcodec/v4l2_m2m_enc: reindent after previous commit

2020-07-16 Thread Andriy Gelman
From: Andriy Gelman 

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_m2m_enc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 6d74c4c083d..6e18217c35f 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -296,12 +296,12 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
AVPacket *avpkt)
 goto dequeue;
 
 if (!frame->buf[0]) {
-ret = ff_encode_get_frame(avctx, frame);
-if (ret < 0 && ret != AVERROR_EOF)
-return ret;
+ret = ff_encode_get_frame(avctx, frame);
+if (ret < 0 && ret != AVERROR_EOF)
+return ret;
 
-if (ret == AVERROR_EOF)
-frame = NULL;
+if (ret == AVERROR_EOF)
+frame = NULL;
 }
 
 ret = v4l2_send_frame(avctx, frame);
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 1/3] avcodec/v4l2_context: return EAGAIN to signal full buffers

2020-07-16 Thread Andriy Gelman
From: Andriy Gelman 

Return proper error when a frame buffers are full. This path is
triggered on the DragonBoard 410c since the encoding API change in
commit 827d6fe73d2f5472c1c2.

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index 29b144ed73e..ff1ea8e57b0 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -599,7 +599,7 @@ int ff_v4l2_context_enqueue_frame(V4L2Context* ctx, const 
AVFrame* frame)
 
 avbuf = v4l2_getfree_v4l2buf(ctx);
 if (!avbuf)
-return AVERROR(ENOMEM);
+return AVERROR(EAGAIN);
 
 ret = ff_v4l2_buffer_avframe_to_buf(frame, avbuf);
 if (ret)
-- 
2.27.0

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

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

Re: [FFmpeg-devel] [PATCH v5] avdevice/xcbgrab: check return values of xcb query functions

2020-07-16 Thread Andriy Gelman
On Tue, 14. Jul 14:14, Moritz Barsnick wrote:
> On Sun, Jul 12, 2020 at 10:54:45 -0400, Andriy Gelman wrote:
> > On Fri, 10. Jul 21:13, Moritz Barsnick wrote:
> > > Since xcbgrab is getting some attention recently...
> > >
> > > Fixes a segfault, as reported in #7312.
> > >
> > > To reproduce:
> > > Terminal 1:
> > > $ Xvfb :1 -nolisten tcp -screen 0 800x600x24
> > > Terminal 2:
> > > $ ffmpeg -f x11grab -i :1 -f null -
> > > or rather
> > > $ gdb -ex r --args ffmpeg_g -f x11grab -i :1 -f null -
> > > Then terminate Xvfb while ffmpeg is running.
> >
> > The rest of the av_log calls use AVFormatContext*.
> > You may want to update to be consistent.
> 
> Good point. I didn't mind the "xcbgrab indev" vs. "x11grab", but it's
> indeed inconsistent. Updated patch attached.
> 
> Moritz

> From 269b43209394c0eceb83f5ae384792c32305333a Mon Sep 17 00:00:00 2001
> From: Moritz Barsnick 
> Date: Tue, 14 Jul 2020 14:07:33 +0200
> Subject: [PATCH] avdevice/xcbgrab: check return values of xcb query functions
> 
> Fixes #7312, segmentation fault on close of X11 server
> 
> xcb_query_pointer_reply() and xcb_get_geometry_reply() can return NULL
> if e.g. the X server closes or the connection is lost. This needs to
> be checked in order to cleanly exit, because the returned pointers are
> dereferenced later.
> 
> Furthermore, their return values need to be free()d, also in error
> code paths.
> 
> Signed-off-by: Moritz Barsnick 
> ---
>  libavdevice/xcbgrab.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
> index 6f6b2dbf15..8bc320d055 100644
> --- a/libavdevice/xcbgrab.c
> +++ b/libavdevice/xcbgrab.c
> @@ -346,8 +346,10 @@ static void xcbgrab_draw_mouse(AVFormatContext *s, 
> AVPacket *pkt,
>  return;
> 

>  cursor = xcb_xfixes_get_cursor_image_cursor_image(ci);
> -if (!cursor)
> +if (!cursor) {
> +free(ci);
>  return;
> +}

This check seems dead code. Looking at xcb sources, cursor is just an offset in
memory from ci so I don't think it can be null here.

> 
>  cx = ci->x - ci->xhot;
>  cy = ci->y - ci->yhot;
> @@ -425,7 +427,16 @@ static int xcbgrab_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  pc  = xcb_query_pointer(c->conn, c->screen->root);
>  gc  = xcb_get_geometry(c->conn, c->screen->root);
>  p   = xcb_query_pointer_reply(c->conn, pc, NULL);

> +if (!p) {
> +av_log(s, AV_LOG_ERROR, "Failed to query xcb pointer\n");
> +return AVERROR_EXTERNAL;
> +}
>  geo = xcb_get_geometry_reply(c->conn, gc, NULL);
> +if (!geo) {
> +av_log(s, AV_LOG_ERROR, "Failed to get xcb geometry\n");
> +free(p);
> +return AVERROR_EXTERNAL;
> +}

This part lgtm.

Btw, when I was testing with -draw_mouse 0, there were no error messages when 
the
X server was killed. We should probably also test if img==NULL after:

img = xcb_get_image_reply(c->conn, iq, &e);

But this is different patch imo.

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

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