Compare commits

...

12 Commits

Author SHA1 Message Date
Andreas Rheinhardt
29584733e6 libavcodec/libvpxenc: Don't free user-provided AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit 26b4509690)
2020-05-23 21:02:30 +02:00
Andreas Rheinhardt
526628058e avcodec/libopusenc: Don't free user-provided AVPacket
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit b803993b6d)
2020-05-23 21:02:25 +02:00
Andreas Rheinhardt
24b4c4c5ba avformat/matroskadec: Fix default value of BlockAddID
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit dbc50f8a93)
2020-04-03 22:49:06 +02:00
Mark Harris
6f6cd2e29d avutil/mem: Fix invalid use of av_alloc_size
The alloc_size attribute is valid only on functions that return a
pointer.  GCC 9 (not yet released) warns about invalid usage:

./libavutil/mem.h:342:1: warning: 'alloc_size' attribute ignored on a function returning int' [-Wattributes]
  342 | av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size);
      | ^~~~~~~~~~~~~

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4361293fcf)
2019-07-23 01:21:46 -03:00
James Almer
f8e254716b avcodec/hevcdec: decode at most one slice reporting being the first in the picture
Fixes deadlocks when decoding packets containing more than one of the aforementioned
slices when using frame threads.

Tested-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 70c8c8a818)
2019-03-20 22:09:31 -03:00
Paul B Mahol
7653e8db4d avfilter/af_silenceremove: fix possible crash if supplied duration is negative
Signed-off-by: Paul B Mahol <onemda@gmail.com>

Fixes ticket #7697.
(cherry picked from commit 2d1594a8d6)
2019-01-25 00:57:38 +01:00
James Almer
a9c1ef2626 avcodec/bitstream_filters: check the input argument of av_bsf_get_by_name() for NULL
Fixes crashes like "ffmpeg -h bsf" caused by passing NULL to strcmp()

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 3258cc6507)
2018-07-28 22:46:33 -03:00
James Almer
ac1ddc6361 avdevice/iec61883: free the private context at the end
Fixes part of ticket #7146.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 5079e96bcc)
2018-04-18 22:59:37 -03:00
James Almer
86d6fca94b avdevice/iec61883: return reference counted packets
Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c8812270.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit b8629654c6)
2018-04-18 22:59:33 -03:00
Marton Balint
13deb0c1f6 avdevice/iec61883: free packet on buffer allocation error
Fixes Coverity CID 1396416.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 4556dad2b7)
2018-04-18 22:59:26 -03:00
James Almer
da11322641 avformat/libssh: check the user provided a password before trying to use it
Fixes ticket #6413

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 8ddb6820bd)
2018-01-11 10:40:33 -03:00
Rostislav Pehlivanov
7cce800930 vc2enc_dwt: pad the temporary buffer by the slice size
Since non-Haar wavelets need to look into pixels outside the frame, we
need to pad the buffer. The old factor of two seemed to be a workaround
that fact and only padded to the left and bottom. This correctly pads
by the slice size and as such reduces memory usage and potential
exploits.
Reported by Liu Bingchang.

Ideally, there should be no temporary buffer but the encoder is designed
to deinterleave the coefficients into the classical wavelet structure
with the lower frequency values in the top left corner.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
(cherry picked from commit 3228ac730c)
2017-11-09 02:10:40 +00:00
12 changed files with 48 additions and 15 deletions

View File

@@ -58,6 +58,9 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char *name)
{
int i;
if (!name)
return NULL;
for (i = 0; bitstream_filters[i]; i++) {
const AVBitStreamFilter *f = bitstream_filters[i];
if (!strcmp(f->name, name))

View File

@@ -2792,6 +2792,10 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
}
if (s->sh.first_slice_in_pic_flag) {
if (s->ref) {
av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first in the same frame.\n");
goto fail;
}
ret = hevc_frame_start(s);
if (ret < 0)
return ret;

View File

@@ -362,7 +362,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
// Check if subtraction resulted in an overflow
if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
av_packet_unref(avpkt);
av_free(avpkt);
return AVERROR(EINVAL);
}
if (discard_padding > 0) {
@@ -371,7 +370,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
10);
if(!side_data) {
av_packet_unref(avpkt);
av_free(avpkt);
return AVERROR(ENOMEM);
}
AV_WL32(side_data + 4, discard_padding);

View File

@@ -805,7 +805,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
cx_frame->sz_alpha + 8);
if(!side_data) {
av_packet_unref(pkt);
av_free(pkt);
return AVERROR(ENOMEM);
}
AV_WB64(side_data, 1);

View File

@@ -1193,7 +1193,8 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
/* DWT init */
if (ff_vc2enc_init_transforms(&s->transform_args[i].t,
s->plane[i].coef_stride,
s->plane[i].dwt_height))
s->plane[i].dwt_height,
s->slice_width, s->slice_height))
goto alloc_fail;
}

View File

