Re: [FFmpeg-devel] [PATCH] avcodec/av1dec: check avctx->hwaccel when hwaccel pix_fmt selected

2020-09-17 Thread Wang, Fei W


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Hendrik Leppkes
> Sent: Thursday, September 17, 2020 5:21 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/av1dec: check avctx->hwaccel
> when hwaccel pix_fmt selected
> 
> On Thu, Sep 17, 2020 at 10:38 AM Fei Wang  wrote:
> >
> > Pix fmt with hwaccel flag may not be chosen in format probing, in this
> > case avctx->hwaccel will not be inited.
> >
> > Signed-off-by: Fei Wang 
> > ---
> >  libavcodec/av1dec.c | 12 
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index
> > 0bb04a3e44..cdcc618013 100644
> > --- a/libavcodec/av1dec.c
> > +++ b/libavcodec/av1dec.c
> > @@ -251,6 +251,7 @@ static int get_pixel_format(AVCodecContext *avctx)
> > {
> >  AV1DecContext *s = avctx->priv_data;
> >  const AV1RawSequenceHeader *seq = s->raw_seq;
> > +const AVPixFmtDescriptor *desc;
> >  uint8_t bit_depth;
> >  int ret;
> >  enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; @@ -327,10 +328,13
> > @@ static int get_pixel_format(AVCodecContext *avctx)
> >   * Since now the av1 decoder doesn't support native decode, if it will 
> > be
> >   * implemented in the future, need remove this check.
> >   */
> > -if (!avctx->hwaccel) {
> > -av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
> > -   " hardware accelerated AV1 decoding.\n");
> > -return AVERROR(ENOSYS);
> > +desc = av_pix_fmt_desc_get(ret);
> > +if (desc && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
> > +if (!avctx->hwaccel) {
> > +av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
> > +   " hardware accelerated AV1 decoding.\n");
> > +return AVERROR(ENOSYS);
> > +}
> >  }
> >
> 
> Isn't it supposed to quit here, because we do not have software decoding?

Since now av1 decoder allow probe, that will try to decode first frame to 
find stream info in open_file stage. While the hwaccel will not be inited.
If without change here, the error log will be print out but later during
transcode stage, it can gives out the correct output.

> 
> - 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 3/8] avcodec/vlc: Add macro for ff_init_vlc_sparse()

2020-09-17 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> ff_init_vlc_sparse() supports arrays of uint8_t, uint16_t and uint32_t
> as input (and it also supports padding/other elements in between the
> elements). This makes the typical case in which the input is a simple
> array more cumbersome. E.g. for an array of uint8_t one would either
> need to call the function with arguments like "array, sizeof(array[0]),
> sizeof(array[0])" or with "array, 1, 1". The former is nicer, but
> longer, so that the latter is mostly used. Therefore this commit adds a
> macro that expands to the sizeof() construct.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/vlc.h | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vlc.h b/libavcodec/vlc.h
> index 42ccddf3fc..7cb323b62c 100644
> --- a/libavcodec/vlc.h
> +++ b/libavcodec/vlc.h
> @@ -35,7 +35,12 @@ typedef struct RL_VLC_ELEM {
>  uint8_t run;
>  } RL_VLC_ELEM;
>  
> -#define init_vlc(vlc, nb_bits, nb_codes,\
> +#define INIT_VLC_DEFAULT_SIZES(ptr) \
> +(ptr), sizeof((ptr)[0]), sizeof((ptr)[0])
> +
> +#define init_vlc(...) init_vlc2(__VA_ARGS__)
> +
> +#define init_vlc2(vlc, nb_bits, nb_codes,   \
>   bits, bits_wrap, bits_size,\
>   codes, codes_wrap, codes_size, \
>   flags) \
> 

This change apparently broke building with MSVC, see [1]. The reason is
that MSVC's behaviour wrt ',' included in the __VA_ARGS__ is
spec-incompliant: These ',' are not treated as argument separators for
further macros (in our case init_vlc2), so that MSVC thinks that the
init_vlc2() macro has only one argument. See [2] for a confirmation that
this is indeed a bug in MSVC; see [3] for a minimal code snippet. There
is a workaround for this by adding an additional intermediate macro as
in [4].
Yet I don't think that this is desirable (I was actually unsure whether
this patch is worth it (after all "INIT_VLC_DEFAULT_SIZES" is quite long
in itself)) and there is the problem that it might not fix everything:
[2] indicates that until recently clang did not support said workaround
when in ms-compatibility mode (admittedly, I don't know whether there is
any reason at all to use clang in ms-compatibility mode to compile
FFmpeg, but whatever...). So my suggestion is to basically revert said
commit; adapting the smacker decoder (its only user) is trivial of
course. I will send a patch that implements this soon.

(Btw: How about macros like this:
#define INIT_VLC(vlc, nb_bits, nb_codes, bits, codes, flags)  \
ff_init_vlc_sparse(vlc, nb_bits, nb_codes,\
   bits, sizeof(*bits), sizeof(*bits),\
   codes, sizeof(*codes), sizeof(*codes), \
   NULL, 0, 0, flags)
and a similar one with symbols?)

- Andreas

[1]:
http://fate.ffmpeg.org/log.cgi?log=compile=20200918012551=x86_64-msvc16-windows-native
[2]: https://reviews.llvm.org/D69626
[3]: https://godbolt.org/z/eTE3Gh
[4]: https://godbolt.org/z/obrz4h
___
ffmpeg-devel mailing list
ffmpeg-devel@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 01/30] avcodec/flashsvenc: Avoid allocation of buffer, fix memleak

2020-09-17 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Up until now, the flashsv encoder tried to allocate two buffers in its
> init function; if only one of these allocations succeeds, the other
> buffer leaks. Fix this by making one of these buffers part of the
> context (its size is a compile-time constant).
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/flashsvenc.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
> index f7f98efde3..4ac643c036 100644
> --- a/libavcodec/flashsvenc.c
> +++ b/libavcodec/flashsvenc.c
> @@ -59,11 +59,11 @@ typedef struct FlashSVContext {
>  uint8_t*previous_frame;
>  int image_width, image_height;
>  int block_width, block_height;
> -uint8_t*tmpblock;
>  uint8_t*encbuffer;
>  int block_size;
>  z_streamzstream;
>  int last_key_frame;
> +uint8_t tmpblock[3 * 256 * 256];
>  } FlashSVContext;
>  
>  static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy,
> @@ -96,7 +96,6 @@ static av_cold int flashsv_encode_end(AVCodecContext *avctx)
>  
>  av_freep(>encbuffer);
>  av_freep(>previous_frame);
> -av_freep(>tmpblock);
>  
>  return 0;
>  }
> @@ -121,10 +120,9 @@ static av_cold int flashsv_encode_init(AVCodecContext 
> *avctx)
>  s->image_width  = avctx->width;
>  s->image_height = avctx->height;
>  
> -s->tmpblock  = av_mallocz(3 * 256 * 256);
>  s->encbuffer = av_mallocz(s->image_width * s->image_height * 3);
>  
> -if (!s->tmpblock || !s->encbuffer) {
> +if (!s->encbuffer) {
>  av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
>  return AVERROR(ENOMEM);
>  }
> 
Will apply the rest of this patchset tomorrow unless there are objections.

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

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

[FFmpeg-devel] [PATCH] avformat/hlsenc: compute video_keyframe_size after write keyframe

2020-09-17 Thread Steven Liu
fix ticket: 8636
When write keyframe and the keyframe is the frist packet of the segment,
then compute the size of the keyframe which have been write into segment
first packet. and set the start position of the segment, should not use
avio_tell(vs->out) to get the keyframe position, because it can be set
to 0 if close at above of the workflow, that maybe inaccurate, but the
start_pos can be used here, because start_pos is set after write
the previous packet.

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cb31d6aed7..8687d7c12c 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2572,13 +2572,14 @@ static int hls_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 
 vs->packets_written++;
 if (oc->pb) {
+int64_t keyframe_pre_pos = avio_tell(oc->pb);
 ret = ff_write_chained(oc, stream_index, pkt, s, 0);
-vs->video_keyframe_size += pkt->size;
-if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && (pkt->flags & 
AV_PKT_FLAG_KEY)) {
-vs->video_keyframe_size = avio_tell(oc->pb);
-} else {
-vs->video_keyframe_pos = avio_tell(vs->out);
+if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
+(pkt->flags & AV_PKT_FLAG_KEY) && !keyframe_pre_pos) {
+av_write_frame(oc, NULL); /* Flush any buffered data */
+vs->video_keyframe_size = avio_tell(oc->pb) - keyframe_pre_pos;
 }
+vs->video_keyframe_pos = vs->start_pos;
 if (hls->ignore_io_errors)
 ret = 0;
 }
-- 
2.25.0



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

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

[FFmpeg-devel] [PATCH 3/3] avdevice/lavfi: av_malloc -> av_malloc_array

2020-09-17 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index a4b510f..ff0be64 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -69,7 +69,7 @@ static int *create_all_formats(int n)
 count++;
 }
 
