Re: [FFmpeg-devel] [PATCH v2 2/3] libavcodec: add a new AV_CODEC_EXPORT_DATA_FILM_GRAIN flag and option

2020-11-15 Thread Anton Khirnov
Quoting Lynne (2020-11-14 15:32:35)
> Nov 14, 2020, 11:23 by an...@khirnov.net:
> 
> > Quoting Lynne (2020-11-12 18:42:22)
> >
> >> This introduces a new field to allow decoders to export their film grain 
> >> parameters.
> >> Will be used by the next patch.
> >>
> >> Patch attached.
> >> From d5d5e1e5f90938ac5cfa462efc13658ab411246b Mon Sep 17 00:00:00 2001
> >> From: Lynne 
> >> Date: Thu, 12 Nov 2020 17:46:09 +0100
> >> Subject: [PATCH v2 2/3] libavcodec: add a new 
> >> AV_CODEC_EXPORT_DATA_FILM_GRAIN
> >>  flag and option
> >>
> >> This introduces a new field to allow decoders to export their film grain
> >> parameters.
> >> Will be used by the next patch.
> >> ---
> >>  doc/APIchanges | 3 +++
> >>  libavcodec/avcodec.h   | 5 +
> >>  libavcodec/options_table.h | 1 +
> >>  libavcodec/version.h   | 4 ++--
> >>  4 files changed, 11 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/doc/APIchanges b/doc/APIchanges
> >> index 41248724d9..9d0ddb4ff6 100644
> >> --- a/doc/APIchanges
> >> +++ b/doc/APIchanges
> >> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
> >>  
> >>  API changes, most recent first:
> >>  
> >> +2020-xx-xx - xx - lavc 58.113.100 - avcodec.h
> >> +  Adds a new flag AV_CODEC_EXPORT_DATA_FILM_GRAIN for export_side_data.
> >> +
> >>  2020-xx-xx - xx - lavu 56.61.100 - film_grain_params.h
> >>  Adds a new API for extracting codec film grain parameters as side data.
> >>  Adds a new AVFrameSideDataType entry AV_FRAME_DATA_FILM_GRAIN_PARAMS for 
> >> it.
> >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> >> index 20af3ef00d..5047da0f6a 100644
> >> --- a/libavcodec/avcodec.h
> >> +++ b/libavcodec/avcodec.h
> >> @@ -410,6 +410,11 @@ typedef struct RcOverride{
> >>  * Export the AVVideoEncParams structure through frame side data.
> >>  */
> >>  #define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS (1 << 2)
> >> +/**
> >> + * Decoding only.
> >> + * Do not apply film grain, export it instead.
> >>
> >
> > Could someone want to both apply AND export it?
> >
> 
> Analyzers. In which case they could use a film grain filter to apply it. But 
> that's a fringe
> use-case for this flag, this mainly targets video players and transcoding, 
> where the
> bandwidth/frames savings can be significant.
> There's a WIP Vulkan filter to apply it, and if there's popular demand, the 
> libdav1d code
> could be ported as a software filter.

Then the documentation should allow for applying and exporting.
Also, this flag is supposed to just trigger exporting some metadata, I
am not very comfortable with it changing decoder output.

What's the current status of film grain across the various sw/hw
decoders we have? IIUC some apply it transparently, some don't?
Should there be a way for the user to check?
And/or a common option for "do not apply/apply (if possible)/auto (apply
if export not requested)"?

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

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

Re: [FFmpeg-devel] [PATCH 5/7] avformat/wavdec: Avoid zeroing written to array

2020-11-15 Thread Anton Khirnov
Quoting Michael Niedermayer (2020-11-16 01:05:07)
> On Sat, Nov 14, 2020 at 11:12:15AM +0100, Anton Khirnov wrote:
> > Quoting Michael Niedermayer (2020-11-10 00:04:54)
> > > Fixes: OOM
> > > Fixes: 
> > > 26934/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5996784213819392
> > > 
> > > Found-by: continuous fuzzing process 
> > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavformat/wavdec.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> > > index a81f2c7a67..6e5f4ccc12 100644
> > > --- a/libavformat/wavdec.c
> > > +++ b/libavformat/wavdec.c
> > > @@ -920,7 +920,7 @@ static int w64_read_header(AVFormatContext *s)
> > >  if (chunk_size == UINT32_MAX || (filesize >= 0 && 
> > > chunk_size > filesize))
> > >  return AVERROR_INVALIDDATA;
> > >  
> > > -value = av_mallocz(chunk_size + 1);
> > > +value = av_malloc(chunk_size + 1);
> > 
> > This looks highly suspicious as a fix for anything other than
> > performance.
> 
> if iam not mistaken:
> The allocation doesnzt trigger OOM as no physical memory is allocated
> but once it is written to "z" it does and then OOMs
> if OTOH its written too while data is read from somewhere then a
> EOF ends writing and no OOM would happen

That is highly dependent on your OS and its configuration (e.g. you can
disable overcommit on Linux).

Also, there seems to be a check right above that fails if chunk_size is
larger than the file size.

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

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

Re: [FFmpeg-devel] [PATCH 10/18] lavf: move AVStream.*index_entries* to AVStreamInternal

2020-11-15 Thread Anton Khirnov
Quoting Xiang, Haihao (2020-11-16 06:16:55)
> 
> This change breaks the compiling of gst-libav (
> https://gitlab.freedesktop.org/gstreamer/gst-libav), I filed  
> https://trac.ffmpeg.org/ticket/8988 to track this regression.

This is not a regression, it's a bug in gst-libav. These fields are
private and have always been private, applications accessing them are
broken.

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

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

Re: [FFmpeg-devel] [PATCH 10/18] lavf: move AVStream.*index_entries* to AVStreamInternal

2020-11-15 Thread Xiang, Haihao

This change breaks the compiling of gst-libav (
https://gitlab.freedesktop.org/gstreamer/gst-libav), I filed  
https://trac.ffmpeg.org/ticket/8988 to track this regression.

Thanks
Haihao


> Those are private fields, no reason to have them exposed in a public
> header. Since there are some (semi-)public fields located after these,
> even though this section is supposed to be private, keep some dummy
> padding there until the next major bump to preserve ABI compatibility.
> ---
>  libavformat/ape.c |   2 +-
>  libavformat/asfdec_f.c|   4 +-
>  libavformat/asfdec_o.c|   6 +-
>  libavformat/avformat.h|  10 +-
>  libavformat/avidec.c  | 100 ++--
>  libavformat/bink.c|  10 +-
>  libavformat/cafdec.c  |  22 ++---
>  libavformat/cinedec.c |   2 +-
>  libavformat/dhav.c|   4 +-
>  libavformat/flacdec.c |   8 +-
>  libavformat/flic.c|   6 +-
>  libavformat/flvdec.c  |  10 +-
>  libavformat/gxf.c |   6 +-
>  libavformat/ifv.c |   8 +-
>  libavformat/img2dec.c |   2 +-
>  libavformat/internal.h|   5 +
>  libavformat/jvdec.c   |  28 +++---
>  libavformat/matroskadec.c |  40 
>  libavformat/mlvdec.c  |  20 ++--
>  libavformat/mov.c | 190 +++---
>  libavformat/mp3dec.c  |   6 +-
>  libavformat/mpc.c |   4 +-
>  libavformat/mpc8.c|   4 +-
>  libavformat/mux.c |   2 +-
>  libavformat/mvdec.c   |   4 +-
>  libavformat/nsvdec.c  |   4 +-
>  libavformat/nutdec.c  |   6 +-
>  libavformat/nutenc.c  |  12 +--
>  libavformat/rl2.c |   8 +-
>  libavformat/rpl.c |   4 +-
>  libavformat/segafilm.c|   2 +-
>  libavformat/tta.c |   8 +-
>  libavformat/utils.c   |  46 -
>  libavformat/vocdec.c  |   8 +-
>  34 files changed, 304 insertions(+), 297 deletions(-)
> 
> diff --git a/libavformat/ape.c b/libavformat/ape.c
> index d92cb2867d..33b7237fb0 100644
> --- a/libavformat/ape.c
> +++ b/libavformat/ape.c
> @@ -469,7 +469,7 @@ static int ape_read_seek(AVFormatContext *s, int
> stream_index, int64_t timestamp
>  if (index < 0)
>  return -1;
>  
> -if ((ret = avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET)) < 0)
> +if ((ret = avio_seek(s->pb, st->internal->index_entries[index].pos,
> SEEK_SET)) < 0)
>  return ret;
>  ape->currentframe = index;
>  return 0;
> diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
> index b92434db9e..deb7c266ed 100644
> --- a/libavformat/asfdec_f.c
> +++ b/libavformat/asfdec_f.c
> @@ -1678,11 +1678,11 @@ static int asf_read_seek(AVFormatContext *s, int
> stream_index,
>  asf->index_read = -1;
>  }
>  
> -if (asf->index_read > 0 && st->index_entries) {
> +if (asf->index_read > 0 && st->internal->index_entries) {
>  int index = av_index_search_timestamp(st, pts, flags);
>  if (index >= 0) {
>  /* find the position */
> -uint64_t pos = st->index_entries[index].pos;
> +uint64_t pos = st->internal->index_entries[index].pos;
>  
>  /* do the seek */
>  av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
> diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
> index 1b10e47907..b142f83541 100644
> --- a/libavformat/asfdec_o.c
> +++ b/libavformat/asfdec_o.c
> @@ -1640,11 +1640,11 @@ static int asf_read_seek(AVFormatContext *s, int
> stream_index,
>  ASFContext *asf = s->priv_data;
>  int idx, ret;
>  
> -if (s->streams[stream_index]->nb_index_entries && asf->is_simple_index) {
> +if (s->streams[stream_index]->internal->nb_index_entries && asf-
> >is_simple_index) {
>  idx = av_index_search_timestamp(s->streams[stream_index], timestamp,
> flags);
> -if (idx < 0 || idx >= s->streams[stream_index]->nb_index_entries)
> +if (idx < 0 || idx >= s->streams[stream_index]->internal-
> >nb_index_entries)
>  return AVERROR_INVALIDDATA;
> -avio_seek(s->pb, s->streams[stream_index]->index_entries[idx].pos,
> SEEK_SET);
> +avio_seek(s->pb, s->streams[stream_index]->internal-
> >index_entries[idx].pos, SEEK_SET);
>  } else {
>  if ((ret = ff_seek_frame_binary(s, stream_index, timestamp, flags)) <
> 0)
>  return ret;
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 1253021452..dbef1b21dd 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1065,10 +1065,12 @@ typedef struct AVStream {
>  #define MAX_REORDER_DELAY 16
>  int64_t pts_buffer[MAX_REORDER_DELAY+1];
>  
> -AVIndexEntry *index_entries; /**< Only used if the format does not
> -support seeking natively. */
> -int nb_index_entries;
> -unsigned int index_entries_allocated_size;
> +#if LIBAVFORMAT_VERSION_MAJOR < 59
> +// kept for ABI compatibility only, do not access in any way
> +

[FFmpeg-devel] [PATCH v2] nv-codec-headers: add cuMemcpy

2020-11-15 Thread leozhang
Signed-off-by: leozhang 
---
 include/ffnvcodec/dynlink_cuda.h   | 2 ++
 include/ffnvcodec/dynlink_loader.h | 4 
 2 files changed, 6 insertions(+)

diff --git a/include/ffnvcodec/dynlink_cuda.h b/include/ffnvcodec/dynlink_cuda.h
index 117fdc5..baafa49 100644
--- a/include/ffnvcodec/dynlink_cuda.h
+++ b/include/ffnvcodec/dynlink_cuda.h
@@ -365,6 +365,8 @@ typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, 
size_t bytesize);
 typedef CUresult CUDAAPI tcuMemAllocPitch_v2(CUdeviceptr *dptr, size_t 
*pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes);
 typedef CUresult CUDAAPI tcuMemsetD8Async(CUdeviceptr dstDevice, unsigned char 
uc, size_t N, CUstream hStream);
 typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr);
+typedef CUresult CUDAAPI tcuMemcpy(CUdeviceptr dst, CUdeviceptr src, size_t 
bytesize);
+typedef CUresult CUDAAPI tcuMemcpyAsync(CUdeviceptr dst, CUdeviceptr src, 
size_t bytesize, CUstream hStream);
 typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy);
 typedef CUresult CUDAAPI tcuMemcpy2DAsync_v2(const CUDA_MEMCPY2D *pcopy, 
CUstream hStream);
 typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr);
diff --git a/include/ffnvcodec/dynlink_loader.h 
b/include/ffnvcodec/dynlink_loader.h
index b9995c3..85aebf4 100644
--- a/include/ffnvcodec/dynlink_loader.h
+++ b/include/ffnvcodec/dynlink_loader.h
@@ -152,6 +152,8 @@ typedef struct CudaFunctions {
 tcuMemAllocPitch_v2 *cuMemAllocPitch;
 tcuMemsetD8Async *cuMemsetD8Async;
 tcuMemFree_v2 *cuMemFree;
+tcuMemcpy *cuMemcpy;
+tcuMemcpyAsync *cuMemcpyAsync;
 tcuMemcpy2D_v2 *cuMemcpy2D;
 tcuMemcpy2DAsync_v2 *cuMemcpy2DAsync;
 tcuGetErrorName *cuGetErrorName;
@@ -290,6 +292,8 @@ static inline int cuda_load_functions(CudaFunctions 
**functions, void *logctx)
 LOAD_SYMBOL(cuMemAllocPitch, tcuMemAllocPitch_v2, "cuMemAllocPitch_v2");
 LOAD_SYMBOL(cuMemsetD8Async, tcuMemsetD8Async, "cuMemsetD8Async");
 LOAD_SYMBOL(cuMemFree, tcuMemFree_v2, "cuMemFree_v2");
+LOAD_SYMBOL(cuMemcpy, tcuMemcpy, "cuMemcpy");
+LOAD_SYMBOL(cuMemcpyAsync, tcuMemcpyAsync, "cuMemcpyAsync");
 LOAD_SYMBOL(cuMemcpy2D, tcuMemcpy2D_v2, "cuMemcpy2D_v2");
 LOAD_SYMBOL(cuMemcpy2DAsync, tcuMemcpy2DAsync_v2, "cuMemcpy2DAsync_v2");
 LOAD_SYMBOL(cuGetErrorName, tcuGetErrorName, "cuGetErrorName");
-- 
2.11.0

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

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

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

2020-11-15 Thread Mohammad Izadi
From: Mohammad Izadi 

HDR10+ is dynamic metadata (A/341 Amendment - SMPTE2094-40) that needs to be 
decoded from ITU-T T.35 in HEVC bitstream. The HDR10+ is transferred to side 
data packet to be used or passed through.
---
The fate test file can be found here: 
https://drive.google.com/file/d/1Hadzc24-RsgnRqS-B0bxLmzDeTwEOhtE/view?usp=sharing

The video file needs to be copied to fate-suite/mov/

 configure |   1 +
 fftools/ffprobe.c | 106 +
 libavcodec/Makefile   |   3 +
 libavcodec/avpacket.c |   1 +
 libavcodec/decode.c   |   1 +
 libavcodec/dynamic_hdr10_plus.c   | 223 ++
 .../dynamic_hdr10_plus.h  |  22 +-
 libavcodec/hevc_sei.c |  62 -
 libavcodec/hevc_sei.h |   5 +
 libavcodec/hevcdec.c  |  18 ++
 libavcodec/packet.h   |   8 +
 libavcodec/version.h  |   2 +-
 libavfilter/vf_showinfo.c | 106 -
 libavutil/Makefile|   2 -
 libavutil/hdr_dynamic_metadata.c  |  47 
 tests/fate/mov.mak|   3 +
 tests/ref/fate/mov-hdr10-plus-metadata|  90 +++
 17 files changed, 629 insertions(+), 71 deletions(-)
 create mode 100644 libavcodec/dynamic_hdr10_plus.c
 rename libavutil/hdr_dynamic_metadata.h => libavcodec/dynamic_hdr10_plus.h 
(95%)
 delete mode 100644 libavutil/hdr_dynamic_metadata.c
 create mode 100644 tests/ref/fate/mov-hdr10-plus-metadata

diff --git a/configure b/configure
index 51e43fbf66..a9f12a421e 100755
--- a/configure
+++ b/configure
@@ -2360,6 +2360,7 @@ CONFIG_EXTRA="
 dirac_parse
 dnn
 dvprofile
+dynamic_hdr10_plus
 exif
 faandct
 faanidct
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 86bd23d36d..4cee4e8ec3 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -35,6 +35,7 @@
 #include "libavutil/bprint.h"
 #include "libavutil/display.h"
 #include "libavutil/hash.h"
+#include "libavutil/hdr_dynamic_metadata.h"
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/dovi_meta.h"
 #include "libavutil/opt.h"
@@ -1860,6 +1861,105 @@ static inline int show_tags(WriterContext *w, 
AVDictionary *tags, int section_id
 return ret;
 }
 
+static void print_dynamic_hdr10_plus(WriterContext *w, AVDynamicHDRPlus 
*metadata)
+{
+if (!metadata)
+return;
+print_int("application version", metadata->application_version);
+print_int("num_windows", metadata->num_windows);
+for (int n = 1; n < metadata->num_windows; n++) {
+AVHDRPlusColorTransformParams *params = >params[n];
+print_q("window_upper_left_corner_x",
+params->window_upper_left_corner_x,'/');
+print_q("window_upper_left_corner_y",
+params->window_upper_left_corner_y,'/');
+print_q("window_lower_right_corner_x",
+params->window_lower_right_corner_x,'/');
+print_q("window_lower_right_corner_y",
+params->window_lower_right_corner_y,'/');
+print_q("window_upper_left_corner_x",
+params->window_upper_left_corner_x,'/');
+print_q("window_upper_left_corner_y",
+params->window_upper_left_corner_y,'/');
+print_int("center_of_ellipse_x",
+  params->center_of_ellipse_x ) ;
+print_int("center_of_ellipse_y",
+  params->center_of_ellipse_y );
+print_int("rotation_angle",
+  params->rotation_angle);
+print_int("semimajor_axis_internal_ellipse",
+  params->semimajor_axis_internal_ellipse);
+print_int("semimajor_axis_external_ellipse",
+  params->semimajor_axis_external_ellipse);
+print_int("semiminor_axis_external_ellipse",
+  params->semiminor_axis_external_ellipse);
+print_int("overlap_process_option",
+  params->overlap_process_option);
+}
+print_q("targeted_system_display_maximum_luminance",
+metadata->targeted_system_display_maximum_luminance,'/');
+if (metadata->targeted_system_display_actual_peak_luminance_flag) {
+print_int("num_rows_targeted_system_display_actual_peak_luminance",
+  
metadata->num_rows_targeted_system_display_actual_peak_luminance);
+print_int("num_cols_targeted_system_display_actual_peak_luminance",
+  
metadata->num_cols_targeted_system_display_actual_peak_luminance);
+for (int i = 0; i < 
metadata->num_rows_targeted_system_display_actual_peak_luminance; i++) {
+for (int j = 0; j < 
metadata->num_cols_targeted_system_display_actual_peak_luminance; j++) {
+print_q("targeted_system_display_actual_peak_luminance",
+ 

Re: [FFmpeg-devel] [PATCH 100/114] avcodec/vp3: Use symbols table for VP3 motion vectors

2020-11-15 Thread Peter Ross
On Sun, Nov 15, 2020 at 06:37:25AM +0100, Andreas Rheinhardt wrote:
> Peter Ross:
> > On Tue, Nov 10, 2020 at 11:58:22AM +0100, Andreas Rheinhardt wrote:
> >> Expressions like array[get_vlc2()] can be optimized by using a symbols
> >> table if the array is always the same for a given VLC. This requirement
> >> is fulfilled for the VLC used for VP3 motion vectors. The reason it
> >> hasn't been done before is probably that the array in this case
> >> contained entries in the range -31..31; but this is no problem with
> >> ff_init_vlc_from_lengths(): Just apply an offset of 31 to the symbols
> >> before storing them in the table used to initialize VP3 motion vectors
> >> and apply an offset of -31 when initializing the actual VLC.
> >>
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >>  libavcodec/vp3.c | 20 ---
> >>  libavcodec/vp3data.h | 46 +++-
> >>  2 files changed, 24 insertions(+), 42 deletions(-)
> >>
> >> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> >> index 7037d03a98..f288a53fe1 100644
> >> --- a/libavcodec/vp3.c
> >> +++ b/libavcodec/vp3.c
> >> @@ -48,6 +48,7 @@
> >>  #include "vp3dsp.h"
> >>  #include "xiph.h"
> >>  
> >> +#define VP3_MV_VLC_BITS 6
> >>  #define VP4_MV_VLC_BITS 6
> >>  #define SUPERBLOCK_VLC_BITS 6
> > 
> > or just use '#define MV_VLC_BITS 6'
> > 
> This patch has to modify all the lines that use the motion_vector_vlc
> VLC table, so using a named constant can be easily done while at it;
> this is no longer true when also changing VP4. Furthermore, there is no
> a-priori reason why it should forever be so that both of these are six
> (the longest VP3 MV code is only eight bits long, which is not
> excessive; I pondered changing it, but decided that it is outside the
> remit of this patchset).

I agree with your reasoning. Cheers,

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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] nv-codec-headers: add cuMemcpy

2020-11-15 Thread leozhang
Timo Rothenpieler  于2020年11月13日周五 下午8:20写道:
>
> Please also add cuMemcpyAsync while at it.
Will add it.
>
> What for and where is this needed?
cuMemcpy is used to copy 1D array between host and device. For
example, the gauss blur filter weights can be calculated by CPU, then
memcpy to device memory, and futher load to shared memory to later
use. It's much speed up then calculating duplicated weights by per GPU
thread.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 4/4 v3] avcodec/av1dec: add an option to select an operating point

2020-11-15 Thread James Almer

On 11/15/2020 6:55 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  doc/decoders.texi   | 13 +
  libavcodec/av1dec.c | 30 ++
  libavcodec/av1dec.h |  4 
  3 files changed, 47 insertions(+)

diff --git a/doc/decoders.texi b/doc/decoders.texi
index bfab562fb2..27c6ba4a5d 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -25,6 +25,19 @@ enabled decoders.
  A description of some of the currently available video decoders
  follows.
  
+@section av1

+
+AOMedia Video 1 (AV1) decoder.
+
+@subsection Options
+
+@table @option
+
+@item operating_point
+Select an operating point of a scalable AV1 bitstream (0 - 31). Default is 0.
+
+@end table
+
  @section rawvideo
  
  Raw video decoder.

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index c1967f03bd..b7ee307159 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -19,6 +19,7 @@
   */
  
  #include "libavutil/pixdesc.h"

+#include "libavutil/opt.h"
  #include "avcodec.h"
  #include "av1dec.h"
  #include "bytestream.h"
@@ -615,6 +616,8 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
  if (ret < 0)
  return ret;
  
+av_opt_set_int(s->cbc->priv_data, "operating_point", s->operating_point, 0);

+
  if (avctx->extradata && avctx->extradata_size) {
  ret = ff_cbs_read(s->cbc, >current_obu, avctx->extradata,
avctx->extradata_size);
@@ -704,6 +707,11 @@ static int set_output_frame(AVCodecContext *avctx, AVFrame 
*frame,
  const AVFrame *srcframe = s->cur_frame.tf.f;
  int ret;
  
+// TODO: all layers

+if (s->operating_point_idc &&
+av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id)
+return 0;
+
  ret = av_frame_ref(frame, srcframe);
  if (ret < 0)
  return ret;
@@ -809,6 +817,8 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
  goto end;
  }
  
+s->operating_point_idc = s->raw_seq->operating_point_idc[s->operating_point];

+
  if (s->pix_fmt == AV_PIX_FMT_NONE) {
  ret = get_pixel_format(avctx);
  if (ret < 0) {
@@ -888,6 +898,9 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
  s->cur_frame.spatial_id  = header->spatial_id;
  s->cur_frame.temporal_id = header->temporal_id;
  
+s->cur_frame.spatial_id  = header->spatial_id;

+s->cur_frame.temporal_id = header->temporal_id;


Removed this locally for obvious reasons, seeing the lines immediately 
above them...



+
  if (avctx->hwaccel) {
  ret = avctx->hwaccel->start_frame(avctx, unit->data,
unit->data_size);
@@ -979,12 +992,28 @@ static void av1_decode_flush(AVCodecContext *avctx)
  av1_frame_unref(avctx, >ref[i]);
  
  av1_frame_unref(avctx, >cur_frame);

+s->operating_point_idc = 0;
  s->raw_frame_header = NULL;
  s->raw_seq = NULL;
  
  ff_cbs_flush(s->cbc);

  }
  
+#define OFFSET(x) offsetof(AV1DecContext, x)

+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+static const AVOption av1_options[] = {
+{ "operating_point",  "Select an operating point of the scalable 
bitstream",
+  OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, AV1_MAX_OPERATING_POINTS - 1, VD },
+{ NULL }
+};
+
+static const AVClass av1_class = {
+.class_name = "AV1 decoder",
+.item_name  = av_default_item_name,
+.option = av1_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
  AVCodec ff_av1_decoder = {
  .name  = "av1",
  .long_name = NULL_IF_CONFIG_SMALL("Alliance for Open Media 
AV1"),
@@ -1000,6 +1029,7 @@ AVCodec ff_av1_decoder = {
   FF_CODEC_CAP_SETS_PKT_DTS,
  .flush = av1_decode_flush,
  .profiles  = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
+.priv_class= _class,
  .hw_configs= (const AVCodecHWConfigInternal * []) {
  #if CONFIG_AV1_DXVA2_HWACCEL
  HWACCEL_DXVA2(av1),
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 4b218f64bb..70414c9ca3 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -74,9 +74,13 @@ typedef struct AV1DecContext {
  uint16_t tg_start;
  uint16_t tg_end;
  
+int operating_point_idc;

+
  AV1Frame ref[AV1_NUM_REF_FRAMES];
  AV1Frame cur_frame;
  
+// AVOptions

+int operating_point;
  } AV1DecContext;
  
  #endif /* AVCODEC_AV1DEC_H */




___
ffmpeg-devel mailing list
ffmpeg-devel@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 5/7] avformat/wavdec: Avoid zeroing written to array

2020-11-15 Thread Michael Niedermayer
On Sat, Nov 14, 2020 at 11:12:15AM +0100, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2020-11-10 00:04:54)
> > Fixes: OOM
> > Fixes: 
> > 26934/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5996784213819392
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/wavdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> > index a81f2c7a67..6e5f4ccc12 100644
> > --- a/libavformat/wavdec.c
> > +++ b/libavformat/wavdec.c
> > @@ -920,7 +920,7 @@ static int w64_read_header(AVFormatContext *s)
> >  if (chunk_size == UINT32_MAX || (filesize >= 0 && 
> > chunk_size > filesize))
> >  return AVERROR_INVALIDDATA;
> >  
> > -value = av_mallocz(chunk_size + 1);
> > +value = av_malloc(chunk_size + 1);
> 
> This looks highly suspicious as a fix for anything other than
> performance.

if iam not mistaken:
The allocation doesnzt trigger OOM as no physical memory is allocated
but once it is written to "z" it does and then OOMs
if OTOH its written too while data is read from somewhere then a
EOF ends writing and no OOM would happen

thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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

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

[FFmpeg-devel] [PATCH 4/4 v3] avcodec/av1dec: add an option to select an operating point

2020-11-15 Thread James Almer
Signed-off-by: James Almer 
---
 doc/decoders.texi   | 13 +
 libavcodec/av1dec.c | 30 ++
 libavcodec/av1dec.h |  4 
 3 files changed, 47 insertions(+)

diff --git a/doc/decoders.texi b/doc/decoders.texi
index bfab562fb2..27c6ba4a5d 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -25,6 +25,19 @@ enabled decoders.
 A description of some of the currently available video decoders
 follows.
 
+@section av1
+
+AOMedia Video 1 (AV1) decoder.
+
+@subsection Options
+
+@table @option
+
+@item operating_point
+Select an operating point of a scalable AV1 bitstream (0 - 31). Default is 0.
+
+@end table
+
 @section rawvideo
 
 Raw video decoder.
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index c1967f03bd..b7ee307159 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -19,6 +19,7 @@
  */
 
 #include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
 #include "avcodec.h"
 #include "av1dec.h"
 #include "bytestream.h"
@@ -615,6 +616,8 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
+av_opt_set_int(s->cbc->priv_data, "operating_point", s->operating_point, 
0);
+
 if (avctx->extradata && avctx->extradata_size) {
 ret = ff_cbs_read(s->cbc, >current_obu, avctx->extradata,
   avctx->extradata_size);
@@ -704,6 +707,11 @@ static int set_output_frame(AVCodecContext *avctx, AVFrame 
*frame,
 const AVFrame *srcframe = s->cur_frame.tf.f;
 int ret;
 
+// TODO: all layers
+if (s->operating_point_idc &&
+av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id)
+return 0;
+
 ret = av_frame_ref(frame, srcframe);
 if (ret < 0)
 return ret;
@@ -809,6 +817,8 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
 goto end;
 }
 
+s->operating_point_idc = 
s->raw_seq->operating_point_idc[s->operating_point];
+
 if (s->pix_fmt == AV_PIX_FMT_NONE) {
 ret = get_pixel_format(avctx);
 if (ret < 0) {
@@ -888,6 +898,9 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
 s->cur_frame.spatial_id  = header->spatial_id;
 s->cur_frame.temporal_id = header->temporal_id;
 
+s->cur_frame.spatial_id  = header->spatial_id;
+s->cur_frame.temporal_id = header->temporal_id;
+
 if (avctx->hwaccel) {
 ret = avctx->hwaccel->start_frame(avctx, unit->data,
   unit->data_size);
@@ -979,12 +992,28 @@ static void av1_decode_flush(AVCodecContext *avctx)
 av1_frame_unref(avctx, >ref[i]);
 
 av1_frame_unref(avctx, >cur_frame);
+s->operating_point_idc = 0;
 s->raw_frame_header = NULL;
 s->raw_seq = NULL;
 
 ff_cbs_flush(s->cbc);
 }
 
+#define OFFSET(x) offsetof(AV1DecContext, x)
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+static const AVOption av1_options[] = {
+{ "operating_point",  "Select an operating point of the scalable 
bitstream",
+  OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, AV1_MAX_OPERATING_POINTS - 1, VD },
+{ NULL }
+};
+
+static const AVClass av1_class = {
+.class_name = "AV1 decoder",
+.item_name  = av_default_item_name,
+.option = av1_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVCodec ff_av1_decoder = {
 .name  = "av1",
 .long_name = NULL_IF_CONFIG_SMALL("Alliance for Open Media 
AV1"),
@@ -1000,6 +1029,7 @@ AVCodec ff_av1_decoder = {
  FF_CODEC_CAP_SETS_PKT_DTS,
 .flush = av1_decode_flush,
 .profiles  = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
+.priv_class= _class,
 .hw_configs= (const AVCodecHWConfigInternal * []) {
 #if CONFIG_AV1_DXVA2_HWACCEL
 HWACCEL_DXVA2(av1),
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 4b218f64bb..70414c9ca3 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -74,9 +74,13 @@ typedef struct AV1DecContext {
 uint16_t tg_start;
 uint16_t tg_end;
 
+int operating_point_idc;
+
 AV1Frame ref[AV1_NUM_REF_FRAMES];
 AV1Frame cur_frame;
 
+// AVOptions
+int operating_point;
 } AV1DecContext;
 
 #endif /* AVCODEC_AV1DEC_H */
-- 
2.29.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/4 v2] avcodec/cbs: allow cbs_read_fragment_content() to discard units

2020-11-15 Thread James Almer
The caller may not need all units in a fragment in reading only scenarios. They
could in fact alter global state stored in the private CodedBitstreamType
fields in an undesirable way.
And unlike preventing decomposition of units, discarding can be done based on
parsed values within the unit.

Signed-off-by: James Almer 
---
 libavcodec/cbs.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index c7afccd6f5..f4312d199b 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -202,6 +202,12 @@ static int cbs_read_fragment_content(CodedBitstreamContext 
*ctx,
 av_log(ctx->log_ctx, AV_LOG_VERBOSE,
"Decomposition unimplemented for unit %d "
"(type %"PRIu32").\n", i, unit->type);
+} else if (err  == AVERROR(EAGAIN)) {
+av_log(ctx->log_ctx, AV_LOG_VERBOSE,
+   "Discarding unit %d "
+   "(type %"PRIu32").\n", i, unit->type);
+av_buffer_unref(>content_ref);
+unit->content = NULL;
 } else if (err < 0) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
"(type %"PRIu32").\n", i, unit->type);
-- 
2.29.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 3/4 v3] avcodec/cbs_av1: add an option to select an operating point

2020-11-15 Thread James Almer
This implements the function drop_obu() as defined in Setion 6.2.1 from the
spec.
In a reading only scenario, units that belong to an operating point the
caller doesn't want should not be parsed.

Signed-off-by: James Almer 
---
 libavcodec/cbs_av1.c | 30 +-
 libavcodec/cbs_av1.h |  5 +
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 9badfe31e4..81662114a1 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -17,6 +17,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/opt.h"
 #include "libavutil/pixfmt.h"
 
 #include "cbs.h"
@@ -883,7 +884,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 int in_spatial_layer  =
 (priv->operating_point_idc >> (priv->spatial_id + 8)) & 1;
 if (!in_temporal_layer || !in_spatial_layer) {
-// Decoding will drop this OBU at this operating point.
+return AVERROR(EAGAIN); // drop_obu()
 }
 }
 }
@@ -896,6 +897,18 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 
+if (priv->operating_point >= 0) {
+AV1RawSequenceHeader *sequence_header = 
>obu.sequence_header;
+
+if (priv->operating_point > 
sequence_header->operating_points_cnt_minus_1) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid Operating 
Point %d requested. "
+   "Must not be higher 
than %u.\n",
+   priv->operating_point, 
sequence_header->operating_points_cnt_minus_1);
+return AVERROR(EINVAL);
+}
+priv->operating_point_idc = 
sequence_header->operating_point_idc[priv->operating_point];
+}
+
 av_buffer_unref(>sequence_header_ref);
 priv->sequence_header = NULL;
 
@@ -1253,9 +1266,24 @@ static const CodedBitstreamUnitTypeDescriptor 
cbs_av1_unit_types[] = {
 CBS_UNIT_TYPE_END_OF_LIST
 };
 
+#define OFFSET(x) offsetof(CodedBitstreamAV1Context, x)
+static const AVOption cbs_av1_options[] = {
+{ "operating_point",  "Set operating point to select layers to parse from 
a scalable bitstream",
+  OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = 
-1 }, -1, AV1_MAX_OPERATING_POINTS - 1, 0 },
+{ NULL }
+};
+
+static const AVClass cbs_av1_class = {
+.class_name = "cbs_av1",
+.item_name  = av_default_item_name,
+.option = cbs_av1_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 const CodedBitstreamType ff_cbs_type_av1 = {
 .codec_id  = AV_CODEC_ID_AV1,
 
+.priv_class= _av1_class,
 .priv_data_size= sizeof(CodedBitstreamAV1Context),
 
 .unit_types= cbs_av1_unit_types,
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 386774750a..e4e0a8ba40 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -421,6 +421,8 @@ typedef struct AV1ReferenceFrameState {
 } AV1ReferenceFrameState;
 
 typedef struct CodedBitstreamAV1Context {
+const AVClass *class;
+
 AV1RawSequenceHeader *sequence_header;
 AVBufferRef  *sequence_header_ref;
 
@@ -449,6 +451,9 @@ typedef struct CodedBitstreamAV1Context {
 int tile_num;
 
 AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
+
+// AVOptions
+int operating_point;
 } CodedBitstreamAV1Context;
 
 
-- 
2.29.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 1/4 v2] avcodec/cbs: add an AVClass to CodedBitstreamType for option handling

2020-11-15 Thread James Almer
So unit parsing may be configured with caller set options.

Signed-off-by: James Almer 
---
 libavcodec/cbs.c  | 9 +
 libavcodec/cbs_internal.h | 6 ++
 2 files changed, 15 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index c8c526ab12..c7afccd6f5 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -23,6 +23,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/buffer.h"
 #include "libavutil/common.h"
+#include "libavutil/opt.h"
 
 #include "cbs.h"
 #include "cbs_internal.h"
@@ -101,6 +102,10 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 av_freep();
 return AVERROR(ENOMEM);
 }
+if (type->priv_class) {
+*(const AVClass **)ctx->priv_data = type->priv_class;
+av_opt_set_defaults(ctx->priv_data);
+}
 }
 
 ctx->decompose_unit_types = NULL;
@@ -129,6 +134,10 @@ void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
 ctx->codec->close(ctx);
 
 av_freep(>write_buffer);
+
+if (ctx->codec->priv_class && ctx->priv_data)
+av_opt_free(ctx->priv_data);
+
 av_freep(>priv_data);
 av_freep(ctx_ptr);
 }
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index faa847aad3..a392880036 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -86,6 +86,12 @@ typedef const struct CodedBitstreamUnitTypeDescriptor {
 typedef struct CodedBitstreamType {
 enum AVCodecID codec_id;
 
+// A class for the private data, used to declare private AVOptions.
+// This field is NULL for types that do not declare any options.
+// If this field is non-NULL, the first member of the filter private data
+// must be a pointer to AVClass.
+const AVClass *priv_class;
+
 size_t priv_data_size;
 
 // List of unit type descriptors for this codec.
-- 
2.29.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".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h265_syntax_template: Better check for num_long_term_sps

2020-11-15 Thread Mark Thompson

On 14/11/2020 10:18, Michael Niedermayer wrote:

Fixes: index 26 out of bounds for type 'uint8_t [16]'
Fixes: 
24913/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6261760693370880

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

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 48fae82d04..8eb6e159f4 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1405,6 +1405,8 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
  infer(num_long_term_sps, 0);
  idx_size = 0;
  }
+if (HEVC_MAX_REFS < current->num_long_term_sps)
+return AVERROR_INVALIDDATA;


Please don't put isolated tests in the middle of the template.  If it 
constrains a value then add it to the constraints on that value.


  ue(num_long_term_pics, 0, HEVC_MAX_REFS - 
current->num_long_term_sps);
  
  for (i = 0; i < current->num_long_term_sps +




It would be good if the commit message could include an explanation derived 
from the standard, too.

As far as I can tell the constraint doesn't appear explicitly, but the SPS is 
allowed to define more possible long term frames than are actually allowed to 
be present at any given moment so we need the tighter bound.

- 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 1/4] avformat/rtsp: set AV_OPT_FLAG_DEPRECATED on depracated options

2020-11-15 Thread Andriy Gelman
From: Andriy Gelman 

Signed-off-by: Andriy Gelman 
---
 libavformat/rtsp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d9832bbf1f..2ef75f50e3 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -94,7 +94,7 @@ const AVOption ff_rtsp_options[] = {
 { "max_port", "set maximum local UDP port", OFFSET(rtp_port_max), 
AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC },
 { "listen_timeout", "set maximum timeout (in seconds) to wait for incoming 
connections (-1 is infinite, imply flag listen)", OFFSET(initial_timeout), 
AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
 #if FF_API_OLD_RTSP_OPTIONS
-{ "timeout", "set maximum timeout (in seconds) to wait for incoming 
connections (-1 is infinite, imply flag listen) (deprecated, use 
listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, 
INT_MIN, INT_MAX, DEC },
+{ "timeout", "set maximum timeout (in seconds) to wait for incoming 
connections (-1 is infinite, imply flag listen) (deprecated, use 
listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, 
INT_MIN, INT_MAX, DEC|AV_OPT_FLAG_DEPRECATED },
 { "stimeout", "set timeout (in microseconds) of socket TCP I/O 
operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, 
DEC },
 #else
 { "timeout", "set timeout (in microseconds) of socket TCP I/O operations", 
OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
@@ -102,7 +102,7 @@ const AVOption ff_rtsp_options[] = {
 COMMON_OPTS(),
 { "user_agent", "override User-Agent header", OFFSET(user_agent), 
AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
 #if FF_API_OLD_RTSP_OPTIONS
-{ "user-agent", "override User-Agent header (deprecated, use user_agent)", 
OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
+{ "user-agent", "override User-Agent header (deprecated, use user_agent)", 
OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, 
DEC|AV_OPT_FLAG_DEPRECATED },
 #endif
 { NULL },
 };
-- 
2.28.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/4] avformat/rtsp: fix timeout option

2020-11-15 Thread Andriy Gelman
From: Andriy Gelman 

92c40ef882be115e72d2aa02f9032b7ce88f8537 added a listen_timeout option
for sdp. This allowed a user to set variable timeout in sdp which was
originally hard coded to 10 seconds.

The commit used the initial_timeout variable to store the value.
However, in rtsp this variable is also used to infer a "listen" mode. Thus,
the timeout value could not be set when connecting to an rtsp server.
The default value of -1 would also result in a 100ms total timeout.

This was attempted to be fixed in c8101aabee654f6d147a4d89f77fa73e18908610,
which changed the meaning of initial_timeout = -1 to be an infinite
timeout in rtsp. However, it did not address the issue that the timeout could
still not be set. Being able to set the timeout is useful because it
allows to automatically reconfigure from a udp to tcp connection in rtp.

In this commit, this is fixed by using the stimeout variable/option to
set the timeout.

Signed-off-by: Andriy Gelman 
---
 libavformat/rtsp.c | 14 +++---
 libavformat/rtsp.h |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 2ef75f50e3..a20cde80a9 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -95,9 +95,9 @@ const AVOption ff_rtsp_options[] = {
 { "listen_timeout", "set maximum timeout (in seconds) to wait for incoming 
connections (-1 is infinite, imply flag listen)", OFFSET(initial_timeout), 
AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
 #if FF_API_OLD_RTSP_OPTIONS
 { "timeout", "set maximum timeout (in seconds) to wait for incoming 
connections (-1 is infinite, imply flag listen) (deprecated, use 
listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, 
INT_MIN, INT_MAX, DEC|AV_OPT_FLAG_DEPRECATED },
-{ "stimeout", "set timeout (in microseconds) of socket TCP I/O 
operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, 
DEC },
+{ "stimeout", "set timeout (in microseconds) of socket TCP I/O 
operations", OFFSET(stimeout), AV_OPT_TYPE_INT64, {.i64 = 0}, INT_MIN, 
INT64_MAX, DEC },
 #else
-{ "timeout", "set timeout (in microseconds) of socket TCP I/O operations", 
OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
+{ "timeout", "set timeout (in microseconds) of socket TCP I/O operations", 
OFFSET(stimeout), AV_OPT_TYPE_INT64, {.i64 = 0}, INT_MIN, INT64_MAX, DEC },
 #endif
 COMMON_OPTS(),
 { "user_agent", "override User-Agent header", OFFSET(user_agent), 
AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
@@ -111,7 +111,7 @@ static const AVOption sdp_options[] = {
 RTSP_FLAG_OPTS("sdp_flags", "SDP flags"),
 { "custom_io", "use custom I/O", 0, AV_OPT_TYPE_CONST, {.i64 = 
RTSP_FLAG_CUSTOM_IO}, 0, 0, DEC, "rtsp_flags" },
 { "rtcp_to_source", "send RTCP packets to the source address of received 
packets", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_RTCP_TO_SOURCE}, 0, 0, DEC, 
"rtsp_flags" },
-{ "listen_timeout", "set maximum timeout (in seconds) to wait for incoming 
connections", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = 
READ_PACKET_TIMEOUT_S}, INT_MIN, INT_MAX, DEC },
+{ "listen_timeout", "set maximum timeout (in seconds) to wait for incoming 
connections", OFFSET(stimeout), AV_OPT_TYPE_DURATION, {.i64 = 
READ_PACKET_TIMEOUT_S*100}, INT_MIN, INT64_MAX, DEC },
 RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from 
the server"),
 COMMON_OPTS(),
 { NULL },
@@ -119,7 +119,7 @@ static const AVOption sdp_options[] = {
 
 static const AVOption rtp_options[] = {
 RTSP_FLAG_OPTS("rtp_flags", "set RTP flags"),
-{ "listen_timeout", "set maximum timeout (in seconds) to wait for incoming 
connections", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = 
READ_PACKET_TIMEOUT_S}, INT_MIN, INT_MAX, DEC },
+{ "listen_timeout", "set maximum timeout (in seconds) to wait for incoming 
connections", OFFSET(stimeout), AV_OPT_TYPE_DURATION, {.i64 = 
READ_PACKET_TIMEOUT_S*100}, INT_MIN, INT64_MAX, DEC },
 RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from 
the server"),
 COMMON_OPTS(),
 { NULL },
@@ -1835,7 +1835,7 @@ redirect:
 /* open the tcp connection */
 ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL,
 host, port,
-"?timeout=%d", rt->stimeout);
+"?timeout=%"PRId64, rt->stimeout);
 if ((ret = ffurl_open_whitelist(>rtsp_hd, tcpname, 
AVIO_FLAG_READ_WRITE,
>interrupt_callback, NULL, s->protocol_whitelist, 
s->protocol_blacklist, NULL)) < 0) {
 err = ret;
@@ -1980,7 +1980,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream 
**prtsp_st,
 int n, i, ret;
 struct pollfd *p = rt->p;
 int *fds = NULL, fdsnum, fdsidx;
-int runs = rt->initial_timeout * 1000LL / POLLING_TIME;
+int64_t runs = rt->stimeout / POLLING_TIME / 1000;
 
 if 

[FFmpeg-devel] [PATCH 2/4] doc/protocols: update options

2020-11-15 Thread Andriy Gelman
From: Andriy Gelman 

Define listen_timeout. Set user-agent and timeout to deprecated.

Signed-off-by: Andriy Gelman 
---
 doc/protocols.texi | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index b4efa14509..fd866f57a5 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1102,11 +1102,16 @@ Set minimum local UDP port. Default value is 5000.
 Set maximum local UDP port. Default value is 65000.
 
 @item timeout
-Set maximum timeout (in seconds) to wait for incoming connections.
+This option is deprecated. Use @option{listen_timeout} instead. Set maximum 
timeout (in seconds) to wait for incoming connections.
 
 A value of -1 means infinite (default). This option implies the
 @option{rtsp_flags} set to @samp{listen}.
 
+@item listen_timeout
+Set maximum timeout (in seconds) to establish an initial connection. Setting
+@samp{listen_timeout} > 0 sets @option{rtsp_flags} to @samp{listen}. Default 
is -1
+which means an infinite timeout when @samp{listen} mode is set.
+
 @item reorder_queue_size
 Set number of packets to buffer for handling of reordered packets.
 
@@ -1114,7 +1119,11 @@ Set number of packets to buffer for handling of 
reordered packets.
 Set socket TCP I/O timeout in microseconds.
 
 @item user-agent
-Override User-Agent header. If not specified, it defaults to the
+This option is deprecated. Use @option{user_agent} instead. Override 
User-Agent header. If not specified, it defaults to the
+libavformat identifier string.
+
+@item user_agent
+User-Agent header. If not specified, it defaults to the
 libavformat identifier string.
 @end table
 
-- 
2.28.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 4/4] avformat/rtsp: change to default stimeout to 10 seconds

2020-11-15 Thread Andriy Gelman
From: Andriy Gelman 

This is to match the behaviour before commits:
c8101aabee654f6d147a4d89f77fa73e18908610
92c40ef882be115e72d2aa02f9032b7ce88f8537

The only difference is that now a 10 second timeout will also be set
when the rtsp session is being setup, whereas before this was an
infinite timeout.

Signed-off-by: Andriy Gelman 
---
 doc/protocols.texi | 3 ++-
 libavformat/rtsp.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index fd866f57a5..0187da6c35 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1116,7 +1116,8 @@ which means an infinite timeout when @samp{listen} mode 
is set.
 Set number of packets to buffer for handling of reordered packets.
 
 @item stimeout
-Set socket TCP I/O timeout in microseconds.
+Set socket TCP I/O timeout in microseconds. Default is 10,000,000 microseconds
+(10 seconds).
 
 @item user-agent
 This option is deprecated. Use @option{user_agent} instead. Override 
User-Agent header. If not specified, it defaults to the
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index a20cde80a9..3699d354f6 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -95,9 +95,9 @@ const AVOption ff_rtsp_options[] = {
 { "listen_timeout", "set maximum timeout (in seconds) to wait for incoming 
connections (-1 is infinite, imply flag listen)", OFFSET(initial_timeout), 
AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
 #if FF_API_OLD_RTSP_OPTIONS
 { "timeout", "set maximum timeout (in seconds) to wait for incoming 
connections (-1 is infinite, imply flag listen) (deprecated, use 
listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, 
INT_MIN, INT_MAX, DEC|AV_OPT_FLAG_DEPRECATED },
-{ "stimeout", "set timeout (in microseconds) of socket TCP I/O 
operations", OFFSET(stimeout), AV_OPT_TYPE_INT64, {.i64 = 0}, INT_MIN, 
INT64_MAX, DEC },
+{ "stimeout", "set timeout (in microseconds) of socket TCP I/O 
operations", OFFSET(stimeout), AV_OPT_TYPE_INT64, {.i64 = 
READ_PACKET_TIMEOUT_S*100}, INT_MIN, INT64_MAX, DEC },
 #else
-{ "timeout", "set timeout (in microseconds) of socket TCP I/O operations", 
OFFSET(stimeout), AV_OPT_TYPE_INT64, {.i64 = 0}, INT_MIN, INT64_MAX, DEC },
+{ "timeout", "set timeout (in microseconds) of socket TCP I/O operations", 
OFFSET(stimeout), AV_OPT_TYPE_INT64, {.i64 = READ_PACKET_TIMEOUT_S*100}, 
INT_MIN, INT64_MAX, DEC },
 #endif
 COMMON_OPTS(),
 { "user_agent", "override User-Agent header", OFFSET(user_agent), 
AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
-- 
2.28.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 2/4] avcodec/cbs: allow cbs_read_fragment_content() to discard units

2020-11-15 Thread James Almer

On 10/1/2020 9:38 PM, James Almer wrote:

On 10/1/2020 8:57 PM, Mark Thompson wrote:

On 20/09/2020 18:24, James Almer wrote:

The caller may not need all units in a fragment in reading only
scenarios. They
could in fact alter global state stored in the private CodedBitstreamType
fields in an undesirable way.
And unlike preventing decomposition of units, discarding can be done
based on
parsed values within the unit.

Signed-off-by: James Almer 
---
   libavcodec/cbs.c | 5 +
   1 file changed, 5 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index e73e18f398..363385b6f3 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -196,6 +196,11 @@ static int
cbs_read_fragment_content(CodedBitstreamContext *ctx,
   av_log(ctx->log_ctx, AV_LOG_VERBOSE,
  "Decomposition unimplemented for unit %d "
  "(type %"PRIu32").\n", i, unit->type);
+    } else if (err  == AVERROR(EAGAIN)) {
+    av_log(ctx->log_ctx, AV_LOG_VERBOSE,
+   "Discarding unit %d "
+   "(type %"PRIu32").\n", i, unit->type);
+    ff_cbs_delete_unit(frag, i--);
   } else if (err < 0) {
   av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit
%d "
  "(type %"PRIu32").\n", i, unit->type);



I don't really like how it is modifying the units in the fragment
internally in the read function.  EAGAIN as an "I didn't do anything
with this" return from read_unit seems reasonable, but then deleting the
unit here feels outside the intended meaning of the function.

Would it make sense to push that further out somehow?  E.g. av1dec.c
ignoring undecomposed units, or maybe a separate function to do deletion
under whatever conditions.


Seems overtly complicated for what ultimately will be the same result.
The fragment will have only the units that were not discarded before
being returned to the caller.

And the caller (av1dec) can't really know if a unit was decomposed or
not, assuming they are not removed from the fragment. In the case of
Patch 3/4, it will return EAGAIN after having filled the OBU header bits.


Ping? I'd like to apply patches 1 and 2 from this set (or some 
variation) and v2 of patches 3 and 4.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/mpegts: make sure mpegts_read_header always stops at the first pmt

2020-11-15 Thread Ross Nicholson
On Sat, 14 Nov 2020 at 23:40, Marton Balint  wrote:

> mpegts_read_header stops parsing the file at the first PMT. However the
> check
> that ensured this was wrong because streams can also be added before the
> first
> PMT is received (e.g. EIT).
>
> So let's make sure we are in the header reading phase by checking if
> ts->pkt is
> unset instead of checking if the number of streams found so far is 0.
>
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mpegts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 80d010db6c..a2003c6632 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2355,7 +2355,7 @@ static void pmt_cb(MpegTSFilter *filter, const
> uint8_t *section, int section_len
>  goto out;
>
>  // stop parsing after pmt, we found header
> -if (!ts->stream->nb_streams)
> +if (!ts->pkt)
>  ts->stop_parse = 2;
>
>  set_pmt_found(ts, h->id);
> --
> 2.26.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Thanks for this. With this fix streams with embedded EIT data open in
approx 1-1.5 seconds as opposed to 10-15 seconds without the fix. If
possible also having this fix in the 4.3 branch as well as master would be
great.
___
ffmpeg-devel mailing list
ffmpeg-devel@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/matroskadec: avoid warning on duration conversion

2020-11-15 Thread Steve Lhomme
Do the conversion from double to uint64_t explicitly and only once.
The comparison to UINT64_MAX is not correct.
---
 libavformat/matroskadec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8a5bc4018a..4ff472005e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2328,8 +2328,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
 
 if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
 if (!track->default_duration && track->video.frame_rate > 0) {
-double default_duration = 10 / track->video.frame_rate;
-if (default_duration > UINT64_MAX || default_duration < 0) {
+uint64_t default_duration = (double)10 / 
track->video.frame_rate;
+if (default_duration > UINT64_MAX) {
 av_log(matroska->ctx, AV_LOG_WARNING,
  "Invalid frame rate %e. Cannot calculate default 
duration.\n",
  track->video.frame_rate);
-- 
2.26.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/2] avformat/matroskadec: adjust the cluster time to the track timebase

2020-11-15 Thread Steve Lhomme
The Block timestamp read in matroska_parse_block() is in track timebase and is
passed on as such to the AVPacket which uses this timebase.

In the normal case the Cluster and Track timebases are the same because the
track->time_scale is 1.0. But when it is not the case, the values in Cluster
timebase need to be transformed in Track timebase so they can be added
together.
---
 libavformat/matroskadec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index ba0e2956df..137674c068 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3581,7 +3581,8 @@ static int matroska_parse_block(MatroskaDemuxContext 
*matroska, AVBufferRef *buf
 
 if (cluster_time != (uint64_t) -1 &&
 (block_time >= 0 || cluster_time >= -block_time)) {
-timecode = cluster_time + block_time - track->codec_delay_in_track_tb;
+uint64_t timecode_cluster_in_track_tb = (double) cluster_time / 
track->time_scale;
+timecode = timecode_cluster_in_track_tb + block_time - 
track->codec_delay_in_track_tb;
 if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE &&
 timecode < track->end_timecode)
 is_keyframe = 0;  /* overlapping subtitles are not key frame */
-- 
2.26.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] avformat/matroskadec: only use the track duration if it exists

2020-11-15 Thread Steve Lhomme
No need to multiplying/dividing when we know it's zero.
---
 libavformat/matroskadec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 4ff472005e..25b22afebe 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3547,7 +3547,7 @@ static int matroska_parse_block(MatroskaDemuxContext 
*matroska, AVBufferRef *buf
 uint32_t lace_size[256];
 int n, flags, laces = 0;
 uint64_t num;
-int trust_default_duration = 1;
+int trust_default_duration;
 
 ffio_init_context(, data, size, 0, NULL, NULL, NULL, NULL);
 
@@ -3615,7 +3615,8 @@ static int matroska_parse_block(MatroskaDemuxContext 
*matroska, AVBufferRef *buf
 return res;
 }
 
-if (track->audio.samplerate == 8000) {
+trust_default_duration = track->default_duration != 0;
+if (track->audio.samplerate == 8000 && trust_default_duration) {
 // If this is needed for more codecs, then add them here
 if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
 if (track->audio.samplerate != st->codecpar->sample_rate || 
!st->codecpar->frame_size)
-- 
2.26.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] avformat/matroskadec: update the end timestamp when there is a timestamp

2020-11-15 Thread Steve Lhomme
No need to check if the cluster has a timestamp or not. If we found a timestamp
for this block, then it's usable. This is actually the same condition to decide
if we can use the timestamp or not.
---
 libavformat/matroskadec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 137674c068..8a5bc4018a 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3626,7 +3626,7 @@ static int matroska_parse_block(MatroskaDemuxContext 
*matroska, AVBufferRef *buf
 if (!block_duration && trust_default_duration)
 block_duration = track->default_duration * laces / 
matroska->time_scale;
 
-if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= 
-block_time))
+if (timecode != AV_NOPTS_VALUE)
 track->end_timecode =
 FFMAX(track->end_timecode, timecode + block_duration);
 
-- 
2.26.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 1/2] avformat/matroskadec: add a warning when the track TimestampScale won't be used

2020-11-15 Thread Steve Lhomme
---
 libavformat/matroskadec.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 981e044263..ba0e2956df 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2672,8 +2672,12 @@ static int matroska_parse_tracks(AVFormatContext *s)
 av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported AVCodecID %s.\n", track->codec_id);
 
-if (track->time_scale < 0.01)
+if (track->time_scale < 0.01) {
+av_log(matroska->ctx, AV_LOG_WARNING,
+   "Track TimestampScale too small %f, assuming 1.0.\n",
+   track->time_scale);
 track->time_scale = 1.0;
+}
 avpriv_set_pts_info(st, 64, matroska->time_scale * track->time_scale,
 1000 * 1000 * 1000);/* 64 bit pts in ns */
 
-- 
2.26.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".

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

2020-11-15 Thread Andreas Rheinhardt
Mohammad Izadi:
> From: Mohammad Izadi 
> 
> HDR10+ is dynamic metadata (A/341 Amendment - SMPTE2094-40) that needs to be 
> decoded from ITU-T T.35 in HEVC bitstream. The HDR10+ is transferred to side 
> data packet to be used or passed through.
> 
> The fate test file can be found here: 
> https://drive.google.com/file/d/1Hadzc24-RsgnRqS-B0bxLmzDeTwEOhtE/view?usp=sharing
> 
> The video file needs to be copied to fate-suite/mov/
> ---

1. The comments regarding fate don't belong in the commit message, they
belong here below the --- (the --annotate option is useful for this when
using git send-email).
2. This file is huge. Why don't you use a file with a smaller
bitrate/resolution?

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