Compare commits

...

17 Commits

Author SHA1 Message Date
Michael Niedermayer
e0723b7e4e avcodec/hevc_filter: copy_CTB() only within width&height
Fixes: out of array access
Fixes: 49271/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5424984922652672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 009ef35d38)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:31:41 +02:00
Michael Niedermayer
6fbd4d2285 avcodec/tiff: Check tile_length and tile_width
Fixes: Division by 0
Fixes: 49235/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5495613847896064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 76112c2b41)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:31:16 +02:00
Michael Niedermayer
fa511b03d3 avcodec/mss4: Check image size with av_image_check_size2()
Fixes: Timeout
Fixes: 48418/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MTS2_fuzzer-4834851466903552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4e145f1dcd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:16:52 +02:00
Michael Niedermayer
5767941df8 avformat/flvdec: Check for EOF in index reading
Fixes: Timeout
Fixes: 47992/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6020443879899136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ceff5d7b74)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:15:48 +02:00
Michael Niedermayer
e6584a3f19 avformat/nutdec: Check get_packetheader() in mainheader
Fixes; Timeout
Fixes: 48794/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6524604713140224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b5de084aa6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:15:14 +02:00
Michael Niedermayer
e8a51675ea avformat/mov: Check for EOF in mov_read_iloc()
Fixes: Timeout
Fixes: 49216/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6563000529584128

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 744ad45c44)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:14:53 +02:00
Michael Niedermayer
1c06f776e6 avformat/asfdec_f: Use 64bit for packet start time
Fixes: signed integer overflow: 2147483647 + 32 cannot be represented in type 'int'
Fixes: 49014/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_fuzzer-6314973315334144

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8ed78486fc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:12:24 +02:00
Michael Niedermayer
e95f80c8df avcodec/exr: Check x/ysize
Fixes: OOM
Fixes: 48911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6352002510094336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 614a4d1476)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:12:03 +02:00
Michael Niedermayer
6a78425604 avcodec/ffv1dec: Fix AC_GOLOMB_RICE min size check
Found-by: mkver

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f7d510b33f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 15:48:06 +02:00
Michael Niedermayer
288ef1939f avcodec/ffv1dec: consider run increase in minimal golomb frame size
Fixes: Timeout
Fixes: 49160/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5672826144686080

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 15785e044e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-20 18:24:47 +02:00
Michael Niedermayer
cd894807fe tools/target_dec_fuzzer: Adjust threshold for MMVIDEO
Fixes: Timeout
Fixes: 49003/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MMVIDEO_fuzzer-5550368423018496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3592b05c84)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-20 18:24:47 +02:00
Michael Niedermayer
22878e8177 RELEASE_NOTES: Based on the version from 5.0
Name suggested by Leo Izen and Andreas Rheinhardt

LTS text suggested by Martijn van Beurden <mvanb1@gmail.com>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-20 18:24:16 +02:00
Timo Rothenpieler
d6a1e5980b avutil/hwcontext_d3d11va: fix texture_infos writes on non-fixed-size pools 2022-07-18 02:10:41 +02:00
Marton Balint
83feded492 avdevice/avdevice: fix return value of avdevice_list_devices()
According to API docs avdevice_list_devices(), avdevice_list_input_sources()
and avdevice_list_input_sinks() should return the number of autodetected
devices on success. This is redundant with AVDeviceInfoList->nb_devices so it
was not noticed earlier that none of the underlying device list functions work
like that.

Let's fix it in generic code to make it in line with the API docs.

Fixes ticket #9820.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 64f04df379)
2022-07-17 22:12:31 +02:00
Michael Niedermayer
2720715dab avcodec/lagarith: Check dst/src in zero run code
Fixes: out of array access
Fixes: 48799/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LAGARITH_fuzzer-4764457825337344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9450f75974)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-16 17:08:26 +02:00
Michael Niedermayer
e04cb59ecc Update for 5.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-16 17:08:26 +02:00
Gyan Doshi
b21d387d6f ffmpeg: add option -isync
This is a per-file input option that adjusts an input's timestamps
with reference to another input, so that emitted packet timestamps
account for the difference between the start times of the two inputs.