-if (!(fmts = av_malloc((count+1) * sizeof(int
+if (!(fmts = av_malloc_array(count + 1, sizeof(*fmts
 return NULL;
 for (j = 0, i = 0; i < n; i++) {
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH 1/3] avdevice/lavfi: fix FIXME and check a/v type by codec_type

2020-09-17 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 4f05a15..268dc0d 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -386,6 +386,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
 AVDictionary *frame_metadata;
 int ret, i;
 int size = 0;
+AVStream *st;
 
 if (lavfi->subcc_packet.size) {
 av_packet_move_ref(pkt, >subcc_packet);
@@ -426,15 +427,16 @@ static int lavfi_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
 
 av_buffersink_get_frame_flags(lavfi->sinks[min_pts_sink_idx], frame, 0);
 stream_idx = lavfi->sink_stream_map[min_pts_sink_idx];
+st = avctx->streams[stream_idx];
 
-if (frame->width /* FIXME best way of testing a video */) {
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 size = av_image_get_buffer_size(frame->format, frame->width, 
frame->height, 1);
 if ((ret = av_new_packet(pkt, size)) < 0)
 return ret;
 
 av_image_copy_to_buffer(pkt->data, size, (const uint8_t 
**)frame->data, frame->linesize,
 frame->format, frame->width, frame->height, 1);
-} else if (frame->channels /* FIXME test audio */) {
+} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
 size = frame->nb_samples * av_get_bytes_per_sample(frame->format) *
frame->channels;
 if ((ret = av_new_packet(pkt, size)) < 0)
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH 2/3] avdevice/lavfi: unref the frame on failure

2020-09-17 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavdevice/lavfi.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 268dc0d..a4b510f 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -432,7 +432,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 size = av_image_get_buffer_size(frame->format, frame->width, 
frame->height, 1);
 if ((ret = av_new_packet(pkt, size)) < 0)
-return ret;
+goto fail;
 
 av_image_copy_to_buffer(pkt->data, size, (const uint8_t 
**)frame->data, frame->linesize,
 frame->format, frame->width, frame->height, 1);
@@ -440,7 +440,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
 size = frame->nb_samples * av_get_bytes_per_sample(frame->format) *
frame->channels;
 if ((ret = av_new_packet(pkt, size)) < 0)
-return ret;
+goto fail;;
 memcpy(pkt->data, frame->data[0], size);
 }
 
@@ -449,18 +449,19 @@ static int lavfi_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
 int size;
 uint8_t *metadata = av_packet_pack_dictionary(frame_metadata, );
 
-if (!metadata)
-return AVERROR(ENOMEM);
+if (!metadata) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 if ((ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
metadata, size)) < 0) {
 av_freep();
-return ret;
+goto fail;;
 }
 }
 
 if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) {
-av_frame_unref(frame);
-return ret;
+goto fail;
 }
 
 pkt->stream_index = stream_idx;
@@ -468,6 +469,10 @@ static int lavfi_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
 pkt->pos = frame->pkt_pos;
 av_frame_unref(frame);
 return size;
+fail:
+av_frame_unref(frame);
+return ret;
+
 }
 
 #define OFFSET(x) offsetof(LavfiContext, x)
-- 
1.8.3.1

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

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

Re: [FFmpeg-devel] [PATCH 13/21] avcodec/smacker: Remove redundant checks when reading VLC codes

2020-09-17 Thread Andreas Rheinhardt
Paul B Mahol:
> On 8/1/20, Andreas Rheinhardt  wrote:
>> The VLC codes in question originate from a Huffmann tree and so every
>> sequence of bits that is longer than the longest code contains an
>> initial sequence that is a valid code. Given that it has been checked
>> during reading said tree (and once again in ff_init_vlc_sparse()) that
>> the length of each code is <= 3 * the number of bits read at once when
>> reading codes, get_vlc2() will always find a matching entry.
>>
>> These checks have been added in 71d3c25a7ef442ac2dd7b6fbf7c489ebc0b58e9b
>> at a time when the length of the codes had not been checked when parsing
>> the tree.
>>
>> For GCC 9 and the sample from ticket #2425 this led to a slight
>> performance regression: The time for one call to smka_decode_frame()
>> increased from 2053671 to 2064529 decicycles; for Clang 9, performance
>> improved from 1521288 to 1508459 decicycles.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/smacker.c | 32 
>>  1 file changed, 32 deletions(-)
>>
> 
> Sure this does not continue under bitstream errors?
> 
> Try some smart fuzzers.
> 
I have now finally fuzzed my patches here and found no bugs at all
(neither with ASAN nor with UBSan). I'll therefore apply it.

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

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

[FFmpeg-devel] Patch: added V210 codec support to MXF encoder

2020-09-17 Thread Swami Kevala
Verified the container_ui and element_ui with a sample file produced by
Sony Server  1.3.0.0.1 (Sony MXF Development Kit (Win32) 4.9.1.118.1)

Tested converting an ffv1/mkv to v210/mxf successfully

-- 
*- 9442504660*

-- 
 


-- 
The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not 
the intended recipient, you should not disseminate, distribute or copy this 
e-mail. Please notify the sender immediately and destroy all copies of this 
message and any attachments. WARNING: Computer viruses can be transmitted 
via email. The recipient should check this email and any attachments for 
the presence of viruses. The Organisation accepts no liability for any 
damage caused by any virus transmitted by this email. 
www.ishafoundation.org 


0001-area-changed-Added-V210-codec-support-to-MXF-encoder.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] avformat/aviobuf: fix broken logic in ffio_ensure_seekback()

2020-09-17 Thread Paul B Mahol
On Thu, Sep 17, 2020 at 09:44:52PM +0200, Marton Balint wrote:
> 
> 
> On Thu, 17 Sep 2020, Paul B Mahol wrote:
> 
> > This removes big CPU overhead for demuxing chained ogg streams.
> > 
> > Signed-off-by: Paul B Mahol 
> > ---
> > libavformat/aviobuf.c | 10 +-
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> > index a77517d712..ce9b7d59c9 100644
> > --- a/libavformat/aviobuf.c
> > +++ b/libavformat/aviobuf.c
> > @@ -996,20 +996,20 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t 
> > buf_size)
> > uint8_t *buffer;
> > int max_buffer_size = s->max_packet_size ?
> >   s->max_packet_size : IO_BUFFER_SIZE;
> > -int filled = s->buf_end - s->buffer;
> > ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
> > s->buffer : -1;
> > 
> > -buf_size += s->buf_ptr - s->buffer + max_buffer_size;
> > -
> > -if (buf_size < filled || s->seekable || !s->read_packet)
> > +if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
> > return 0;
> 
> This is still not correct. You can only return if
> buf_size <= s->buf_end - s->buf_ptr

That one gives you original issue.

> OR
> buf_size <= s->buffer + s->buffer_size - s->buf_ptr - max_buffer_size + 1
> 

That one gives you also original issue but at slower peace.

> And the new minimum buffer size is what is calculated now, so that should
> not be changed.
> 
> I am not sure if this fixes you original issue. It might make sense to
> allocate max_buffer_size*2 length buffers by default, but the buffer size
> revert logic must be fixed to support that...
> 
> Regards,
> Marton
> 
> 
> 
> > +buf_size += s->buffer_size;
> > +buf_size = FFMAX(buf_size, max_buffer_size);
> > +
> > av_assert0(!s->write_flag);
> > 
> > buffer = av_malloc(buf_size);
> > if (!buffer)
> > return AVERROR(ENOMEM);
> > 
> > -memcpy(buffer, s->buffer, filled);
> > +memcpy(buffer, s->buffer, s->buffer_size);
> > av_free(s->buffer);
> > s->buf_ptr = buffer + (s->buf_ptr - s->buffer);
> > s->buf_end = buffer + (s->buf_end - s->buffer);
> > -- 
> > 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 mailing list
> ffmpeg-devel@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 v2 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF

2020-09-17 Thread Tomas Härdin
mån 2020-09-14 klockan 12:23 +0200 skrev Tomas Härdin:
> ons 2020-09-09 klockan 15:56 +0100 skrev Harry Mallon:
> > * As embedded by Apple Compressor
> > 
> > Signed-off-by: Harry Mallon 
> > ---
> >  libavformat/mxfdec.c|  27 +
> >  tests/fate/mxf.mak  |   4 +
> >  tests/ref/fate/mxf-probe-applehdr10 | 169
> > 
> 
> Sweet, I don't have to write the test myself .)
> 
> Just ran FATE, the entire patch set works fine. We just need to get
> that sample into the sample suite then all three of them can be
> pushed.
> I'll see what I can do.

FATE suite updated, FATE passes -> patchset pushed

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH v2] avfilter/vf_scale: translate and verify swscale internal range flag

2020-09-17 Thread Jan Ekström
On Thu, Sep 17, 2020 at 11:31 PM Michael Niedermayer
 wrote:
