[FFmpeg-cvslog] avdevice/pulse_audio_dec: do not read undersized frames

2021-03-12 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sat Feb  6 19:48:51 
2021 +0100| [b2d0826513c5e76f9bad2f1f0c809bc5c8e58b0c] | committer: Marton 
Balint

avdevice/pulse_audio_dec: do not read undersized frames

Keep on reading fragments until we got fragment_size amount of data, otherwise
we might get frames with 1-2 samples only if pa_stream_peek is called slightly
less frequently than sample rate.

Note that fragments might contain a lot less data than fragment_size, so
reading multiple fragments to get fragment_size amount of data is intentional.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b2d0826513c5e76f9bad2f1f0c809bc5c8e58b0c
---

 libavdevice/pulse_audio_dec.c | 71 +--
 1 file changed, 41 insertions(+), 30 deletions(-)

diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c
index 0454a643dd..3777396ef6 100644
--- a/libavdevice/pulse_audio_dec.c
+++ b/libavdevice/pulse_audio_dec.c
@@ -48,6 +48,7 @@ typedef struct PulseData {
 pa_threaded_mainloop *mainloop;
 pa_context *context;
 pa_stream *stream;
+size_t pa_frame_size;
 
 TimeFilter *timefilter;
 int last_period;
@@ -250,6 +251,7 @@ static av_cold int pulse_read_header(AVFormatContext *s)
 goto unlock_and_fail;
 }
 pd->fragment_size = queried_attr->fragsize;
+pd->pa_frame_size = pa_frame_size();
 
 pa_threaded_mainloop_unlock(pd->mainloop);
 