Typical use case is to sync two or more live inputs such as from capture
devices. Both the target and reference input source timestamps should be
based on the same clock source.

If either input lacks starting timestamps, then no sync adjustment is made.
2022-07-14 15:49:10 +05:30
19 changed files with 154 additions and 10 deletions

View File

@@ -1 +1 @@
4.4.git
5.1

18
RELEASE_NOTES Normal file
View File

@@ -0,0 +1,18 @@
┌────────────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 5.1 "Riemann" LTS │
└────────────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 5.1 "Riemann" LTS, about 6
months after the release of FFmpeg 5.0, our first Long Term Support
release. While several past FFmpeg releases have enjoyed long term
support, this is the first release where such an intention is made
clear at release.
A complete Changelog is available at the root of the project, and the
complete Git history on https://git.ffmpeg.org/gitweb/ffmpeg.git
We hope you will like this release as much as we enjoyed working on it, and
as usual, if you have any questions about it, or any FFmpeg related topic,
feel free to join us on the #ffmpeg IRC channel (on irc.libera.chat) or ask
on the mailing-lists.

View File

@@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = 5.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@@ -518,6 +518,21 @@ see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1)
Like the @code{-ss} option but relative to the "end of file". That is negative
values are earlier in the file, 0 is at EOF.
@item -isync @var{input_index} (@emph{input})
Assign an input as a sync source.
This will take the difference between the start times of the target and reference inputs and
offset the timestamps of the target file by that difference. The source timestamps of the two
inputs should derive from the same clock source for expected results. If @code{copyts} is set
then @code{start_at_zero} must also be set. If either of the inputs has no starting timestamp
then no sync adjustment is made.
Acceptable values are those that refer to a valid ffmpeg input index. If the sync reference is
the target index itself or @var{-1}, then no adjustment is made to target timestamps. A sync
reference may not itself be synced to any other input.
Default value is @var{-1}.
@item -itsoffset @var{offset} (@emph{input})
Set the input time offset.

View File

@@ -118,6 +118,7 @@ typedef struct OptionsContext {
float readrate;
int accurate_seek;
int thread_queue_size;
int input_sync_ref;
SpecifierOpt *ts_scale;
int nb_ts_scale;
@@ -410,6 +411,7 @@ typedef struct InputFile {
at the moment when looping happens */
AVRational time_base; /* time base of the duration */
int64_t input_ts_offset;
int input_sync_ref;
int64_t ts_offset;
int64_t last_ts;

View File

@@ -235,6 +235,7 @@ static void init_options(OptionsContext *o)
o->chapters_input_file = INT_MAX;
o->accurate_seek = 1;
o->thread_queue_size = -1;
o->input_sync_ref = -1;
}
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
@@ -287,6 +288,58 @@ static int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, in
return 0;
}
static int apply_sync_offsets(void)
{
for (int i = 0; i < nb_input_files; i++) {
InputFile *ref, *self = input_files[i];
int64_t adjustment;
int64_t self_start_time, ref_start_time, self_seek_start, ref_seek_start;
int start_times_set = 1;
if (self->input_sync_ref == -1 || self->input_sync_ref == i) continue;
if (self->input_sync_ref >= nb_input_files || self->input_sync_ref < -1) {
av_log(NULL, AV_LOG_FATAL, "-isync for input %d references non-existent input %d.\n", i, self->input_sync_ref);
exit_program(1);
}
if (copy_ts && !start_at_zero) {
av_log(NULL, AV_LOG_FATAL, "Use of -isync requires that start_at_zero be set if copyts is set.\n");
exit_program(1);
}
ref = input_files[self->input_sync_ref];
if (ref->input_sync_ref != -1 && ref->input_sync_ref != self->input_sync_ref) {
av_log(NULL, AV_LOG_ERROR, "-isync for input %d references a resynced input %d. Sync not set.\n", i, self->input_sync_ref);
continue;
}
if (self->ctx->start_time_realtime != AV_NOPTS_VALUE && ref->ctx->start_time_realtime != AV_NOPTS_VALUE) {
self_start_time = self->ctx->start_time_realtime;
ref_start_time = ref->ctx->start_time_realtime;
} else if (self->ctx->start_time != AV_NOPTS_VALUE && ref->ctx->start_time != AV_NOPTS_VALUE) {
self_start_time = self->ctx->start_time;
ref_start_time = ref->ctx->start_time;
} else {
start_times_set = 0;
}
if (start_times_set) {
self_seek_start = self->start_time == AV_NOPTS_VALUE ? 0 : self->start_time;
ref_seek_start = ref->start_time == AV_NOPTS_VALUE ? 0 : ref->start_time;
adjustment = (self_start_time - ref_start_time) + !copy_ts*(self_seek_start - ref_seek_start) + ref->input_ts_offset;
self->ts_offset += adjustment;
av_log(NULL, AV_LOG_INFO, "Adjusted ts offset for Input #%d by %"PRId64" us to sync with Input #%d.\n", i, adjustment, self->input_sync_ref);
} else {
av_log(NULL, AV_LOG_INFO, "Unable to identify start times for Inputs #%d and %d both. No sync adjustment made.\n", i, self->input_sync_ref);
}
}
return 0;
}
static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
{
av_free(filter_nbthreads);
@@ -1305,6 +1358,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
f->ist_index = nb_input_streams - ic->nb_streams;
f->start_time = o->start_time;
f->recording_time = o->recording_time;
f->input_sync_ref = o->input_sync_ref;
f->input_ts_offset = o->input_ts_offset;
f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);
f->nb_streams = ic->nb_streams;
@@ -3489,6 +3543,8 @@ int ffmpeg_parse_options(int argc, char **argv)
goto fail;
}
apply_sync_offsets();
/* create the complex filtergraphs */
ret = init_complex_filters();
if (ret < 0) {
@@ -3603,6 +3659,9 @@ const OptionDef options[] = {
{ "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT |
OPT_INPUT, { .off = OFFSET(accurate_seek) },
"enable/disable accurate seeking with -ss" },
{ "isync", HAS_ARG | OPT_INT | OPT_OFFSET |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_sync_ref) },
"Indicate the input index for sync reference", "sync ref" },
{ "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_ts_offset) },
"set the input ts offset", "time_off" },