>
> On Wed, Sep 16, 2020 at 11:18:48PM +0300, Jan Ekström wrote:
> > This value - while it looks like the actual range of the content -
> > is nothing but the internal value of swscale.
> >
> > Thus, if we have RGB content, force the value to 1. Swscale will
> > ignore it, but at least the value of the output AVFrame will now
> > properly be "full range" instead of "limited range", as it is right
> > now.
> >
> > Additionally, after calling sws_setColorspaceDetails double-check
> > the configured internal flag for the color range. Warn if this is
> > different to the requested value.
> >
> > Finally, utilize the translated configured output value into the
> > output AVFrame's color_range.
> > ---
> >  libavfilter/vf_scale.c | 51 +-
> >  1 file changed, 50 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> > index 58eee96744..592e4a344e 100644
> > --- a/libavfilter/vf_scale.c
> > +++ b/libavfilter/vf_scale.c
> > @@ -750,11 +750,30 @@ scale:
> >  || in_range != AVCOL_RANGE_UNSPECIFIED
> >  || scale->out_range != AVCOL_RANGE_UNSPECIFIED) {
> >  int in_full, out_full, brightness, contrast, saturation;
> > +int configured_in_full_range_flag, configured_out_full_range_flag;
> >  const int *inv_table, *table;
> > +const AVPixFmtDescriptor *in_desc  = 
> > av_pix_fmt_desc_get(in->format);
> > +const AVPixFmtDescriptor *out_desc = 
> > av_pix_fmt_desc_get(out->format);
>
> > +if (!in_desc || !out_desc) {
> > +av_log(ctx, AV_LOG_ERROR,
> > +   "Failed to get one or more of the pixel format 
> > descriptors "
> > +   "for formats - in: %d (%s), out: %d (%s)!\n",
> > +   in->format, in_desc ? "OK" : "bad",
> > +   out->format, out_desc ? "OK": "bad");
> > +av_frame_free();
> > +av_frame_free(frame_out);
> > +return AVERROR_INVALIDDATA;
> > +}
>
> can this be true ?
>

Maybe it cannot, but it's a pointer. If the value somehow ends up
being one for which there is no descriptor.

It all boils to, unless I know there cannot technically be a nullptr
received, I check. Because this way the check is in one place, instead
of doing `xx_desc ? xx_desc->thing : failover` everywhere.

I can change this to an assert as mentioned by Nicolas, of course.

>
> >
> >  sws_getColorspaceDetails(scale->sws, (int **)_table, _full,
> >   (int **), _full,
> >   , , );
>
> > +// translate the swscale internal range flags to hold true
> > +// for RGB
>
> The range field of AVFrame is documented as
> "MPEG vs JPEG YUV range."
>

Yes, but I think quite a few people at this point just read it "full
range" VS "limited range" without any connotations towards YCbCr
specifically. Personally, I consider the enumeration names as just old
left-overs from the time when the MPEG/JPEG or TV/PC naming sounded
like a good idea and that nobody wanted to start the change of adding
new defines and enum values etc, doing deprecation etc as that is
quite a lot of work just to get the naming of enums nicer. Case in
point - for example pngdec sets the range value for the RGB frames it
returns.

Of course unless you specifically want to support limited range RGB,
RGB should not only be implied being full range by default but also
always set to be full range everywhere.

> so it is not defined for RGB and cannot be "wrong" for RGB
> maybe iam nitpicking here but if you want to use the range for RGB
> the API docs need to be changed first.
>

The code was ALREADY doing that, and I'm just converting the value so
that you don't end up with RGB + limited range AVFrames?!

> I mean you could set it to 1 for RGB thats ok without a API
> docs change. But writing in a comment that one way is correct for RGB is not
> compatible with the current documentation
>

So you want another patch that changes it to just say "limited/narrow
range" and "full range"? Like seriously, I just wanted to fix a
problem that got found because I finally started plugging some pipes
together!

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

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

Re: [FFmpeg-devel] [PATCH v2] avfilter/vf_scale: translate and verify swscale internal range flag

2020-09-17 Thread Michael Niedermayer
On Wed, Sep 16, 2020 at 11:18:48PM +0300, Jan Ekström wrote:
> This value - while it looks like the actual range of the content -
> is nothing but the internal value of swscale.
> 
> Thus, if we have RGB content, force the value to 1. Swscale will
> ignore it, but at least the value of the output AVFrame will now
> properly be "full range" instead of "limited range", as it is right
> now.
> 
> Additionally, after calling sws_setColorspaceDetails double-check
> the configured internal flag for the color range. Warn if this is
> different to the requested value.
> 
> Finally, utilize the translated configured output value into the
> output AVFrame's color_range.
> ---
>  libavfilter/vf_scale.c | 51 +-
>  1 file changed, 50 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index 58eee96744..592e4a344e 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -750,11 +750,30 @@ scale:
>  || in_range != AVCOL_RANGE_UNSPECIFIED
>  || scale->out_range != AVCOL_RANGE_UNSPECIFIED) {
>  int in_full, out_full, brightness, contrast, saturation;
> +int configured_in_full_range_flag, configured_out_full_range_flag;
>  const int *inv_table, *table;
> +const AVPixFmtDescriptor *in_desc  = av_pix_fmt_desc_get(in->format);
> +const AVPixFmtDescriptor *out_desc = 
> av_pix_fmt_desc_get(out->format);

> +if (!in_desc || !out_desc) {
> +av_log(ctx, AV_LOG_ERROR,
> +   "Failed to get one or more of the pixel format 
> descriptors "
> +   "for formats - in: %d (%s), out: %d (%s)!\n",
> +   in->format, in_desc ? "OK" : "bad",
> +   out->format, out_desc ? "OK": "bad");
> +av_frame_free();
> +av_frame_free(frame_out);
> +return AVERROR_INVALIDDATA;
> +}

can this be true ?


>  
>  sws_getColorspaceDetails(scale->sws, (int **)_table, _full,
>   (int **), _full,
>   , , );

> +// translate the swscale internal range flags to hold true
> +// for RGB

The range field of AVFrame is documented as
"MPEG vs JPEG YUV range."

so it is not defined for RGB and cannot be "wrong" for RGB
maybe iam nitpicking here but if you want to use the range for RGB
the API docs need to be changed first.

I mean you could set it to 1 for RGB thats ok without a API
docs change. But writing in a comment that one way is correct for RGB is not
compatible with the current documentation

thx

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

The day soldiers stop bringing you their problems is the day you have stopped 
leading them. They have either lost confidence that you can help or concluded 
you do not care. Either case is a failure of leadership. - Colin Powell


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] avfilter/vf_scale: set RGB to always be full range

2020-09-17 Thread Michael Niedermayer
On Thu, Sep 17, 2020 at 11:10:29AM +0100, Kevin Wheatley wrote:
> On Wed, Sep 16, 2020 at 9:43 PM Jan Ekström  wrote:
> >
> > On Wed, Sep 16, 2020 at 11:38 PM Michael Niedermayer
> >  wrote:
> > > Does anything document the meaning of range or AVCOL_RANGE for RGB ?
> > > The enum is documented as "MPEG vs JPEG YUV range."
> > >
> > > What is limited range RGB ? what would the ranges of R,G,B be and where
> > > is that specified ?
> 
> EBU only describes full range for 'file' based images
> 
> https://tech.ebu.ch/docs/r/r103.pdf
> 
> but ITU 
> https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-2-201807-I!!PDF-E.pdf

thanks for the links!

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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] libavformat/rmdec.c: Fix Use-of-uninitialized-value in ff_codec_get_id

2020-09-17 Thread Michael Niedermayer
On Mon, Sep 14, 2020 at 10:49:00AM -0700, Thierry Foucu wrote:
> In case the pb does not contain 4 bytes, the buf[256] will not be
> initialize before we pass it to ff_codec_get_id
> ---
>  libavformat/rmdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
> index a36e693ab2..220aa8aee2 100644
> --- a/libavformat/rmdec.c
> +++ b/libavformat/rmdec.c
> @@ -180,12 +180,12 @@ static int rm_read_audio_stream_info(AVFormatContext 
> *s, AVIOContext *pb,
>  st->codecpar->sample_rate = avio_rb16(pb);
>  avio_rb32(pb);
>  st->codecpar->channels = avio_rb16(pb);
> +AV_WL32(buf, 0);
>  if (version == 5) {
>  ast->deint_id = avio_rl32(pb);

>  avio_read(pb, buf, 4);

I think the avio_read() return code should be checked instead

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] avformat/aviobuf: fix broken logic in ffio_ensure_seekback()

2020-09-17 Thread Marton Balint



On Thu, 17 Sep 2020, Paul B Mahol wrote:


This removes big CPU overhead for demuxing chained ogg streams.

Signed-off-by: Paul B Mahol 
---
libavformat/aviobuf.c | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a77517d712..ce9b7d59c9 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -996,20 +996,20 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
uint8_t *buffer;
int max_buffer_size = s->max_packet_size ?
  s->max_packet_size : IO_BUFFER_SIZE;
-int filled = s->buf_end - s->buffer;
ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
s->buffer : -1;

-buf_size += s->buf_ptr - s->buffer + max_buffer_size;
-
-if (buf_size < filled || s->seekable || !s->read_packet)
+if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
return 0;


This is still not correct. You can only return if
buf_size <= s->buf_end - s->buf_ptr
OR
buf_size <= s->buffer + s->buffer_size - s->buf_ptr - max_buffer_size + 1

And the new minimum buffer size is what is calculated now, so that should 
not be changed.


I am not sure if this fixes you original issue. It might make sense to 
allocate max_buffer_size*2 length buffers by default, but the buffer size 
revert logic must be fixed to support that...


Regards,
Marton




+buf_size += s->buffer_size;
+buf_size = FFMAX(buf_size, max_buffer_size);
+
av_assert0(!s->write_flag);

buffer = av_malloc(buf_size);
if (!buffer)
return AVERROR(ENOMEM);

-memcpy(buffer, s->buffer, filled);
+memcpy(buffer, s->buffer, s->buffer_size);
av_free(s->buffer);
s->buf_ptr = buffer + (s->buf_ptr - s->buffer);
s->buf_end = buffer + (s->buf_end - s->buffer);
--
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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2] avcodec/h264_slice: sync User Data Unregistered SEI buffers across threads