@@ -261,7 +263,7 @@ static av_cold int pulse_read_header(AVFormatContext *s)
 avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */
 
 pd->timefilter = ff_timefilter_new(100.0 / pd->sample_rate,
-   1000, 1.5E-6);
+   pd->fragment_size / pd->pa_frame_size, 
1.5E-6);
 
 if (!pd->timefilter) {
 pulse_close(s);
@@ -286,12 +288,13 @@ static int pulse_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 int64_t dts;
 pa_usec_t latency;
 int negative;
+ptrdiff_t pos = 0;
 
 pa_threaded_mainloop_lock(pd->mainloop);
 
 CHECK_DEAD_GOTO(pd, ret, unlock_and_fail);
 
-while (!read_data) {
+while (pos < pd->fragment_size) {
 int r;
 
 r = pa_stream_peek(pd->stream, _data, _length);
@@ -305,43 +308,51 @@ static int pulse_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 * silence, but that wouldn't work for compressed streams. */
 r = pa_stream_drop(pd->stream);
 CHECK_SUCCESS_GOTO(ret, r == 0, unlock_and_fail);
+} else {
+if (!pos) {
+if (av_new_packet(pkt, pd->fragment_size) < 0) {
+ret = AVERROR(ENOMEM);
+goto unlock_and_fail;
+}
+
+dts = av_gettime();
+pa_operation_unref(pa_stream_update_timing_info(pd->stream, 
NULL, NULL));
+
+if (pa_stream_get_latency(pd->stream, , ) >= 
0) {
+if (negative) {
+dts += latency;
+} else
+dts -= latency;
+} else {
+av_log(s, AV_LOG_WARNING, "pa_stream_get_latency() 
failed\n");
+}
+}
+if (pkt->size - pos < read_length) {
+if (pos)
+break;
+pa_stream_drop(pd->stream);
+/* Oversized fragment??? */
+ret = AVERROR_EXTERNAL;
+goto unlock_and_fail;
+}
+memcpy(pkt->data + pos, read_data, read_length);
+pos += read_length;
+pa_stream_drop(pd->stream);
 }
 }
 
-if (av_new_packet(pkt, read_length) < 0) {
-ret = AVERROR(ENOMEM);
-goto unlock_and_fail;
-}
-
-dts = av_gettime();
-pa_operation_unref(pa_stream_update_timing_info(pd->stream, NULL, NULL));
-
-if (pa_stream_get_latency(pd->stream, , ) >= 0) {
-enum AVCodecID codec_id =
-s->audio_codec_id == AV_CODEC_ID_NONE ? DEFAULT_CODEC_ID : 
s->audio_codec_id;
-int frame_size = ((av_get_bits_per_sample(codec_id) >> 3) * 
pd->channels);
-int frame_duration = read_length / frame_size;
-
-
-if (negative) {
-dts += latency;
-} else
-dts -= latency;
-if (pd->wallclock)
-pkt->pts = ff_timefilter_update(pd->timefilter, dts, 
pd->last_period);
+pa_threaded_mainloop_unlock(pd->mainloop);
 
-pd->last_period = frame_duration;
-} else {
-av_log(s, AV_LOG_WARNING, "pa_stream_get_latency() failed\n");
-}
+av_shrink_packet(pkt, pos);
 
-memcpy(pkt->data, read_data, read_length);
-pa_stream_drop(pd->stream);
+if (pd->wallclock)
+pkt->pts = ff_timefilter_update(pd->timefilter, dts, pd->last_period);
+pd->last_period = pkt->size / pd->pa_frame_size;
 
-

[FFmpeg-cvslog] avdevice/pulse_audio_dec: only set adjust latency flag if fragment_size is not set

2021-03-12 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Thu Feb 11 23:03:26 
2021 +0100| [7f059a250bb7bcbf7bba537c1a059a5934413035] | committer: Marton 
Balint

avdevice/pulse_audio_dec: only set adjust latency flag if fragment_size is not 
set

Otherwise fragment_size is ignored.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f059a250bb7bcbf7bba537c1a059a5934413035
---

 libavdevice/pulse_audio_dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c
index 6dea332beb..0454a643dd 100644
--- a/libavdevice/pulse_audio_dec.c
+++ b/libavdevice/pulse_audio_dec.c
@@ -218,7 +218,7 @@ static av_cold int pulse_read_header(AVFormatContext *s)
 
 ret = pa_stream_connect_record(pd->stream, device, ,
 PA_STREAM_INTERPOLATE_TIMING
-|PA_STREAM_ADJUST_LATENCY
+| (pd->fragment_size == -1 ? 
PA_STREAM_ADJUST_LATENCY : 0)
 |PA_STREAM_AUTO_TIMING_UPDATE);
 
 if (ret < 0) {

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

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

[FFmpeg-cvslog] avdevice/pulse_audio_dec: query actual fragment size

2021-03-12 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Wed Feb 10 00:15:00 
2021 +0100| [104aa921c96f126c49259c946e995679cec3abd6] | committer: Marton 
Balint

avdevice/pulse_audio_dec: query actual fragment size

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=104aa921c96f126c49259c946e995679cec3abd6
---

 libavdevice/pulse_audio_dec.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c
index 50a3c971ae..6dea332beb 100644
--- a/libavdevice/pulse_audio_dec.c
+++ b/libavdevice/pulse_audio_dec.c
@@ -149,6 +149,7 @@ static av_cold int pulse_read_header(AVFormatContext *s)
 
 pa_buffer_attr attr = { -1 };
 pa_channel_map cmap;
+const pa_buffer_attr *queried_attr;
 
 pa_channel_map_init_extend(, pd->channels, PA_CHANNEL_MAP_WAVEEX);
 
@@ -242,6 +243,14 @@ static av_cold int pulse_read_header(AVFormatContext *s)
 pa_threaded_mainloop_wait(pd->mainloop);
 }
 
+/* Query actual fragment size */
+queried_attr = pa_stream_get_buffer_attr(pd->stream);
+if (!queried_attr || queried_attr->fragsize > INT_MAX/100) {
+ret = AVERROR_EXTERNAL;
+goto unlock_and_fail;
+}
+pd->fragment_size = queried_attr->fragsize;
+
 pa_threaded_mainloop_unlock(pd->mainloop);
 
 /* take real parameters */

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

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

[FFmpeg-cvslog] avdevice/alsa_dec: make sure we have enough data in non-blocking mode

2021-03-12 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Tue Feb  9 22:24:50 
2021 +0100| [1a90cf4410a3464c8d749242e23629776f310ee0] | committer: Marton 
Balint

avdevice/alsa_dec: make sure we have enough data in non-blocking mode

Otherwise we might return 1-2 samples per packet if av_read_frame() call rate is
only sligthly less than the stream sample rate.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1a90cf4410a3464c8d749242e23629776f310ee0
---

 libavdevice/alsa.c |  5 +
 libavdevice/alsa.h |  1 +
 libavdevice/alsa_dec.c | 22 --
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index 117b2ea144..ee282fac16 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -286,6 +286,10 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, 
snd_pcm_stream_t mode,
 }
 }
 
+s->pkt = av_packet_alloc();
+if (!s->pkt)
+goto fail1;
+
 s->h = h;
 return 0;
 
@@ -308,6 +312,7 @@ av_cold int ff_alsa_close(AVFormatContext *s1)
 if (CONFIG_ALSA_INDEV)
 ff_timefilter_destroy(s->timefilter);
 snd_pcm_close(s->h);
+av_packet_free(>pkt);
 return 0;
 }
 