@@ -255,21 +255,27 @@ static void vc2_subband_dwt_haar_shift(VC2TransformContext *t, dwtcoef *data,
dwt_haar(t, data, stride, width, height, 1);
}
av_cold int ff_vc2enc_init_transforms(VC2TransformContext *s, int p_width, int p_height)
av_cold int ff_vc2enc_init_transforms(VC2TransformContext *s, int p_stride,
int p_height, int slice_w, int slice_h)
{
s->vc2_subband_dwt[VC2_TRANSFORM_9_7] = vc2_subband_dwt_97;
s->vc2_subband_dwt[VC2_TRANSFORM_5_3] = vc2_subband_dwt_53;
s->vc2_subband_dwt[VC2_TRANSFORM_HAAR] = vc2_subband_dwt_haar;
s->vc2_subband_dwt[VC2_TRANSFORM_HAAR_S] = vc2_subband_dwt_haar_shift;
s->buffer = av_malloc(2*p_width*p_height*sizeof(dwtcoef));
/* Pad by the slice size, only matters for non-Haar wavelets */
s->buffer = av_calloc((p_stride + slice_w)*(p_height + slice_h), sizeof(dwtcoef));
if (!s->buffer)
return 1;
s->padding = (slice_h >> 1)*p_stride + (slice_w >> 1);
s->buffer += s->padding;
return 0;
}
av_cold void ff_vc2enc_free_transforms(VC2TransformContext *s)
{
av_freep(&s->buffer);
av_free(s->buffer - s->padding);
s->buffer = NULL;
}

View File

@@ -41,12 +41,14 @@ enum VC2TransformType {
typedef struct VC2TransformContext {
dwtcoef *buffer;
int padding;
void (*vc2_subband_dwt[VC2_TRANSFORMS_NB])(struct VC2TransformContext *t,
dwtcoef *data, ptrdiff_t stride,
int width, int height);
} VC2TransformContext;
int ff_vc2enc_init_transforms(VC2TransformContext *t, int p_width, int p_height);
int ff_vc2enc_init_transforms(VC2TransformContext *t, int p_stride, int p_height,
int slice_w, int slice_h);
void ff_vc2enc_free_transforms(VC2TransformContext *t);
#endif /* AVCODEC_VC2ENC_DWT_H */

View File

@@ -118,14 +118,16 @@ static int iec61883_callback(unsigned char *data, int length,
goto exit;
}
packet->buf = av_malloc(length);
packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
if (!packet->buf) {
av_free(packet);
ret = -1;
goto exit;
}
packet->len = length;
memcpy(packet->buf, data, length);
memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
if (dv->queue_first) {
dv->queue_last->next = packet;
@@ -199,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data *dv, AVPacket *pkt)
size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
packet->buf, packet->len, -1);
dv->queue_first = packet->next;
if (size < 0)
av_free(packet->buf);
av_free(packet);
dv->packets--;
if (size > 0)
return size;
if (size < 0)
return -1;
return -1;
if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
av_freep(&pkt->data);
av_packet_unref(pkt);
return -1;
}
return size;
}
static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)
@@ -453,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
} else {
iec61883_dv_fb_stop(dv->iec61883_dv);
iec61883_dv_fb_close(dv->iec61883_dv);
av_freep(&dv->dv_demux);
}
while (dv->queue_first) {
DVPacket *packet = dv->queue_first;

View File

@@ -186,8 +186,17 @@ static int config_input(AVFilterLink *inlink)
s->start_duration = av_rescale(s->start_duration, inlink->sample_rate,
AV_TIME_BASE);
if (s->start_duration < 0) {
av_log(ctx, AV_LOG_WARNING, "start duration must be non-negative\n");
s->start_duration = -s->start_duration;
}
s->stop_duration = av_rescale(s->stop_duration, inlink->sample_rate,
AV_TIME_BASE);
if (s->stop_duration < 0) {
av_log(ctx, AV_LOG_WARNING, "stop duration must be non-negative\n");
s->stop_duration = -s->stop_duration;
}
s->start_holdoff = av_malloc_array(FFMAX(s->start_duration, 1),
sizeof(*s->start_holdoff) *

View File

@@ -103,7 +103,7 @@ static av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user
}
}
if (!authorized && (auth_methods & SSH_AUTH_METHOD_PASSWORD)) {
if (!authorized && password && (auth_methods & SSH_AUTH_METHOD_PASSWORD)) {
if (ssh_userauth_password(libssh->session, NULL, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with password.\n");
authorized = 1;

View File

@@ -660,7 +660,7 @@ static const EbmlSyntax matroska_segments[] = {
};
static const EbmlSyntax matroska_blockmore[] = {
{ MATROSKA_ID_BLOCKADDID, EBML_UINT, 0, offsetof(MatroskaBlock,additional_id) },
{ MATROSKA_ID_BLOCKADDID, EBML_UINT, 0, offsetof(MatroskaBlock,additional_id), { .u = 1 } },
{ MATROSKA_ID_BLOCKADDITIONAL, EBML_BIN, 0, offsetof(MatroskaBlock,additional) },
{ 0 }
};

View File

@@ -183,7 +183,7 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
* The situation is undefined according to POSIX and may crash with
* some libc implementations.
*/
av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size);
int av_reallocp_array(void *ptr, size_t nmemb, size_t size);
/**
* Free a memory block which has been allocated with av_malloc(z)() or