2020-09-17 Thread James Almer
Signed-off-by: James Almer 
---
Now it also updates the x264_build field.

 libavcodec/h264_slice.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cfc29e186c..f091cd4dc1 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -439,6 +439,26 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 return AVERROR(ENOMEM);
 }
 
+for (i = 0; i < h->sei.unregistered.nb_buf_ref; i++)
+av_buffer_unref(>sei.unregistered.buf_ref[i]);
+h->sei.unregistered.nb_buf_ref = 0;
+
+if (h1->sei.unregistered.nb_buf_ref) {
+ret = av_reallocp_array(>sei.unregistered.buf_ref,
+h1->sei.unregistered.nb_buf_ref,
+sizeof(*h1->sei.unregistered.buf_ref));
+if (ret < 0)
+return ret;
+
+for (i = 0; i < h1->sei.unregistered.nb_buf_ref; i++) {
+h->sei.unregistered.buf_ref[i] = 
av_buffer_ref(h1->sei.unregistered.buf_ref[i]);
+if (!h->sei.unregistered.buf_ref[i])
+return AVERROR(ENOMEM);
+h->sei.unregistered.nb_buf_ref++;
+}
+}
+h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
+
 if (!h->cur_pic_ptr)
 return 0;
 
-- 
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] avcodec/h264_slice: sync User Data Unregistered SEI buffers across threads

2020-09-17 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/h264_slice.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cfc29e186c..bb95a92792 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -439,6 +439,25 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 return AVERROR(ENOMEM);
 }
 
+for (i = 0; i < h->sei.unregistered.nb_buf_ref; i++)
+av_buffer_unref(>sei.unregistered.buf_ref[i]);
+h->sei.unregistered.nb_buf_ref = 0;
+
+if (h1->sei.unregistered.nb_buf_ref) {
+ret = av_reallocp_array(>sei.unregistered.buf_ref,
+h1->sei.unregistered.nb_buf_ref,
+sizeof(*h1->sei.unregistered.buf_ref));
+if (ret < 0)
+return ret;
+
+for (i = 0; i < h1->sei.unregistered.nb_buf_ref; i++) {
+h->sei.unregistered.buf_ref[i] = 
av_buffer_ref(h1->sei.unregistered.buf_ref[i]);
+if (!h->sei.unregistered.buf_ref[i])
+return AVERROR(ENOMEM);
+h->sei.unregistered.nb_buf_ref++;
+}
+}
+
 if (!h->cur_pic_ptr)
 return 0;
 
-- 
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] avcodec/svq1dec: use av_malloc_array() to allocate pmv

2020-09-17 Thread Guangxin Xu
On Thu, Sep 17, 2020 at 10:00 PM Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/svq1dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
> index 25bd3d0253..ddd02f354e 100644
> --- a/libavcodec/svq1dec.c
> +++ b/libavcodec/svq1dec.c
> @@ -679,7 +679,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
> void *data,
>  if (result < 0)
>  return result;
>
> -pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv));
> +pmv = av_malloc_array((FFALIGN(s->width, 16) / 8 + 3), sizeof(*pmv));
>
nit, the() for first param is not needed.


>  if (!pmv)
>  return AVERROR(ENOMEM);
>
> --
> 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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/hevcdec: sync User Data Unregistered SEI buffers across threads

2020-09-17 Thread Guangxin Xu
On Thu, Sep 17, 2020 at 11:09 PM James Almer  wrote:

> On 9/17/2020 10:59 AM, Guangxin Xu wrote:
> > On Thu, Sep 17, 2020 at 9:35 PM James Almer  wrote:
> >
> >> Signed-off-by: James Almer 
> >> ---
> >>  libavcodec/hevcdec.c | 19 +++
> >>  1 file changed, 19 insertions(+)
> >>
> >> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> >> index 1f3ea54d39..2481730788 100644
> >> --- a/libavcodec/hevcdec.c
> >> +++ b/libavcodec/hevcdec.c
> >> @@ -3548,6 +3548,25 @@ static int
> >> hevc_update_thread_context(AVCodecContext *dst,
> >>  return AVERROR(ENOMEM);
> >>  }
> >>
> >> +for (i = 0; i < s->sei.unregistered.nb_buf_ref; i++)
> >> +av_buffer_unref(>sei.unregistered.buf_ref[i]);
> >> +s->sei.unregistered.nb_buf_ref = 0;
> >>
> > Is it possible to define a new function ff_hevc_reset_sei_unregistered,
> > then we can reuse the function here and in ff_hevc_reset_sei?
>
> I don't think it's worth doing for only three lines.
>
> >
> >
> >> +
> >> +if (s0->sei.unregistered.nb_buf_ref) {
> >> +ret = av_reallocp_array(>sei.unregistered.buf_ref,
> >> +s0->sei.unregistered.nb_buf_ref,
> >> +sizeof(*s0->sei.unregistered.buf_ref));
> >>
> > This will call copy  >sei.unregistered.buf_ref,  but it's not needed.
>
> I made it this way since when both contexts have an allocated buffer of
> the same size or smaller, the call will basically be a no-op and faster
> than a free() + malloc().
>
In this case,  it's should be ok, thanks for explaining.


> I don't know how often that can be, considering the buffer will be freed
> after generating an output frame, so I can change it before pushing if
> you prefer the alternative.
>
> >
> > +if (ret < 0)
> >> +return ret;
> >> +
> >> +for (i = 0; i < s0->sei.unregistered.nb_buf_ref; i++) {
> >> +s->sei.unregistered.buf_ref[i] =
> >> av_buffer_ref(s0->sei.unregistered.buf_ref[i]);
> >> +if (!s->sei.unregistered.buf_ref[i])
> >> +return AVERROR(ENOMEM);
> >> +s->sei.unregistered.nb_buf_ref++;
> >> +}
> >> +}
> >> +
> >>  s->sei.frame_packing= s0->sei.frame_packing;
> >>  s->sei.display_orientation  = s0->sei.display_orientation;
> >>  s->sei.mastering_display= s0->sei.mastering_display;
> >> --
> >> 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 mailing list
> > ffmpeg-devel@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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/svq1dec: use av_malloc_array() to allocate pmv

2020-09-17 Thread James Almer
On 9/17/2020 10:59 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/svq1dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
> index 25bd3d0253..ddd02f354e 100644
> --- a/libavcodec/svq1dec.c
> +++ b/libavcodec/svq1dec.c
> @@ -679,7 +679,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void 
> *data,
>  if (result < 0)
>  return result;
>  
> -pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv));
> +pmv = av_malloc_array((FFALIGN(s->width, 16) / 8 + 3), sizeof(*pmv));
>  if (!pmv)
>  return AVERROR(ENOMEM);

LGTM. And this is trivial, no need to send a patch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/hevcdec: sync User Data Unregistered SEI buffers across threads

2020-09-17 Thread James Almer
On 9/17/2020 10:59 AM, Guangxin Xu wrote:
> On Thu, Sep 17, 2020 at 9:35 PM James Almer  wrote:
> 
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/hevcdec.c | 19 +++
>>  1 file changed, 19 insertions(+)
>>
>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
>> index 1f3ea54d39..2481730788 100644
>> --- a/libavcodec/hevcdec.c
>> +++ b/libavcodec/hevcdec.c
>> @@ -3548,6 +3548,25 @@ static int
>> hevc_update_thread_context(AVCodecContext *dst,
>>  return AVERROR(ENOMEM);
>>  }
>>
>> +for (i = 0; i < s->sei.unregistered.nb_buf_ref; i++)
>> +av_buffer_unref(>sei.unregistered.buf_ref[i]);
>> +s->sei.unregistered.nb_buf_ref = 0;
>>
> Is it possible to define a new function ff_hevc_reset_sei_unregistered,
> then we can reuse the function here and in ff_hevc_reset_sei?

I don't think it's worth doing for only three lines.

> 
> 
>> +
>> +if (s0->sei.unregistered.nb_buf_ref) {
>> +ret = av_reallocp_array(>sei.unregistered.buf_ref,
>> +s0->sei.unregistered.nb_buf_ref,
>> +sizeof(*s0->sei.unregistered.buf_ref));
>>
> This will call copy  >sei.unregistered.buf_ref,  but it's not needed.

I made it this way since when both contexts have an allocated buffer of
the same size or smaller, the call will basically be a no-op and faster
than a free() + malloc().
I don't know how often that can be, considering the buffer will be freed
after generating an output frame, so I can change it before pushing if
you prefer the alternative.

> 
> +if (ret < 0)
>> +return ret;
>> +
>> +for (i = 0; i < s0->sei.unregistered.nb_buf_ref; i++) {
>> +s->sei.unregistered.buf_ref[i] =
>> av_buffer_ref(s0->sei.unregistered.buf_ref[i]);
>> +if (!s->sei.unregistered.buf_ref[i])
>> +return AVERROR(ENOMEM);
>> +s->sei.unregistered.nb_buf_ref++;
>> +}
>> +}
>> +
>>  s->sei.frame_packing= s0->sei.frame_packing;
>>  s->sei.display_orientation  = s0->sei.display_orientation;
>>  s->sei.mastering_display= s0->sei.mastering_display;
>> --
>> 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 mailing list
> ffmpeg-devel@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 2/2] avcodec/hevcdec: sync User Data Unregistered SEI buffers across threads