diff --git a/libavdevice/alsa.h b/libavdevice/alsa.h
index 1ed8c82199..07783c983a 100644
--- a/libavdevice/alsa.h
+++ b/libavdevice/alsa.h
@@ -58,6 +58,7 @@ typedef struct AlsaData {
 void *reorder_buf;
 int reorder_buf_size; ///< in frames
 int64_t timestamp; ///< current timestamp, without latency applied.
+AVPacket *pkt;
 } AlsaData;
 
 /**
diff --git a/libavdevice/alsa_dec.c b/libavdevice/alsa_dec.c
index 36494e921c..d8d4f3293b 100644
--- a/libavdevice/alsa_dec.c
+++ b/libavdevice/alsa_dec.c
@@ -105,34 +105,36 @@ static int audio_read_packet(AVFormatContext *s1, 
AVPacket *pkt)
 int64_t dts;
 snd_pcm_sframes_t delay = 0;
 
-if (av_new_packet(pkt, s->period_size * s->frame_size) < 0) {
-return AVERROR(EIO);
+if (!s->pkt->data) {
+int ret = av_new_packet(s->pkt, s->period_size * s->frame_size);
+if (ret < 0)
+return ret;
+s->pkt->size = 0;
 }
 
-while ((res = snd_pcm_readi(s->h, pkt->data, s->period_size)) < 0) {
+do {
+while ((res = snd_pcm_readi(s->h, s->pkt->data + s->pkt->size, 
s->period_size - s->pkt->size / s->frame_size)) < 0) {
 if (res == -EAGAIN) {
-av_packet_unref(pkt);
-
 return AVERROR(EAGAIN);
 }
+s->pkt->size = 0;
 if (ff_alsa_xrun_recover(s1, res) < 0) {
 av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n",
snd_strerror(res));
-av_packet_unref(pkt);
-
 return AVERROR(EIO);
 }
 ff_timefilter_reset(s->timefilter);
-}
+}
+s->pkt->size += res * s->frame_size;
+} while (s->pkt->size < s->period_size * s->frame_size);
 
+av_packet_move_ref(pkt, s->pkt);
 dts = av_gettime();
 snd_pcm_delay(s->h, );
 dts -= av_rescale(delay + res, 100, s->sample_rate);
 pkt->pts = ff_timefilter_update(s->timefilter, dts, s->last_period);
 s->last_period = res;
 
-pkt->size = res * s->frame_size;
-
 return 0;
 }
 

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

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

[FFmpeg-cvslog] avcodec: add a get_encode_buffer() callback to AVCodecContext

2021-03-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Feb 20 16:01:52 
2021 -0300| [6e7e3a3820f0888ff92d6be44f40ff733bcce874] | committer: James Almer

avcodec: add a get_encode_buffer() callback to AVCodecContext

This callback is functionally the same as get_buffer2() is for decoders, and
implements for the new encode API the functionality of the old encode API had
where the user could provide their own buffers.

Reviewed-by: Lynne 
Reviewed-by: Michael Niedermayer 
Reviewed-by: Mark Thompson 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e7e3a3820f0888ff92d6be44f40ff733bcce874
---

 doc/APIchanges   |  7 +++
 libavcodec/avcodec.h | 50 
 libavcodec/codec.h   |  8 ---
 libavcodec/encode.c  | 59 
 libavcodec/encode.h  |  8 +++
 libavcodec/options.c |  1 +
 libavcodec/version.h |  2 +-
 7 files changed, 131 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 13350c0db0..3096c019c6 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,13 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2021-03-12 - xx - lavc 58.131.100 - avcodec.h codec.h
+  Add a get_encode_buffer callback to AVCodecContext, similar to
+  get_buffer2 but for encoders.
+  Add avcodec_default_get_encode_buffer().
+  Add AV_GET_ENCODE_BUFFER_FLAG_REF.
+  Encoders may now be flagged as AV_CODEC_CAP_DR1 capable.
+
 2021-03-10 - xx - lavf 58.72.100 - avformat.h
   Change AVBufferRef related AVStream function and struct size
   parameter and fields type to size_t at next major bump.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3ecb3a4a60..fbd4804160 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -513,6 +513,11 @@ typedef struct AVProducerReferenceTime {
  */
 #define AV_GET_BUFFER_FLAG_REF (1 << 0)
 
+/**
+ * The encoder will keep a reference to the packet and may reuse it later.
+ */
+#define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)
+
 struct AVCodecInternal;
 
 /**
@@ -2339,6 +2344,44 @@ typedef struct AVCodecContext {
  * - encoding: set by user
  */
 int export_side_data;