View File

@@ -1241,7 +1241,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
td->ysize = FFMIN(s->tile_attr.ySize, s->ydelta - tile_y * s->tile_attr.ySize);
td->xsize = FFMIN(s->tile_attr.xSize, s->xdelta - tile_x * s->tile_attr.xSize);
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX)
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
av_image_check_size2(td->xsize, td->ysize, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA;
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
@@ -1265,7 +1266,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
td->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */
td->xsize = s->xdelta;
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX)
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
av_image_check_size2(td->xsize, td->ysize, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA;
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */

View File

@@ -883,7 +883,14 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (buf_size < avctx->width * avctx->height / (128*8))
return AVERROR_INVALIDDATA;
} else {
if (buf_size < avctx->height / 8)
int w = avctx->width;
int s = 1 + w / (1<<23);
w /= s;
for (i = 0; w > (1<<ff_log2_run[i]); i++)
w -= ff_log2_run[i];
if (buf_size < (avctx->height + i + 6) / 8 * s)
return AVERROR_INVALIDDATA;
}

View File

@@ -143,11 +143,22 @@ static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height,
if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) {
for (i = 0; i < height; i++) {
for (j = 0; j < width; j+=8)
for (j = 0; j < width - 7; j+=8)
AV_COPY64U(dst+j, src+j);
dst += stride_dst;
src += stride_src;
}
if (width&7) {
dst += ((width>>3)<<3) - stride_dst * height;
src += ((width>>3)<<3) - stride_src * height;
width &= 7;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++)
dst[j] = src[j];
dst += stride_dst;
src += stride_src;
}
}
} else {
for (i = 0; i < height; i++) {
for (j = 0; j < width; j+=16)

View File

@@ -409,6 +409,9 @@ output_zeros:
if (zero_run) {
zero_run = 0;
i += esc_count;
if (i > end - dst ||
i >= src_end - src)
return AVERROR_INVALIDDATA;
memcpy(dst, src, i);
dst += i;
l->zeros_rem = lag_calc_zero_run(src[i]);

View File

@@ -26,6 +26,7 @@
*/
#include "libavutil/thread.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
@@ -477,6 +478,9 @@ static int mss4_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
width, height);
return AVERROR_INVALIDDATA;
}
if (av_image_check_size2(width, height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)
return AVERROR_INVALIDDATA;
if (quality < 1 || quality > 100) {
av_log(avctx, AV_LOG_ERROR, "Invalid quality setting %d\n", quality);
return AVERROR_INVALIDDATA;

View File

@@ -965,6 +965,9 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
int pos_x = 0, pos_y = 0;
int ret;
if (s->tile_width <= 0 || s->tile_length <= 0)
return AVERROR_INVALIDDATA;
has_width_leftover = (s->width % s->tile_width != 0);
has_height_leftover = (s->height % s->tile_length != 0);

View File

@@ -75,9 +75,11 @@ int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)
ret = s->oformat->get_device_list(s, *device_list);
else
ret = s->iformat->get_device_list(s, *device_list);
if (ret < 0)
if (ret < 0) {
avdevice_free_list_devices(device_list);
return ret;
return ret;
}
return (*device_list)->nb_devices;
}
static int list_devices_for_context(AVFormatContext *s, AVDictionary *options,

View File

@@ -104,7 +104,7 @@ typedef struct ASFContext {
int ts_is_pts;
int packet_multi_size;
int packet_time_delta;
int packet_time_start;
int64_t packet_time_start;
int64_t packet_pos;
int stream_index;

View File

@@ -463,6 +463,8 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m
goto invalid;
if (current_array == &times && (d <= INT64_MIN / 1000 || d >= INT64_MAX / 1000))
goto invalid;
if (avio_feof(ioc))
goto invalid;
current_array[0][i] = d;
}
if (times && filepositions) {

View File

@@ -7540,6 +7540,8 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
for (int i = 0; i < item_count; i++) {
int item_id = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
if (avio_feof(pb))
return AVERROR_INVALIDDATA;
if (version > 0)
avio_rb16(pb); // construction_method.
avio_rb16(pb); // data_reference_index.

View File

@@ -200,6 +200,8 @@ static int decode_main_header(NUTContext *nut)
int tmp_stream, tmp_mul, tmp_pts, tmp_size, tmp_res, tmp_head_idx;
length = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
if (length == (uint64_t)-1)
return AVERROR_INVALIDDATA;
end = length + avio_tell(bc);
nut->version = ffio_read_varlen(bc);

View File

@@ -166,6 +166,17 @@ static AVBufferRef *wrap_texture_buf(AVHWFramesContext *ctx, ID3D11Texture2D *te
return NULL;
}
if (s->nb_surfaces <= s->nb_surfaces_used) {
frames_hwctx->texture_infos = av_realloc_f(frames_hwctx->texture_infos,
s->nb_surfaces_used + 1,
sizeof(*frames_hwctx->texture_infos));
if (!frames_hwctx->texture_infos) {
ID3D11Texture2D_Release(tex);
return NULL;
}
s->nb_surfaces = s->nb_surfaces_used + 1;
}
frames_hwctx->texture_infos[s->nb_surfaces_used].texture = tex;
frames_hwctx->texture_infos[s->nb_surfaces_used].index = index;
s->nb_surfaces_used++;
@@ -284,7 +295,7 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx)
}
}
hwctx->texture_infos = av_calloc(ctx->initial_pool_size, sizeof(*hwctx->texture_infos));
hwctx->texture_infos = av_realloc_f(NULL, ctx->initial_pool_size, sizeof(*hwctx->texture_infos));
if (!hwctx->texture_infos)
return AVERROR(ENOMEM);
s->nb_surfaces = ctx->initial_pool_size;

View File

@@ -246,6 +246,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
case AV_CODEC_ID_LOCO: maxpixels /= 1024; break;
case AV_CODEC_ID_VORBIS: maxsamples /= 1024; break;
case AV_CODEC_ID_LSCR: maxpixels /= 16; break;
case AV_CODEC_ID_MMVIDEO: maxpixels /= 256; break;
case AV_CODEC_ID_MOTIONPIXELS:maxpixels /= 256; break;
case AV_CODEC_ID_MP4ALS: maxsamples /= 65536; break;
case AV_CODEC_ID_MSA1: maxpixels /= 16384; break;