2020-09-17 Thread Guangxin Xu
On Thu, Sep 17, 2020 at 9:35 PM James Almer  wrote:

> Signed-off-by: James Almer 
> ---
>  libavcodec/hevcdec.c | 19 +++
>  1 file changed, 19 insertions(+)
>
> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> index 1f3ea54d39..2481730788 100644
> --- a/libavcodec/hevcdec.c
> +++ b/libavcodec/hevcdec.c
> @@ -3548,6 +3548,25 @@ static int
> hevc_update_thread_context(AVCodecContext *dst,
>  return AVERROR(ENOMEM);
>  }
>
> +for (i = 0; i < s->sei.unregistered.nb_buf_ref; i++)
> +av_buffer_unref(>sei.unregistered.buf_ref[i]);
> +s->sei.unregistered.nb_buf_ref = 0;
>
Is it possible to define a new function ff_hevc_reset_sei_unregistered,
then we can reuse the function here and in ff_hevc_reset_sei?


> +
> +if (s0->sei.unregistered.nb_buf_ref) {
> +ret = av_reallocp_array(>sei.unregistered.buf_ref,
> +s0->sei.unregistered.nb_buf_ref,
> +sizeof(*s0->sei.unregistered.buf_ref));
>
This will call copy  >sei.unregistered.buf_ref,  but it's not needed.

+if (ret < 0)
> +return ret;
> +
> +for (i = 0; i < s0->sei.unregistered.nb_buf_ref; i++) {
> +s->sei.unregistered.buf_ref[i] =
> av_buffer_ref(s0->sei.unregistered.buf_ref[i]);
> +if (!s->sei.unregistered.buf_ref[i])
> +return AVERROR(ENOMEM);
> +s->sei.unregistered.nb_buf_ref++;
> +}
> +}
> +
>  s->sei.frame_packing= s0->sei.frame_packing;
>  s->sei.display_orientation  = s0->sei.display_orientation;
>  s->sei.mastering_display= s0->sei.mastering_display;
> --
> 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 mailing list
ffmpeg-devel@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/svq1dec: use av_malloc_array() to allocate pmv

2020-09-17 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/svq1dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
index 25bd3d0253..ddd02f354e 100644
--- a/libavcodec/svq1dec.c
+++ b/libavcodec/svq1dec.c
@@ -679,7 +679,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void 
*data,
 if (result < 0)
 return result;
 
-pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv));
+pmv = av_malloc_array((FFALIGN(s->width, 16) / 8 + 3), sizeof(*pmv));
 if (!pmv)
 return AVERROR(ENOMEM);
 
-- 
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/hevcdec: sync SEI derived AVCodecContext fields across threads

2020-09-17 Thread James Almer
Fixes ticket #8610.

Found-by: Pavel Koshevoy 
Signed-off-by: James Almer 
---
 libavcodec/hevcdec.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index c1de75abe1..1f3ea54d39 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -369,12 +369,22 @@ static void export_stream_params(HEVCContext *s, const 
HEVCSPS *sps)
 if (num != 0 && den != 0)
 av_reduce(>framerate.den, >framerate.num,
   num, den, 1 << 30);
+}
+
+static int export_stream_params_from_sei(HEVCContext *s)
+{
+AVCodecContext *avctx = s->avctx;
+
+if (s->sei.a53_caption.buf_ref)
+s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 
 if (s->sei.alternative_transfer.present &&
 
av_color_transfer_name(s->sei.alternative_transfer.preferred_transfer_characteristics)
 &&
 s->sei.alternative_transfer.preferred_transfer_characteristics != 
AVCOL_TRC_UNSPECIFIED) {
 avctx->color_trc = 
s->sei.alternative_transfer.preferred_transfer_characteristics;
 }
+
+return 0;
 }
 
 static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
@@ -582,6 +592,10 @@ static int hls_slice_header(HEVCContext *s)
 s->max_ra = INT_MAX;
 }
 
+ret = export_stream_params_from_sei(s);
+if (ret < 0)
+return ret;
+
 sh->dependent_slice_segment_flag = 0;
 if (!sh->first_slice_in_pic_flag) {
 int slice_address_length;
@@ -2806,8 +2820,6 @@ static int set_side_data(HEVCContext *s)
 if (!sd)
 av_buffer_unref(>buf_ref);
 a53->buf_ref = NULL;
-
-s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
 }
 
 for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) {
@@ -3250,6 +3262,11 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t 
*buf, int length, int f
 }
 }
 
+/* export stream parameters from SEI */
+ret = export_stream_params_from_sei(s);
+if (ret < 0)
+return ret;
+
 return 0;
 }
 
@@ -3537,6 +3554,10 @@ static int hevc_update_thread_context(AVCodecContext 
*dst,
 s->sei.content_light= s0->sei.content_light;
 s->sei.alternative_transfer = s0->sei.alternative_transfer;
 
+ret = export_stream_params_from_sei(s);
+if (ret < 0)
+return ret;
+
 return 0;
 }
 #endif
-- 
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 2/2] avcodec/hevcdec: sync User Data Unregistered SEI buffers across threads

2020-09-17 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/hevcdec.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 1f3ea54d39..2481730788 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3548,6 +3548,25 @@ static int hevc_update_thread_context(AVCodecContext 
*dst,
 return AVERROR(ENOMEM);
 }
 
+for (i = 0; i < s->sei.unregistered.nb_buf_ref; i++)
+av_buffer_unref(>sei.unregistered.buf_ref[i]);
+s->sei.unregistered.nb_buf_ref = 0;
+
+if (s0->sei.unregistered.nb_buf_ref) {
+ret = av_reallocp_array(>sei.unregistered.buf_ref,
+s0->sei.unregistered.nb_buf_ref,
+sizeof(*s0->sei.unregistered.buf_ref));
+if (ret < 0)
+return ret;
+
+for (i = 0; i < s0->sei.unregistered.nb_buf_ref; i++) {
+s->sei.unregistered.buf_ref[i] = 
av_buffer_ref(s0->sei.unregistered.buf_ref[i]);
+if (!s->sei.unregistered.buf_ref[i])
+return AVERROR(ENOMEM);
+s->sei.unregistered.nb_buf_ref++;
+}
+}
+
 s->sei.frame_packing= s0->sei.frame_packing;
 s->sei.display_orientation  = s0->sei.display_orientation;
 s->sei.mastering_display= s0->sei.mastering_display;
-- 
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 v3 2/2] dnn_backend_native_layer_conv2d.c: refine code.

2020-09-17 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Hendrik
> Leppkes
> Sent: 2020年9月17日 20:28
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v3 2/2]
> dnn_backend_native_layer_conv2d.c: refine code.
> 
> On Thu, Sep 17, 2020 at 2:02 PM Guo, Yejun  wrote:
> >
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Hendrik Leppkes
> > > Sent: 2020年9月17日 19:21
> > > To: FFmpeg development discussions and patches
> > > 
> > > Subject: Re: [FFmpeg-devel] [PATCH v3 2/2]
> > > dnn_backend_native_layer_conv2d.c: refine code.
> > >
> > > On Thu, Sep 17, 2020 at 4:07 AM Guo, Yejun  wrote:
> > > >
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: ffmpeg-devel  On Behalf
> > > > > Of xuju...@sjtu.edu.cn
> > > > > Sent: 2020年9月16日 18:07
> > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > Cc: xuju...@sjtu.edu.cn
> > > > > Subject: [FFmpeg-devel] [PATCH v3 2/2]
> > > dnn_backend_native_layer_conv2d.c:
> > > > > refine code.
> > > > >
> > > > > From: Xu Jun 
> > > > >
> > > > > Move thread area allocate out of thread function into main thread.
> > > > >
> > > > > Signed-off-by: Xu Jun 
> > > > > ---
> > > > >  .../dnn/dnn_backend_native_layer_conv2d.c | 30
> +--
> > > > >  1 file changed, 14 insertions(+), 16 deletions(-)
> > > >
> > > > LGTM, will push soon, thanks.
> > >
> > > The dnn-layer-conv2d test fails after the recent changes on some
> > > systems,
> > > namely:
> > >
> > > Windows mingw 64-bit (eg.
> > > http://fate.ffmpeg.org/report.cgi?time=20200917051623=x86_64-mi
> > > ngw-
> > > w64-windows-native)
> > > MSVC 32-bit static build (eg.
> > > http://fate.ffmpeg.org/report.cgi?time=20200917102627=x86_32-ms
> > > vc16
> > > -windows-native)
> > > and maybe more windows combination, some of my boxes are still running
> FATE.
> > >
> > > There is no output, just a wrong return value apparently. Any ideas/fixes?
> > >
> > thanks for pointing out.
> >
> > I think the output is in file dnn-layer-conv2d.err "Test
> > dnn-layer-conv2d failed. Look at tests/data/fate/dnn-layer-conv2d.err for
> details."
> >
> 
> There is no output, all these files are empty.
> 
I see, and we are setting up the system locally to reproduce the issue.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] avocdec/hevcdec: set SEI derived AVCodecContext fields as soon as they are parsed