+
+/**
+ * This callback is called at the beginning of each packet to get a data
+ * buffer for it.
+ *
+ * The following field will be set in the packet before this callback is
+ * called:
+ * - size
+ * This callback must use the above value to calculate the required buffer 
size,
+ * which must padded by at least AV_INPUT_BUFFER_PADDING_SIZE bytes.
+ *
+ * This callback must fill the following fields in the packet:
+ * - data: alignment requirements for AVPacket apply, if any. Some 
architectures and
+ *   encoders may benefit from having aligned data.
+ * - buf: must contain a pointer to an AVBufferRef structure. The packet's
+ *   data pointer must be contained in it. See: av_buffer_create(), 
av_buffer_alloc(),
+ *   and av_buffer_ref().
+ *
+ * If AV_CODEC_CAP_DR1 is not set then get_encode_buffer() must call
+ * avcodec_default_get_encode_buffer() instead of providing a buffer 
allocated by
+ * some other means.
+ *
+ * The flags field may contain a combination of AV_GET_ENCODE_BUFFER_FLAG_ 
flags.
+ * They may be used for example to hint what use the buffer may get after 
being
+ * created.
+ * Implementations of this callback may ignore flags they don't understand.
+ * If AV_GET_ENCODE_BUFFER_FLAG_REF is set in flags then the packet may be 
reused
+ * (read and/or written to if it is writable) later by libavcodec.
+ *
+ * This callback must be thread-safe, as when frame threading is used, it 
may
+ * be called from multiple threads simultaneously.
+ *
+ * @see avcodec_default_get_encode_buffer()
+ *
+ * - encoding: Set by libavcodec, user can override.
+ * - decoding: unused
+ */
+int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int 
flags);
 } AVCodecContext;
 
 #if FF_API_CODEC_GET_SET
@@ -2898,6 +2941,13 @@ void avsubtitle_free(AVSubtitle *sub);
  */
 int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
 
+/**
+ * The default callback for AVCodecContext.get_encode_buffer(). It is made 
public so
+ * it can be called by custom get_encode_buffer() implementations for encoders 
without
+ * AV_CODEC_CAP_DR1 set.
+ */
+int avcodec_default_get_encode_buffer(AVCodecContext *s, AVPacket *pkt, int 
flags);
+
 /**
  * Modify width and height values so that they will result in a memory
  * buffer that is acceptable for the codec if you do not use any horizontal
diff --git a/libavcodec/codec.h b/libavcodec/codec.h
index 729df0e304..1bb70260ac 100644
--- a/libavcodec/codec.h
+++ b/libavcodec/codec.h
@@ -43,9 +43,11 @@
  */
 #define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 <<  0)
 /**
- * Codec uses get_buffer() for allocating buffers 

[FFmpeg-cvslog] cbs_sei: Detect payload overflows when reading SEI messages

2021-03-12 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Tue Feb  2 20:58:11 
2021 +| [2c96e6cb955af3062e78c5b0f9fb907cfb2e59e3] | committer: Mark 
Thompson

cbs_sei: Detect payload overflows when reading SEI messages

The top-level GetBitContext is sized for the whole NAL unit, so it fails
to detect overflows where a payload continues into the following message.
To fix that, we make a new context on the stack for reading each payload.

Fixes: 
29892/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-6310830956216320
Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c96e6cb955af3062e78c5b0f9fb907cfb2e59e3
---

 libavcodec/cbs_sei_syntax_template.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cbs_sei_syntax_template.c 
b/libavcodec/cbs_sei_syntax_template.c
index 9114e61ff6..0ef7b42ed9 100644
--- a/libavcodec/cbs_sei_syntax_template.c
+++ b/libavcodec/cbs_sei_syntax_template.c
@@ -238,6 +238,7 @@ static int FUNC(message_list)(CodedBitstreamContext *ctx, 
RWContext *rw,
 uint32_t payload_type = 0;
 uint32_t payload_size = 0;
 uint32_t tmp;
+GetBitContext payload_gbc;
 
 while (show_bits(rw, 8) == 0xff) {
 fixed(8, ff_byte, 0xff);
@@ -253,13 +254,27 @@ static int FUNC(message_list)(CodedBitstreamContext *ctx, 
RWContext *rw,
 xu(8, last_payload_size_byte, tmp, 0, 254, 0);
 payload_size += tmp;
 
+// There must be space remaining for both the payload and
+// the trailing bits on the SEI NAL unit.
+if (payload_size + 1 > get_bits_left(rw) / 8) {
+av_log(ctx->log_ctx, AV_LOG_ERROR,
+   "Invalid SEI message: payload_size too large "
+   "(%"PRIu32" bytes).\n", payload_size);
+return AVERROR_INVALIDDATA;
+}
+CHECK(init_get_bits(_gbc, rw->buffer,
+get_bits_count(rw) + 8 * payload_size));
+skip_bits_long(_gbc, get_bits_count(rw));
+
 CHECK(ff_cbs_sei_list_add(current));
 message = >messages[k];
 
 message->payload_type = payload_type;
 message->payload_size = payload_size;
 
-CHECK(FUNC(message)(ctx, rw, message));
+CHECK(FUNC(message)(ctx, _gbc, message));
+
+skip_bits_long(rw, 8 * payload_size);
 
 if (!cbs_h2645_read_more_rbsp_data(rw))
 break;

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

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

[FFmpeg-cvslog] cbs_h265: Detect more reference combinations which would overflow the DPB

2021-03-12 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Wed Feb  3 21:34:07 
2021 +| [b128b0ce2203f96ff86969f6d0039827a7f00378] | committer: Mark 
Thompson

cbs_h265: Detect more reference combinations which would overflow the DPB

In total, the number of short term references (from the selected short
term ref pic set), the number of long term references (combining both the
used candidates from the SPS and those defined in the slice header) and
the number of instances of the current picture (usually one, but can be
two if current picture reference is enabled) must never exceed the size
of the DPB.  This is a generalisation of the condition associated with
num_long_term_pics in 7.4.7.1.

We use this to apply tighter bounds to the number of long term pictures
referred to in the slice header, and also to detect the invalid case where
the second reference to the current picture would not fit in the DPB (this
case can't be detected earlier because an STRPS with 15 pictures can still
be valid in the same stream when used with a different PPS which does not
require two DPB slots for the current picture).

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
Tested-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b128b0ce2203f96ff86969f6d0039827a7f00378
---

 libavcodec/cbs_h265_syntax_template.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index d09934cfeb..5d216aad36 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1369,6 +1369,7 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
 if (current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_W_RADL &&
 current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_N_LP) {
 const H265RawSTRefPicSet *rps;
+int dpb_slots_remaining;
 
 ub(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, 
slice_pic_order_cnt_lsb);
 
@@ -1387,6 +1388,22 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
 rps = >st_ref_pic_set[0];
 }
 
+dpb_slots_remaining = HEVC_MAX_DPB_SIZE - 1 -
+rps->num_negative_pics - rps->num_positive_pics;
+if (pps->pps_curr_pic_ref_enabled_flag &&
+(sps->sample_adaptive_offset_enabled_flag ||
+ !pps->pps_deblocking_filter_disabled_flag ||
+ pps->deblocking_filter_override_enabled_flag)) {
+// This picture will occupy two DPB slots.
+if (dpb_slots_remaining == 0) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
+   "short-term ref pic set contains too many pictures "
+   "to use with current picture reference enabled.\n");
+return AVERROR_INVALIDDATA;
+}
+--dpb_slots_remaining;
+}
+
 num_pic_total_curr = 0;
 for (i = 0; i < rps->num_negative_pics; i++)
 if (rps->used_by_curr_pic_s0_flag[i])
@@ -1399,13 +1416,15 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
 unsigned int idx_size;
 
 if (sps->num_long_term_ref_pics_sps > 0) {
-ue(num_long_term_sps, 0, sps->num_long_term_ref_pics_sps);
+ue(num_long_term_sps, 0, 
FFMIN(sps->num_long_term_ref_pics_sps,
+   dpb_slots_remaining));
 idx_size = av_log2(sps->num_long_term_ref_pics_sps - 1) + 
1;
+dpb_slots_remaining -= current->num_long_term_sps;
 } else {
 infer(num_long_term_sps, 0);
 idx_size = 0;
 }
-ue(num_long_term_pics, 0, HEVC_MAX_REFS - 
current->num_long_term_sps);
+ue(num_long_term_pics, 0, dpb_slots_remaining);
 
 for (i = 0; i < current->num_long_term_sps +
 current->num_long_term_pics; i++) {

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

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

[FFmpeg-cvslog] avcodec/cbs_h26[45]: Remove redundant enum constants

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Mar 10 11:26:52 2021 +0100| [ec54c32d4a13689678e99cccda3cbaae3af0df52] | 
committer: Andreas Rheinhardt

avcodec/cbs_h26[45]: Remove redundant enum constants

Unused since 8843607f495c95c1e67a3ce3d6f15dca6e252439.

Reviewed-by: Mark Thompson 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ec54c32d4a13689678e99cccda3cbaae3af0df52
---

 libavcodec/cbs_h264.h | 10 --
 libavcodec/cbs_h265.h |  9 -
 2 files changed, 19 deletions(-)

diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 9eb97eae24..5a8641a333 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -28,16 +28,6 @@
 #include "h264.h"
 
 
-enum {
-// This limit is arbitrary - it is sufficient for one message of each
-// type plus some repeats, and will therefore easily cover all sane
-// streams.  However, it is possible to make technically-valid streams
-// for which it will fail (for example, by including a large number of
-// user-data-unregistered messages).
-H264_MAX_SEI_PAYLOADS = 64,
-};
-
-
 typedef struct H264RawNALUnitHeader {
 uint8_t nal_ref_idc;
 uint8_t nal_unit_type;
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index 738cbeec2c..f7753f1206 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -26,15 +26,6 @@
 #include "cbs_sei.h"
 #include "hevc.h"
 
-enum {
-// This limit is arbitrary - it is sufficient for one message of each
-// type plus some repeats, and will therefore easily cover all sane
-// streams.  However, it is possible to make technically-valid streams
-// for which it will fail (for example, by including a large number of
-// user-data-unregistered messages).
-H265_MAX_SEI_PAYLOADS = 64,
-};
-
 typedef struct H265RawNALUnitHeader {
 uint8_t nal_unit_type;
 uint8_t nuh_layer_id;

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

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

[FFmpeg-cvslog] avcodec/cbs_sei: Fix leak of AVBufferRef on error

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Mar  9 22:11:52 2021 +0100| [70d226575ad8d3953e10a3233257f6e37ad35591] | 
committer: Andreas Rheinhardt

avcodec/cbs_sei: Fix leak of AVBufferRef on error

An AVBufferRef (and the corresponding AVBuffer and the underlying actual
buffer) would leak in ff_cbs_sei_add_message() on error in case an error
happened after its creation and before it has been attached to more
permanent storage. Fix this by only creating the AVBufferRef immediately
before attaching it to its intended target position.

(Given that no SEI message currently created is refcounted, the above
can't happen at the moment. But Coverity already nevertheless noticed:
This commit fixes Coverity issue #1473521.)

Reviewed-by: Mark Thompson 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70d226575ad8d3953e10a3233257f6e37ad35591
---

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

diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c
index 2a96db9674..141e97ec58 100644
--- a/libavcodec/cbs_sei.c
+++ b/libavcodec/cbs_sei.c
@@ -262,14 +262,6 @@ int ff_cbs_sei_add_message(CodedBitstreamContext *ctx,
 if (!desc)
 return AVERROR(EINVAL);
 
-if (payload_buf) {
-payload_ref = av_buffer_ref(payload_buf);
-if (!payload_ref)
-return AVERROR(ENOMEM);
-} else {
-payload_ref = NULL;
-}
-
 // Find an existing SEI unit or make a new one to add to.
 err = cbs_sei_get_unit(ctx, au, prefix, );
 if (err < 0)
@@ -285,6 +277,14 @@ int ff_cbs_sei_add_message(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 
+if (payload_buf) {
+payload_ref = av_buffer_ref(payload_buf);
+if (!payload_ref)
+return AVERROR(ENOMEM);
+} else {
+payload_ref = NULL;
+}
+
 message = >messages[list->nb_messages - 1];
 
 message->payload_type = payload_type;

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

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

[FFmpeg-cvslog] avcodec/cbs: Remove redundant checks for CodedBitstreamContext.codec

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Mar  9 20:16:04 2021 +0100| [85685297c28958f3a8fa50a50ed3a6171e7f34c2] | 
committer: Andreas Rheinhardt

avcodec/cbs: Remove redundant checks for CodedBitstreamContext.codec

Setting this field happens immediately after the allocation in
ff_cbs_init(), so the whole CBS code may presume that any
CodedBitstreamContext has this set. Lots of code already presumed this,
yet ff_cbs_close() did it inconsistently: It checked before checking
whether the CodedBitstreamType has a close function; yet it simply
unconditionally read ctx->codec->priv_class. Coverity complained about
this in issue #1473564, which this commit fixes.

Reviewed-by: Mark Thompson 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85685297c28958f3a8fa50a50ed3a6171e7f34c2
---

 libavcodec/cbs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index ecf22b3fdb..c7f69845fb 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -94,7 +94,7 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 return AVERROR(ENOMEM);
 
 ctx->log_ctx = log_ctx;
-ctx->codec   = type;
+ctx->codec   = type; /* Must be before any error */
 
 if (type->priv_data_size) {
 ctx->priv_data = av_mallocz(ctx->codec->priv_data_size);
@@ -119,7 +119,7 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 
 void ff_cbs_flush(CodedBitstreamContext *ctx)
 {
-if (ctx->codec && ctx->codec->flush)
+if (ctx->codec->flush)
 ctx->codec->flush(ctx);
 }
 
@@ -130,7 +130,7 @@ void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
 if (!ctx)
 return;
 
-if (ctx->codec && ctx->codec->close)
+if (ctx->codec->close)
 ctx->codec->close(ctx);
 
 av_freep(>write_buffer);

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

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

[FFmpeg-cvslog] avcodec/cbs_sei: Don't use -1th element of array

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Mar  9 21:29:24 2021 +0100| [12a9f3fc09c7f0ded8be76d66542a88d293663cc] | 
committer: Andreas Rheinhardt

avcodec/cbs_sei: Don't use -1th element of array

(This affected only suffix SEI messages; yet no such SEI messages are
currently inserted.)

Reviewed-by: Mark Thompson 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12a9f3fc09c7f0ded8be76d66542a88d293663cc
---

 libavcodec/cbs_sei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c
index c49830ad77..2a96db9674 100644
--- a/libavcodec/cbs_sei.c
+++ b/libavcodec/cbs_sei.c
@@ -166,7 +166,7 @@ static int cbs_sei_get_unit(CodedBitstreamContext *ctx,
 }
 if (i < 0) {
 // No VCL units; just put it at the end.
-position = -1;
+position = au->nb_units;
 } else {
 position = i + 1;
 }

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

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

[FFmpeg-cvslog] avcodec/nvenc: base timestamps on frameIntervalP

2021-03-12 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Fri Mar 12 
22:42:02 2021 +0200| [30cd7feb2dd497b16edb6d7c09a83eb49f89645d] | committer: 
Timo Rothenpieler

avcodec/nvenc: base timestamps on frameIntervalP

If b-frames were enabled implicitly (if max_b_frames wasn't set by
the caller at all, since a0949d0bcb0eee2f3fffcf9a4810c0295d14c0dc),
we wouldn't offset dts at all, producing invalid pts/dts combinations
(causing loud warnings by ffmpeg, or muxer errors if passed without
an extra cleanup pass).

Instead use frameIntervalP for offsetting, which should always be
accurate.

Signed-off-by: Timo Rothenpieler 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=30cd7feb2dd497b16edb6d7c09a83eb49f89645d
---

 libavcodec/nvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index a061dee880..fbf55ebc9d 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1921,7 +1921,7 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
 pkt->pts = params->outputTimeStamp;
 pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list);
 