2020-09-17 Thread James Almer
On 9/16/2020 9:36 PM, James Almer wrote:
> export_stream_params() may not be called in some scenarios, for example 
> leaving
> both the AVCodecContext and subsequent output frames with the color_trc value
> taken from the VUI instead of the Alternative Transfer Characteristics SEI.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/hevcdec.c | 27 +++
>  1 file changed, 19 insertions(+), 8 deletions(-)

Ignore this patch. Will send a better version that syncs the fields
across threads.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3 2/2] dnn_backend_native_layer_conv2d.c: refine code.

2020-09-17 Thread Hendrik Leppkes
On Thu, Sep 17, 2020 at 2:02 PM Guo, Yejun  wrote:
>
>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of Hendrik
> > Leppkes
> > Sent: 2020年9月17日 19:21
> > To: FFmpeg development discussions and patches 
> > Subject: Re: [FFmpeg-devel] [PATCH v3 2/2]
> > dnn_backend_native_layer_conv2d.c: refine code.
> >
> > On Thu, Sep 17, 2020 at 4:07 AM Guo, Yejun  wrote:
> > >
> > >
> > >
> > > > -Original Message-
> > > > From: ffmpeg-devel  On Behalf Of
> > > > xuju...@sjtu.edu.cn
> > > > Sent: 2020年9月16日 18:07
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: xuju...@sjtu.edu.cn
> > > > Subject: [FFmpeg-devel] [PATCH v3 2/2]
> > dnn_backend_native_layer_conv2d.c:
> > > > refine code.
> > > >
> > > > From: Xu Jun 
> > > >
> > > > Move thread area allocate out of thread function into main thread.
> > > >
> > > > Signed-off-by: Xu Jun 
> > > > ---
> > > >  .../dnn/dnn_backend_native_layer_conv2d.c | 30 +--
> > > >  1 file changed, 14 insertions(+), 16 deletions(-)
> > >
> > > LGTM, will push soon, thanks.
> >
> > The dnn-layer-conv2d test fails after the recent changes on some systems,
> > namely:
> >
> > Windows mingw 64-bit (eg.
> > http://fate.ffmpeg.org/report.cgi?time=20200917051623=x86_64-mingw-
> > w64-windows-native)
> > MSVC 32-bit static build (eg.
> > http://fate.ffmpeg.org/report.cgi?time=20200917102627=x86_32-msvc16
> > -windows-native)
> > and maybe more windows combination, some of my boxes are still running FATE.
> >
> > There is no output, just a wrong return value apparently. Any ideas/fixes?
> >
> thanks for pointing out.
>
> I think the output is in file dnn-layer-conv2d.err
> "Test dnn-layer-conv2d failed. Look at tests/data/fate/dnn-layer-conv2d.err 
> for details."
>

There is no output, all these files are empty.

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

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

Re: [FFmpeg-devel] [PATCH v3 2/2] dnn_backend_native_layer_conv2d.c: refine code.

2020-09-17 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Hendrik
> Leppkes
> Sent: 2020年9月17日 19:21
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v3 2/2]
> dnn_backend_native_layer_conv2d.c: refine code.
> 
> On Thu, Sep 17, 2020 at 4:07 AM Guo, Yejun  wrote:
> >
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > xuju...@sjtu.edu.cn
> > > Sent: 2020年9月16日 18:07
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: xuju...@sjtu.edu.cn
> > > Subject: [FFmpeg-devel] [PATCH v3 2/2]
> dnn_backend_native_layer_conv2d.c:
> > > refine code.
> > >
> > > From: Xu Jun 
> > >
> > > Move thread area allocate out of thread function into main thread.
> > >
> > > Signed-off-by: Xu Jun 
> > > ---
> > >  .../dnn/dnn_backend_native_layer_conv2d.c | 30 +--
> > >  1 file changed, 14 insertions(+), 16 deletions(-)
> >
> > LGTM, will push soon, thanks.
> 
> The dnn-layer-conv2d test fails after the recent changes on some systems,
> namely:
> 
> Windows mingw 64-bit (eg.
> http://fate.ffmpeg.org/report.cgi?time=20200917051623=x86_64-mingw-
> w64-windows-native)
> MSVC 32-bit static build (eg.
> http://fate.ffmpeg.org/report.cgi?time=20200917102627=x86_32-msvc16
> -windows-native)
> and maybe more windows combination, some of my boxes are still running FATE.
> 
> There is no output, just a wrong return value apparently. Any ideas/fixes?
> 
thanks for pointing out.

I think the output is in file dnn-layer-conv2d.err
"Test dnn-layer-conv2d failed. Look at tests/data/fate/dnn-layer-conv2d.err for 
details."

Does anyone have such system and can lend me for a while? I can quickly have a 
debug, thanks.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/videotoolboxenc: fix use after destroy

2020-09-17 Thread Richard Kern


> On Sep 10, 2020, at 11:13 AM, Zhao Zhili  wrote:
> 
> 
>> 在 2020年9月10日,下午10:21,Richard Kern  写道:
>> 
>> 
>> 
 On Sep 10, 2020, at 8:57 AM, zhilizhao  wrote:
>>> 
>>> 
>>> 
> On Aug 28, 2020, at 8:55 AM, Steven Liu  wrote:
 
  于2020年8月27日周四 下午5:39写道:
> 
> From: Zhao Zhili 
> 
> The lock is used in clear_frame_queue().
> ---
> libavcodec/videotoolboxenc.c | 11 +++
> 1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 988782f10d..758db9641f 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -2496,14 +2496,17 @@ static av_cold int vtenc_close(AVCodecContext 
> *avctx)
> {
>  VTEncContext *vtctx = avctx->priv_data;
> 
> -pthread_cond_destroy(>cv_sample_sent);
> -pthread_mutex_destroy(>lock);
> -
> -if(!vtctx->session) return 0;
> +if(!vtctx->session) {
> +pthread_cond_destroy(>cv_sample_sent);
> +pthread_mutex_destroy(>lock);
> +return 0;
> +}
> 
>  VTCompressionSessionCompleteFrames(vtctx->session,
> kCMTimeIndefinite);
>  clear_frame_queue(vtctx);
> +pthread_cond_destroy(>cv_sample_sent);
> +pthread_mutex_destroy(>lock);
>  CFRelease(vtctx->session);
>  vtctx->session = 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".
 
 
 This patch look better than
 https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200827025327.28334-1...@chinaffmpeg.org/
 
>>> 
>>> Ping for the patch set.
>> Can you provide steps to reproduce the deadlock issue? I can get it pushed 
>> this weekend if so. 
> 
> I only try to fix a use after destroy issue as the commit message says.
> It may solved another issue unintentional. Liu, could you help by giving
> more information about the deadlock issue, please.
I’ll figure out a way to reproduce this in the next few days and get these 
patches pushed. 

> 
>>> 
 
 Thanks
 Steven
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@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 mailing list
>> ffmpeg-devel@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 mailing list
ffmpeg-devel@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] avformat/img2enc: add strftime_mkdir option to automatically create time-based directories

2020-09-17 Thread xiaofeng
-- 
xiaofeng

--
gpg key fingerprint:
2048R/5E63005B
C84F 671F 70B7 7330 4726  5EC8 02BC CBA2 5E63 005B
--
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
From 1d8e36f2231a03999d874a6915d042b0ebbe3d68 Mon Sep 17 00:00:00 2001
From: wxf 
Date: Thu, 17 Sep 2020 19:20:31 +0800
Subject: [PATCH] avformat/img2enc: add strftime_mkdir option to automatically
 create time-based directories

Signed-off-by: wxf 
---
 libavformat/img2enc.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index b303d38239..10ffb227a9 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -42,6 +42,7 @@ typedef struct VideoMuxData {
 char target[4][1024];
 int update;
 int use_strftime;
+int use_strftime_mkdir;
 int frame_pts;
 const char *muxer;
 int use_rename;
@@ -147,6 +148,19 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 av_log(s, AV_LOG_ERROR, "Could not get frame filename with strftime\n");
 return AVERROR(EINVAL);
 }