-pkt->dts -= FFMAX(avctx->max_b_frames, 0) * FFMAX(avctx->ticks_per_frame, 
1);
+pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * 
FFMAX(avctx->ticks_per_frame, 1);
 
 return 0;
 }

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

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

[FFmpeg-cvslog] avfilter/vf_uspp: Fix leak of packet side data

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Mar 12 15:07:33 2021 +0100| [6e2db67801c9975fae6f55c40f615d87b9a74a15] | 
committer: Andreas Rheinhardt

avfilter/vf_uspp: Fix leak of packet side data

The uspp filter uses a special option ("no_bitstream") of
the Snow encoder to suppress it from generating output.
The filter therefore did not unref the packet after usage,
believing it to be blank. But this is wrong, as the Snow encoder
attaches quality stats side data to the packet.

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e2db67801c9975fae6f55c40f615d87b9a74a15
---

 libavfilter/vf_uspp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index b77edeb244..523e47c811 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -257,6 +257,7 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t 
*src[3],
 av_log(p->avctx_enc[i], AV_LOG_ERROR, "Encoding failed\n");
 continue;
 }
+av_packet_unref();
 
 p->frame_dec = p->avctx_enc[i]->coded_frame;
 

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

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

[FFmpeg-cvslog] avfilter/vf_uspp: Fix leak of qp-table on error

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Mar 12 14:55:53 2021 +0100| [0858853241925d0a45f58a4724f203d284a70f00] | 
committer: Andreas Rheinhardt