+if (img->use_strftime_mkdir) {
+const char *dir;
+char *fn_copy = av_strdup(filename);
+if (!fn_copy)
+return AVERROR(ENOMEM);
+dir = av_dirname(fn_copy);
+if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
+av_log(s, AV_LOG_ERROR, "Could not create directory %s with use_strftime_mkdir\n", dir);
+av_freep(_copy);
+return AVERROR(errno);
+}
+av_freep(_copy);
+}
 } else if (img->frame_pts) {
 if (av_get_frame_filename2(filename, sizeof(filename), img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
 av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames.");
@@ -243,6 +257,7 @@ static const AVOption muxoptions[] = {
 { "update",   "continuously overwrite one file", OFFSET(update),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0,   1, ENC },
 { "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT,  { .i64 = 1 }, 0, INT_MAX, ENC },
 { "strftime", "use strftime for filename", OFFSET(use_strftime),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
+{ "strftime_mkdir", "create last directory component in strftime-generated filename", OFFSET(use_strftime_mkdir),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
 { "frame_pts","use current frame pts for filename", OFFSET(frame_pts),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
 { "atomic_writing", "write files atomically (using temporary files and renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
 { "protocol_opts", "specify protocol options for the opened files", OFFSET(protocol_opts), AV_OPT_TYPE_DICT, {0}, 0, 0, ENC },
-- 
2.18.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 v3 2/2] dnn_backend_native_layer_conv2d.c: refine code.

2020-09-17 Thread Hendrik Leppkes
On Thu, Sep 17, 2020 at 4:07 AM Guo, Yejun  wrote:
>
>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > xuju...@sjtu.edu.cn
> > Sent: 2020年9月16日 18:07
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: xuju...@sjtu.edu.cn
> > Subject: [FFmpeg-devel] [PATCH v3 2/2] dnn_backend_native_layer_conv2d.c:
> > refine code.
> >
> > From: Xu Jun 
> >
> > Move thread area allocate out of thread function into main thread.
> >
> > Signed-off-by: Xu Jun 
> > ---
> >  .../dnn/dnn_backend_native_layer_conv2d.c | 30 +--
> >  1 file changed, 14 insertions(+), 16 deletions(-)
>
> LGTM, will push soon, thanks.

The dnn-layer-conv2d test fails after the recent changes on some
systems, namely:

Windows mingw 64-bit (eg.
http://fate.ffmpeg.org/report.cgi?time=20200917051623=x86_64-mingw-w64-windows-native)
MSVC 32-bit static build (eg.
http://fate.ffmpeg.org/report.cgi?time=20200917102627=x86_32-msvc16-windows-native)
and maybe more windows combination, some of my boxes are still running FATE.

There is no output, just a wrong return value apparently. Any ideas/fixes?

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

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

Re: [FFmpeg-devel] [PATCH] avformat: add CRI AAX demuxer

2020-09-17 Thread Paul B Mahol
On Sun, Sep 13, 2020 at 08:01:33PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/adxdec.c  |  16 ++
>  libavformat/Makefile |   1 +
>  libavformat/aaxdec.c | 377 +++
>  libavformat/allformats.c |   1 +
>  4 files changed, 395 insertions(+)
>  create mode 100644 libavformat/aaxdec.c
> 

gonna apply
___
ffmpeg-devel mailing list
ffmpeg-devel@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] avfilter/vf_scale: set RGB to always be full range

2020-09-17 Thread Kevin Wheatley
On Wed, Sep 16, 2020 at 9:43 PM Jan Ekström  wrote:
>
> On Wed, Sep 16, 2020 at 11:38 PM Michael Niedermayer
>  wrote:
> > Does anything document the meaning of range or AVCOL_RANGE for RGB ?
> > The enum is documented as "MPEG vs JPEG YUV range."
> >
> > What is limited range RGB ? what would the ranges of R,G,B be and where
> > is that specified ?

EBU only describes full range for 'file' based images

https://tech.ebu.ch/docs/r/r103.pdf

but ITU 
https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-2-201807-I!!PDF-E.pdf

does describe narrow range RGB on p9

Kevin
___
ffmpeg-devel mailing list
ffmpeg-devel@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/aviobuf: fix broken logic in ffio_ensure_seekback()

2020-09-17 Thread Paul B Mahol
This removes big CPU overhead for demuxing chained ogg streams.

Signed-off-by: Paul B Mahol 
---
 libavformat/aviobuf.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a77517d712..ce9b7d59c9 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -996,20 +996,20 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
 uint8_t *buffer;
 int max_buffer_size = s->max_packet_size ?
   s->max_packet_size : IO_BUFFER_SIZE;
-int filled = s->buf_end - s->buffer;
 ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
s->buffer : -1;
 
-buf_size += s->buf_ptr - s->buffer + max_buffer_size;
-
-if (buf_size < filled || s->seekable || !s->read_packet)
+if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
 return 0;
+buf_size += s->buffer_size;
+buf_size = FFMAX(buf_size, max_buffer_size);
+
 av_assert0(!s->write_flag);
 
 buffer = av_malloc(buf_size);
 if (!buffer)
 return AVERROR(ENOMEM);
 
-memcpy(buffer, s->buffer, filled);
+memcpy(buffer, s->buffer, s->buffer_size);
 av_free(s->buffer);
 s->buf_ptr = buffer + (s->buf_ptr - s->buffer);
 s->buf_end = buffer + (s->buf_end - s->buffer);
-- 
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] avcodec/av1dec: check avctx->hwaccel when hwaccel pix_fmt selected

2020-09-17 Thread Hendrik Leppkes
On Thu, Sep 17, 2020 at 10:38 AM Fei Wang  wrote:
>
> Pix fmt with hwaccel flag may not be chosen in format probing, in
> this case avctx->hwaccel will not be inited.
>
> Signed-off-by: Fei Wang 
> ---
>  libavcodec/av1dec.c | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index 0bb04a3e44..cdcc618013 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -251,6 +251,7 @@ static int get_pixel_format(AVCodecContext *avctx)
>  {
>  AV1DecContext *s = avctx->priv_data;
>  const AV1RawSequenceHeader *seq = s->raw_seq;
> +const AVPixFmtDescriptor *desc;
>  uint8_t bit_depth;
>  int ret;
>  enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
> @@ -327,10 +328,13 @@ static int get_pixel_format(AVCodecContext *avctx)
>   * Since now the av1 decoder doesn't support native decode, if it will be
>   * implemented in the future, need remove this check.
>   */
> -if (!avctx->hwaccel) {
> -av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
> -   " hardware accelerated AV1 decoding.\n");
> -return AVERROR(ENOSYS);
> +desc = av_pix_fmt_desc_get(ret);
> +if (desc && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
> +if (!avctx->hwaccel) {
> +av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
> +   " hardware accelerated AV1 decoding.\n");
> +return AVERROR(ENOSYS);
> +}
>  }
>

Isn't it supposed to quit here, because we do not have software decoding?

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

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

[FFmpeg-devel] [PATCH] avcodec/av1dec: check avctx->hwaccel when hwaccel pix_fmt selected

2020-09-17 Thread Fei Wang
Pix fmt with hwaccel flag may not be chosen in format probing, in
this case avctx->hwaccel will not be inited.

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

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 0bb04a3e44..cdcc618013 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -251,6 +251,7 @@ static int get_pixel_format(AVCodecContext *avctx)
 {
 AV1DecContext *s = avctx->priv_data;
 const AV1RawSequenceHeader *seq = s->raw_seq;
+const AVPixFmtDescriptor *desc;
 uint8_t bit_depth;
 int ret;
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
@@ -327,10 +328,13 @@ static int get_pixel_format(AVCodecContext *avctx)
  * Since now the av1 decoder doesn't support native decode, if it will be
  * implemented in the future, need remove this check.
  */
-if (!avctx->hwaccel) {
-av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
-   " hardware accelerated AV1 decoding.\n");
-return AVERROR(ENOSYS);
+desc = av_pix_fmt_desc_get(ret);
+if (desc && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+if (!avctx->hwaccel) {
+av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
+   " hardware accelerated AV1 decoding.\n");
+return AVERROR(ENOSYS);
+}
 }
 
 avctx->pix_fmt = ret;
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/av1dec: Check tiles sizes, fix assert, don't read bytes bitwise

2020-09-17 Thread Wang, Fei W


> -Original Message-
> From: ffmpeg-devel  On Behalf Of James
> Almer
> Sent: Thursday, September 17, 2020 11:37 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/av1dec: Check tiles sizes, fix
> assert, don't read bytes bitwise
> 
> On 9/17/2020 12:19 AM, Andreas Rheinhardt wrote:
> > Tiles have a size field with a length from one to four bytes. As such
> > it is not possible to read it all at once with a call to get_bits() as
> > this only allows to read up to 25 bits; this is guarded by an
> > av_assert2. Yet this is done by the AV1 decoder in get_tiles_info().
> > It has been done despite said size fields being byte-aligned. This
> > commit fixes this by using the bytestream2 API instead.
> >
> > Furthermore, it is now explicitly checked whether the data is
> > consistent, i.e. whether the data that is supposed to be there extends
> > beyond the end of the data actually present.
> >
> > Signed-off-by: Andreas Rheinhardt 
> > ---
> >  libavcodec/av1dec.c | 40 
> >  1 file changed, 20 insertions(+), 20 deletions(-)
> >
> > diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index
> > cb46801202..0bb04a3e44 100644
> > --- a/libavcodec/av1dec.c
> > +++ b/libavcodec/av1dec.c
> > @@ -21,7 +21,7 @@
> >  #include "libavutil/pixdesc.h"
> >  #include "avcodec.h"
> >  #include "av1dec.h"
> > -#include "get_bits.h"
> > +#include "bytestream.h"
> >  #include "hwconfig.h"
> >  #include "internal.h"
> >  #include "profiles.h"
> > @@ -205,18 +205,12 @@ static int init_tile_data(AV1DecContext *s)
> > static int get_tiles_info(AVCodecContext *avctx, const AV1RawTileGroup
> > *tile_group)  {
> >  AV1DecContext *s = avctx->priv_data;
> > -GetBitContext gb;
> > +GetByteContext gb;
> >  uint16_t tile_num, tile_row, tile_col;
> > -uint32_t size = 0, size_bytes = 0, offset = 0;
> > -int ret;
> > -
> > -if ((ret = init_get_bits8(,
> > -  tile_group->tile_data.data,
> > -  tile_group->tile_data.data_size)) < 0) {
> > -av_log(avctx, AV_LOG_ERROR, "Failed to initialize bitstream 
> > reader.\n");
> > -return ret;
> > -}
> > +uint32_t size = 0, size_bytes = 0;
> >
> > +bytestream2_init(, tile_group->tile_data.data,
> > + tile_group->tile_data.data_size);
> >  s->tg_start = tile_group->tg_start;
> >  s->tg_end = tile_group->tg_end;
> >
> > @@ -225,24 +219,28 @@ static int get_tiles_info(AVCodecContext *avctx,
> const AV1RawTileGroup *tile_gro
> >  tile_col = tile_num % s->raw_frame_header->tile_cols;
> >
> >  if (tile_num == tile_group->tg_end) {
> > -s->tile_group_info[tile_num].tile_size = get_bits_left() / 
> > 8;
> > -s->tile_group_info[tile_num].tile_offset = offset;
> > +s->tile_group_info[tile_num].tile_size =
> bytestream2_get_bytes_left();
> > +s->tile_group_info[tile_num].tile_offset =
> > + bytestream2_tell();
> >  s->tile_group_info[tile_num].tile_row = tile_row;
> >  s->tile_group_info[tile_num].tile_column = tile_col;
> >  return 0;
> >  }
> >  size_bytes = s->raw_frame_header->tile_size_bytes_minus1 + 1;
> > -size = get_bits_le(, size_bytes * 8) + 1;
> > -skip_bits(, size * 8);
> > -
> > -offset += size_bytes;
> > +if (bytestream2_get_bytes_left() < size_bytes)
> > +return AVERROR_INVALIDDATA;
> > +size = 0;
> > +for (int i = 0; i < size_bytes; i++)
> > +size |= bytestream2_get_byteu() << 8 * i;
> > +if (bytestream2_get_bytes_left() <= size)
> > +return AVERROR_INVALIDDATA;
> > +size++;
> >
> >  s->tile_group_info[tile_num].tile_size = size;
> > -s->tile_group_info[tile_num].tile_offset = offset;
> > +s->tile_group_info[tile_num].tile_offset =
> > + bytestream2_tell();
> >  s->tile_group_info[tile_num].tile_row = tile_row;
> >  s->tile_group_info[tile_num].tile_column = tile_col;
> >
> > -offset += size;
> > +bytestream2_skipu(, size);
> >  }
> >
> >  return 0;
> > @@ -778,7 +776,9 @@ static int av1_decode_frame(AVCodecContext *avctx,
> void *frame,
> >  else
> >  raw_tile_group = >obu.tile_group;
> >
> > -get_tiles_info(avctx, raw_tile_group);
> > +ret = get_tiles_info(avctx, raw_tile_group);
> > +if (ret < 0)
> > +goto end;
> >
> >  if (avctx->hwaccel) {
> >  ret = avctx->hwaccel->decode_slice(avctx,
> 
> Should be ok.

LGTM. Thanks

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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] lavf/srt: fix build fail when used the libsrt 1.4.1

2020-09-17 Thread Gyan Doshi



On 15-09-2020 12:47 pm, myp...@gmail.com wrote:

On Tue, Sep 15, 2020 at 2:23 PM Gyan Doshi  wrote:

This should be backported to 4.3 and other releases whose builds fail.

Gyan

Will backporting, thx


Ping.

4.3.1 build with libsrt remains broken.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/aviobuf: fix broken logic in ffio_ensure_seekback()

2020-09-17 Thread Marton Balint



On Wed, 16 Sep 2020, Paul B Mahol wrote:


This removes big CPU overhead for demuxing chained ogg streams.

Signed-off-by: Paul B Mahol 
---
libavformat/aviobuf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a77517d712..9dfef2377e 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -999,10 +999,10 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
int filled = s->buf_end - s->buffer;
ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - 
s->buffer : -1;

-buf_size += s->buf_ptr - s->buffer + max_buffer_size;
-
if (buf_size < filled || s->seekable || !s->read_packet)


This does not seem right, the amount of to-be-read data in 
the buffer is (buf_end - buf_ptr), so that is the amount that is seekable 
backwards, not (buf_end - buffer = filled).


Regards,
Marton


return 0;
+buf_size += s->buf_end - s->buf_ptr + max_buffer_size;
+
av_assert0(!s->write_flag);

buffer = av_malloc(buf_size);
--
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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/av1dec: Check tiles sizes, fix assert, don't read bytes bitwise

2020-09-17 Thread James Almer
On 9/17/2020 12:19 AM, Andreas Rheinhardt wrote:
> Tiles have a size field with a length from one to four bytes. As such it
> is not possible to read it all at once with a call to get_bits() as this
> only allows to read up to 25 bits; this is guarded by an av_assert2. Yet
> this is done by the AV1 decoder in get_tiles_info(). It has been done
> despite said size fields being byte-aligned. This commit fixes this by
> using the bytestream2 API instead.
> 
> Furthermore, it is now explicitly checked whether the data is
> consistent, i.e. whether the data that is supposed to be there extends
> beyond the end of the data actually present.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/av1dec.c | 40 
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index cb46801202..0bb04a3e44 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -21,7 +21,7 @@
>  #include "libavutil/pixdesc.h"
>  #include "avcodec.h"
>  #include "av1dec.h"
> -#include "get_bits.h"
> +#include "bytestream.h"
>  #include "hwconfig.h"
>  #include "internal.h"
>  #include "profiles.h"
> @@ -205,18 +205,12 @@ static int init_tile_data(AV1DecContext *s)
>  static int get_tiles_info(AVCodecContext *avctx, const AV1RawTileGroup 
> *tile_group)
>  {
>  AV1DecContext *s = avctx->priv_data;
> -GetBitContext gb;
> +GetByteContext gb;
>  uint16_t tile_num, tile_row, tile_col;
> -uint32_t size = 0, size_bytes = 0, offset = 0;
> -int ret;
> -
> -if ((ret = init_get_bits8(,
> -  tile_group->tile_data.data,
> -  tile_group->tile_data.data_size)) < 0) {
> -av_log(avctx, AV_LOG_ERROR, "Failed to initialize bitstream 
> reader.\n");
> -return ret;
> -}
> +uint32_t size = 0, size_bytes = 0;
>  
> +bytestream2_init(, tile_group->tile_data.data,
> + tile_group->tile_data.data_size);
>  s->tg_start = tile_group->tg_start;
>  s->tg_end = tile_group->tg_end;
>  
> @@ -225,24 +219,28 @@ static int get_tiles_info(AVCodecContext *avctx, const 
> AV1RawTileGroup *tile_gro
>  tile_col = tile_num % s->raw_frame_header->tile_cols;
>  
>  if (tile_num == tile_group->tg_end) {
> -s->tile_group_info[tile_num].tile_size = get_bits_left() / 8;
> -s->tile_group_info[tile_num].tile_offset = offset;
> +s->tile_group_info[tile_num].tile_size = 
> bytestream2_get_bytes_left();
> +s->tile_group_info[tile_num].tile_offset = bytestream2_tell();
>  s->tile_group_info[tile_num].tile_row = tile_row;
>  s->tile_group_info[tile_num].tile_column = tile_col;
>  return 0;
>  }
>  size_bytes = s->raw_frame_header->tile_size_bytes_minus1 + 1;
> -size = get_bits_le(, size_bytes * 8) + 1;
> -skip_bits(, size * 8);
> -
> -offset += size_bytes;
> +if (bytestream2_get_bytes_left() < size_bytes)
> +return AVERROR_INVALIDDATA;
> +size = 0;
> +for (int i = 0; i < size_bytes; i++)
> +size |= bytestream2_get_byteu() << 8 * i;
> +if (bytestream2_get_bytes_left() <= size)
> +return AVERROR_INVALIDDATA;
> +size++;
>  
>  s->tile_group_info[tile_num].tile_size = size;
> -s->tile_group_info[tile_num].tile_offset = offset;
> +s->tile_group_info[tile_num].tile_offset = bytestream2_tell();
>  s->tile_group_info[tile_num].tile_row = tile_row;
>  s->tile_group_info[tile_num].tile_column = tile_col;
>  
> -offset += size;
> +bytestream2_skipu(, size);
>  }
>  
>  return 0;
> @@ -778,7 +776,9 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
> *frame,
>  else
>  raw_tile_group = >obu.tile_group;
>  
> -get_tiles_info(avctx, raw_tile_group);
> +ret = get_tiles_info(avctx, raw_tile_group);
> +if (ret < 0)
> +goto end;
>  
>  if (avctx->hwaccel) {
>  ret = avctx->hwaccel->decode_slice(avctx,

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

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