avfilter/vf_uspp: Fix leak of qp-table on error

Fixes Coverity issue #1473500.

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0858853241925d0a45f58a4724f203d284a70f00
---

 libavfilter/vf_uspp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index 8b39f53c3d..b77edeb244 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -425,6 +425,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
 if (!out) {
 av_frame_free();
+if (qp_table != uspp->non_b_qp_table)
+av_free(qp_table);
 return AVERROR(ENOMEM);
 }
 av_frame_copy_props(out, in);

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

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

[FFmpeg-cvslog] avcodec/decode: Reindentation

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Mar 12 17:40:07 2021 +0100| [0364188fb907ef901cfbb1531a5d7bb458de348d] | 
committer: Andreas Rheinhardt

avcodec/decode: Reindentation

Reviewed-by: James Almer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0364188fb907ef901cfbb1531a5d7bb458de348d
---

 libavcodec/decode.c | 49 -
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 73cc3def5f..495e9e8b23 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1723,7 +1723,6 @@ static int add_metadata_from_side_data(const AVPacket 
*avpkt, AVFrame *frame)
 int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
 {
 AVPacket *pkt = avctx->internal->last_pkt_props;
-int i;
 static const struct {
 enum AVPacketSideDataType packet;
 enum AVFrameSideDataType frame;
@@ -1744,36 +1743,36 @@ int ff_decode_frame_props(AVCodecContext *avctx, 
AVFrame *frame)
 av_fifo_generic_read(avctx->internal->pkt_props,
  pkt, sizeof(*pkt), NULL);
 
-frame->pts = pkt->pts;
+frame->pts = pkt->pts;
 #if FF_API_PKT_PTS
 FF_DISABLE_DEPRECATION_WARNINGS
-frame->pkt_pts = pkt->pts;
+frame->pkt_pts = pkt->pts;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-frame->pkt_pos  = pkt->pos;
-frame->pkt_duration = pkt->duration;
-frame->pkt_size = pkt->size;
-
-for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
-buffer_size_t size;
-uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, 
);
-if (packet_sd) {
-AVFrameSideData *frame_sd = av_frame_new_side_data(frame,
-   sd[i].frame,
-   size);
-if (!frame_sd)
-return AVERROR(ENOMEM);
-
-memcpy(frame_sd->data, packet_sd, size);
-}
+frame->pkt_pos  = pkt->pos;
+frame->pkt_duration = pkt->duration;
+frame->pkt_size = pkt->size;
+
+for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
+buffer_size_t size;
+uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, );
+if (packet_sd) {
+AVFrameSideData *frame_sd = av_frame_new_side_data(frame,
+   sd[i].frame,
+   size);
+if (!frame_sd)
+return AVERROR(ENOMEM);
+
+memcpy(frame_sd->data, packet_sd, size);
 }
-add_metadata_from_side_data(pkt, frame);
+}
+add_metadata_from_side_data(pkt, frame);
 
-if (pkt->flags & AV_PKT_FLAG_DISCARD) {
-frame->flags |= AV_FRAME_FLAG_DISCARD;
-} else {
-frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD);
-}
+if (pkt->flags & AV_PKT_FLAG_DISCARD) {
+frame->flags |= AV_FRAME_FLAG_DISCARD;
+} else {
+frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD);
+}
 frame->reordered_opaque = avctx->reordered_opaque;
 
 if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED)

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

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

[FFmpeg-cvslog] avcodec/decode: Remove always-true check

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Mar 12 17:29:28 2021 +0100| [cc448f8d394c4530748f1694bd9d23b6110d1759] | 
committer: Andreas Rheinhardt

avcodec/decode: Remove always-true check

Forgotten in 1fd76277708cf83572ba243e98f9e848c652f83d.

Reviewed-by: James Almer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cc448f8d394c4530748f1694bd9d23b6110d1759
---

 libavcodec/decode.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index c7dbf7b791..73cc3def5f 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1744,7 +1744,6 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 av_fifo_generic_read(avctx->internal->pkt_props,
  pkt, sizeof(*pkt), NULL);
 
-if (pkt) {
 frame->pts = pkt->pts;
 #if FF_API_PKT_PTS
 FF_DISABLE_DEPRECATION_WARNINGS
@@ -1775,7 +1774,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 } else {
 frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD);
 }
-}
 frame->reordered_opaque = avctx->reordered_opaque;
 
 if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED)

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

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

[FFmpeg-cvslog] avformat/adp, svs: Remove redundant av_shrink_packet()

2021-03-12 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Mar 12 09:23:46 2021 +0100| [d025a5bcc271387e2f3080b88651eddbae9b93d2] | 
committer: Andreas Rheinhardt

avformat/adp, svs: Remove redundant av_shrink_packet()

av_get_packet() already makes sure that the packet size is accurate
and that the packet data is zero-padded even when one could not read as
much as desired.

Reviewed-by: James Almer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d025a5bcc271387e2f3080b88651eddbae9b93d2
---

 libavformat/adp.c | 8 ++--
 libavformat/svs.c | 1 -
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/libavformat/adp.c b/libavformat/adp.c
index 8668c78fe4..b0ee09753e 100644
--- a/libavformat/adp.c
+++ b/libavformat/adp.c
@@ -75,13 +75,9 @@ static int adp_read_packet(AVFormatContext *s, AVPacket *pkt)
 return AVERROR_EOF;
 
 ret = av_get_packet(s->pb, pkt, size);
+if (ret < 0)
+return ret;
 
-if (ret != size) {
-if (ret < 0) {
-return ret;
-}
-av_shrink_packet(pkt, ret);
-}
 pkt->stream_index = 0;
 
 return ret;
diff --git a/libavformat/svs.c b/libavformat/svs.c
index d4285ed306..8be26c5bc3 100644
--- a/libavformat/svs.c
+++ b/libavformat/svs.c
@@ -79,7 +79,6 @@ static int svs_read_packet(AVFormatContext *s, AVPacket *pkt)
 if (ret != 32 * 256) {
 if (ret < 0)
 return ret;
-av_shrink_packet(pkt, ret);
 pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
 }
 pkt->stream_index = 0;

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

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