Compare commits

...

25 Commits
n7.0 ... n6.0

Author SHA1 Message Date
Michael Niedermayer
ea3d24bbe3 RELEASE_NOTES: Based on the version from 5.1
Name suggested by Niklas Haas

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-26 00:13:45 +01:00
Michael Niedermayer
ff5cce2eaf avcodec/motionpixels: Mask pixels to valid values
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOTIONPIXELS_fuzzer-6724203352555520

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 ac6eec1fc2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:50:36 +01:00
Michael Niedermayer
1eb1acb62b avcodec/xpmdec: Check size before allocation to avoid truncation
Fixes:OOM
Fixes:out of array access (no testcase)
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-6573323838685184

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 95f0f84dae)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:50:10 +01:00
Michael Niedermayer
718d6c71ef avcodec/bink: Avoid undefined out of array end pointers in binkb_decode_plane()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ea9deafd3b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:49:27 +01:00
Michael Niedermayer
8ab01c8b0d avcodec/bink: Fix off by 1 error in ref end
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-6657932926517248

Alterantivly to this it is possibly to allocate a bigger array

Note: oss-fuzz assigned this issue to a unrelated theora bug so the bug number matches that

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 49487045dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:48:29 +01:00
Michael Niedermayer
d1e446d570 avcodec/utils: Ensure linesize for SVQ3
Fixes: Assertion block_w * sizeof(uint8_t) <= ((buf_linesize) >= 0 ? (buf_linesize) : (-(buf_linesize))
Fixes: 54861/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5352418248622080

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 4eef658ca5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:52:50 +01:00
Michael Niedermayer
8e478e0cb1 avcodec/utils: allocate a line more for VC1 and WMV3
Fixes: out of array read on 32bit
Fixes: 54857/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5840588224462848

The chroma MC code reads over the currently allocated frame.
Alternative fixes would be allocating a few bytes more at the end instead of a whole
line extra or to adjust the threshold where the edge emu code is activated

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 01636a63d4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:40:02 +01:00
Michael Niedermayer
81d9c57c43 avcodec/videodsp_template: Adjust pointers to avoid undefined pointer things
Fixes: subtraction of unsigned offset from 0xf6602770 overflowed to 0xf6638c80
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-495074400600064

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 f0150cd41c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:39:17 +01:00
Michael Niedermayer
3ae6feff7e avcodec/pngdec: dont skip/read chunk twice
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-6668158952144896.fuzz

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 df1a38d520)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:27:12 +01:00
Michael Niedermayer
197dcd28ef avcodec/pngdec: Check deloco index more exactly
Fixes: out of array access:
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-6716193709096960

Alternatively it should be possible to limit this to 3 plane RGB 8 /16bit to ensure the size is what it should be

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 d5bae70406)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:20:35 +01:00
Michael Niedermayer
bc531eedbd avformat/wavarc: Check if extradata has been fully read
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2df271c78c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:20:11 +01:00
Michael Niedermayer
e4eed31133 avcodec/wavarc: Check k
Fixes: Assertion failure
Fixes: 55849/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6590105973555200

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 4dee46426e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:19:58 +01:00
Michael Niedermayer
c56f84e656 avcodec/ffv1dec: Check that num h/v slices is supported
Fixes: out of array access
Fixes: 55597/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4898293416329216

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 8ead0ae68e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:08:41 +01:00
Michael Niedermayer
bbcf3f4234 avcodec/rka: avoid undefined doubling sum overflow
Fixes: signed integer overflow: -2124073172 * 2 cannot be represented in type 'int'
Fixes: 56099/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-4530933127839744

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 a02e45a1f3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:08:13 +01:00
Michael Niedermayer
8a6c037acd avcodec/rka: avoid negative value shift
Fixes: left shift of negative value -81
Fixes: 56061/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-4649758062149632

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 a5d4e7e3f9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:08:03 +01:00
Michael Niedermayer
b59152b474 avcodec/rka: check for size 1 filter
Such filters will not advance and be stuck in the current implementation

Fixes: Infinite loop
Fixes: 56052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5236218750435328

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 8874cfa2e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:06:40 +01:00
Michael Niedermayer
0c1e67ab14 avcodec/rka: Fix some integer anomalies
Fixes: left shift of negative value -3201
Fixes: integer overflow: -76470276 * -25608 cannot be represented in type 'int'
Fixes: 56052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5236218750435328

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 d495747a9f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:06:21 +01:00
Michael Niedermayer
ec5edc0946 avformat/rka: Fix 1/0 with bps=1
Fixes: division by zero
Fixes: 55940/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6333107679920128

The decoder does not support bps=1 and i have no such sample so it is not
known if this duration is correct. Alternatively we could error out on all
bps we currently do not support on the decoder side or not set duration.

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 b3df7ca748)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:05:55 +01:00
Michael Niedermayer
6f1b24c4fe avformat/mov: Check samplesize and offset to avoid integer overflow
Fixes: signed integer overflow: 9223372036854775584 + 536870912 cannot be represented in type 'long'
Fixes: 55844/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-510613920664780

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 53c1f5c2e2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 20:54:16 +01:00
John Coiner
691d019899 avformat/mpegtsenc: re-emit extradata ahead of IDR pictures even if AUD is already present
Current mpegtsenc code only inserts SPS/PPS from extradata before IDR frames if
AUD is also inserted.

Unfortunately some encoders may preface a key frame with an AUD, but no
SPS/PPS. In that case current code does not repeat the "extradata" and the
resulting HLS stream may become noncompliant and unjoinable.

Fix this by always inserting SPS/PPS and moving AUD to the beginning of the
packet if it is already present.

Fixes ticket #10148.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit e0cb89c354)
2023-02-19 22:50:32 +01:00
Marton Balint
65873ac3ee doc: remove docs for options removed at the bump
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 3807fbd90a)
2023-02-19 22:50:21 +01:00
James Almer
34a1403831 avfilter/af_pan: use the new swr used channel layout option
Fixes ticket #10180

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 4561232b1a)
2023-02-19 18:30:15 -03:00
James Almer
a34b348328 swresample/swresample: add a used channel layout option using the new API
Replaces the "used channel count" option, which is now deprecated.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 223c70cf1d)
2023-02-19 18:30:15 -03:00
James Almer
6112745d8e doc/resampler.texi: add missing swr channel layout options
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1d14959f12)
2023-02-19 18:30:15 -03:00
Michael Niedermayer
71534916df Update things for 6.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 19:16:39 +01:00
26 changed files with 150 additions and 94 deletions

View File

@@ -1 +1 @@
5.1.git
6.0

15
RELEASE_NOTES Normal file
View File

@@ -0,0 +1,15 @@
┌────────────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 6.0 "Von Neumann" │
└────────────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 6.0 "Von Neumann", about 6
months after the release of FFmpeg 5.1.
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 = 6.0
# 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

@@ -1949,22 +1949,6 @@ Set the number of slices, used in parallelized encoding. Default value
is 0. This is only used when @option{slice_mode} is set to
@samp{fixed}.
@item slice_mode
Set slice mode. Can assume one of the following possible values:
@table @samp
@item fixed
a fixed number of slices
@item rowmb
one slice per row of macroblocks
@item auto
automatic number of slices according to number of threads
@item dyn
dynamic slicing
@end table
Default value is @samp{auto}.
@item loopfilter
Enable loop filter, if set to 1 (automatically enabled). To disable
set a value of 0.

View File

@@ -26943,11 +26943,6 @@ Specify the frame rate expected for the video stream.
@item pixel_aspect, sar
The sample (pixel) aspect ratio of the input video.
@item sws_param
This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};}
to the filtergraph description to specify swscale flags for automatically
inserted scalers. See @ref{Filtergraph syntax}.
@item hw_frames_ctx
When using a hardware pixel format, this should be a reference to an
AVHWFramesContext describing input frames.

View File

@@ -795,12 +795,6 @@ deletes them. Increase this to allow continue clients to download segments which
were recently referenced in the playlist. Default value is 1, meaning segments older than
@code{hls_list_size+1} will be deleted.
@item hls_ts_options @var{options_list}
Set output format options using a :-separated list of key=value
parameters. Values containing @code{:} special characters must be
escaped.
@code{hls_ts_options} is deprecated, use hls_segment_options instead of it..
@item hls_start_number_source
Start the playlist sequence number (@code{#EXT-X-MEDIA-SEQUENCE}) according to the specified source.
Unless @code{hls_flags single_file} is set, it also specifies source of starting sequence numbers of

View File

@@ -11,18 +11,8 @@ programmatic use.
@table @option
@item ich, in_channel_count
Set the number of input channels. Default value is 0. Setting this
value is not mandatory if the corresponding channel layout
@option{in_channel_layout} is set.
@item och, out_channel_count
Set the number of output channels. Default value is 0. Setting this
value is not mandatory if the corresponding channel layout
@option{out_channel_layout} is set.
@item uch, used_channel_count
Set the number of used input channels. Default value is 0. This option is
@item uchl, used_chlayout
Set used input channel layout. Default is unset. This option is
only used for special remapping.
@item isr, in_sample_rate
@@ -41,8 +31,8 @@ Specify the output sample format. It is set by default to @code{none}.
Set the internal sample format. Default value is @code{none}.
This will automatically be chosen when it is not explicitly set.
@item icl, in_channel_layout
@item ocl, out_channel_layout
@item ichl, in_chlayout
@item ochl, out_chlayout
Set the input/output channel layout.
See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}

View File

@@ -870,7 +870,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
binkb_init_bundles(c);
ref_start = frame->data[plane_idx];
ref_end = frame->data[plane_idx] + (bh * frame->linesize[plane_idx] + bw) * 8;
ref_end = frame->data[plane_idx] + ((bh - 1) * frame->linesize[plane_idx] + bw - 1) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
@@ -926,7 +926,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride;
if (ref < ref_start || ref + 8*stride > ref_end) {
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8);
@@ -942,7 +942,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride;
if (ref < ref_start || ref + 8 * stride > ref_end) {
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8);
@@ -974,7 +974,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride;
if (ref < ref_start || ref + 8 * stride > ref_end) {
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8);

View File

@@ -475,6 +475,11 @@ static int read_extra_header(FFV1Context *f)
return AVERROR_INVALIDDATA;
}
if (f->num_h_slices > MAX_SLICES / f->num_v_slices) {
av_log(f->avctx, AV_LOG_ERROR, "slice count unsupported\n");
return AVERROR_PATCHWELCOME;
}
f->quant_table_count = get_symbol(c, state, 0);
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES || !f->quant_table_count) {
av_log(f->avctx, AV_LOG_ERROR, "quant table count %d is invalid\n", f->quant_table_count);

View File

@@ -185,7 +185,7 @@ static YuvPixel mp_get_yuv_from_rgb(MotionPixelsContext *mp, int x, int y)
int color;
color = *(uint16_t *)&mp->frame->data[0][y * mp->frame->linesize[0] + x * 2];
return mp_rgb_yuv_table[color];
return mp_rgb_yuv_table[color & 0x7FFF];
}
static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const YuvPixel *p)

View File

@@ -329,7 +329,7 @@ void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
{ \
int i; \
for (i = 0; i < size; i += 3 + alpha) { \
for (i = 0; i < size - 2; i += 3 + alpha) { \
int g = dst [i + 1]; \
dst[i + 0] += g; \
dst[i + 2] += g; \
@@ -1238,6 +1238,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
}
av_log(avctx, AV_LOG_ERROR, ", skipping\n");
bytestream2_skip(&s->gb, length + 8); /* tag */
continue;
}
}
tag = bytestream2_get_le32(&s->gb);

View File

@@ -691,7 +691,7 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns
else
split = size >> 4;
if (size <= 0)
if (size <= 1)
return 0;
for (int x = 0; x < size;) {
@@ -723,21 +723,21 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns
last_val = val;
src = &ctx->buf1[off + -1];
for (int i = 0; i < filt.size && i < 15; i++)
sum += filt.coeffs[i] * src[-i];
sum = sum * 2;
sum += filt.coeffs[i] * (unsigned)src[-i];
sum = sum * 2U;
for (int i = 15; i < filt.size; i++)
sum += filt.coeffs[i] * src[-i];
sum += filt.coeffs[i] * (unsigned)src[-i];
sum = sum >> 6;
if (ctx->cmode == 0) {
if (bits == 0) {
ctx->buf1[off] = sum + val;
} else {
ctx->buf1[off] = (val + (sum >> bits) << bits) +
ctx->buf1[off] = (val + (sum >> bits)) * (1 << bits) +
(((1U << bits) - 1U) & ctx->buf1[off + -1]);
}
ctx->buf0[off] = ctx->buf1[off] + ctx->buf0[off + -1];
} else {
val <<= ctx->cmode;
val *= 1 << ctx->cmode;
sum += ctx->buf0[off + -1] + val;
switch (s->bps) {
case 16: sum = av_clip_int16(sum); break;

View File

@@ -323,6 +323,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
*width = FFALIGN(*width, w_align);
*height = FFALIGN(*height, h_align);
if (s->codec_id == AV_CODEC_ID_H264 || s->lowres ||
s->codec_id == AV_CODEC_ID_VC1 || s->codec_id == AV_CODEC_ID_WMV3 ||
s->codec_id == AV_CODEC_ID_VP5 || s->codec_id == AV_CODEC_ID_VP6 ||
s->codec_id == AV_CODEC_ID_VP6F || s->codec_id == AV_CODEC_ID_VP6A
) {
@@ -336,6 +337,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
// the next rounded up width is 32
*width = FFMAX(*width, 32);
}
if (s->codec_id == AV_CODEC_ID_SVQ3) {
*width = FFMAX(*width, 32);
}
for (i = 0; i < 4; i++)
linesize_align[i] = STRIDE_ALIGN;

View File

@@ -64,7 +64,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
av_assert2(start_x < end_x && block_w);
w = end_x - start_x;
src += start_y * src_linesize + start_x * sizeof(pixel);
src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel);
buf += start_x * sizeof(pixel);
// top
@@ -87,7 +87,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
buf += buf_linesize;
}
buf -= block_h * buf_linesize + start_x * sizeof(pixel);
buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel);
while (block_h--) {
pixel *bufp = (pixel *) buf;

View File

@@ -192,6 +192,8 @@ static int decode_1dif(AVCodecContext *avctx,
if (block_type < 4 && block_type >= 0) {
k = 1 + (avctx->sample_fmt == AV_SAMPLE_FMT_S16P);
k = get_urice(gb, k) + 1;
if (k > 32)
return AVERROR_INVALIDDATA;
}
switch (block_type) {
@@ -282,6 +284,8 @@ static int decode_2slp(AVCodecContext *avctx,
if (block_type < 5 && block_type >= 0) {
k = 1 + (avctx->sample_fmt == AV_SAMPLE_FMT_S16P);
k = get_urice(gb, k) + 1;
if (k > 32)
return AVERROR_INVALIDDATA;
}
switch (block_type) {

View File

@@ -354,6 +354,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, AVFrame *p,
return AVERROR_INVALIDDATA;
}
if (size > SIZE_MAX / 4)
return AVERROR(ENOMEM);
size *= 4;
ptr += mod_strcspn(ptr, ",") + 1;

View File

@@ -313,7 +313,7 @@ static int config_props(AVFilterLink *link)
pan->channel_map[i] = ch_id;
}
av_opt_set_int(pan->swr, "uch", pan->nb_output_channels, 0);
av_opt_set_chlayout(pan->swr, "uchl", &pan->out_channel_layout, 0);
swr_set_channel_mapping(pan->swr, pan->channel_map);
} else {
// renormalize

View File

@@ -4192,6 +4192,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
if (keyframe)
distance = 0;
sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizes[current_sample];
if (current_offset > INT64_MAX - sample_size) {
av_log(mov->fc, AV_LOG_ERROR, "Current offset %"PRId64" or sample size %u is too large\n",
current_offset,
sample_size);
return;
}
if (sc->pseudo_stream_id == -1 ||
sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) {
AVIndexEntry *e;

View File

@@ -29,6 +29,8 @@
#include "libavcodec/ac3_parser_internal.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/h264.h"
#include "libavcodec/startcode.h"
#include "avformat.h"
@@ -1877,6 +1879,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
const uint8_t *p = buf, *buf_end = p + size;
const uint8_t *found_aud = NULL, *found_aud_end = NULL;
uint32_t state = -1;
int extradd = (pkt->flags & AV_PKT_FLAG_KEY) ? st->codecpar->extradata_size : 0;
int ret = ff_check_h264_startcode(s, st, pkt);
@@ -1886,27 +1889,58 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
if (extradd && AV_RB24(st->codecpar->extradata) > 1)
extradd = 0;
/* Ensure that all pictures are prefixed with an AUD, and that
* IDR pictures are also prefixed with SPS and PPS. SPS and PPS
* are assumed to be available in 'extradata' if not found in-band. */
do {
p = avpriv_find_start_code(p, buf_end, &state);
av_log(s, AV_LOG_TRACE, "nal %"PRId32"\n", state & 0x1f);
if ((state & 0x1f) == 7)
if ((state & 0x1f) == H264_NAL_SPS)
extradd = 0;
} while (p < buf_end && (state & 0x1f) != 9 &&
(state & 0x1f) != 5 && (state & 0x1f) != 1);
if ((state & 0x1f) != 5)
if ((state & 0x1f) == H264_NAL_AUD) {
found_aud = p - 4; // start of the 0x000001 start code.
found_aud_end = p + 1; // first byte past the AUD.
if (found_aud < buf)
found_aud = buf;
if (buf_end < found_aud_end)
found_aud_end = buf_end;
}
} while (p < buf_end
&& (state & 0x1f) != H264_NAL_IDR_SLICE
&& (state & 0x1f) != H264_NAL_SLICE
&& (extradd > 0 || !found_aud));
if ((state & 0x1f) != H264_NAL_IDR_SLICE)
extradd = 0;
if ((state & 0x1f) != 9) { // AUD NAL
if (!found_aud) {
/* Prefix 'buf' with the missing AUD, and extradata if needed. */
data = av_malloc(pkt->size + 6 + extradd);
if (!data)
return AVERROR(ENOMEM);
memcpy(data + 6, st->codecpar->extradata, extradd);
memcpy(data + 6 + extradd, pkt->data, pkt->size);
AV_WB32(data, 0x00000001);
data[4] = 0x09;
data[4] = H264_NAL_AUD;
data[5] = 0xf0; // any slice type (0xe) + rbsp stop one bit
buf = data;
size = pkt->size + 6 + extradd;
} else if (extradd != 0) {
/* Move the AUD up to the beginning of the frame, where the H.264
* spec requires it to appear. Emit the extradata after it. */
PutByteContext pb;
const int new_pkt_size = pkt->size + 1 + extradd;
data = av_malloc(new_pkt_size);
if (!data)
return AVERROR(ENOMEM);
bytestream2_init_writer(&pb, data, new_pkt_size);
bytestream2_put_byte(&pb, 0x00);
bytestream2_put_buffer(&pb, found_aud, found_aud_end - found_aud);
bytestream2_put_buffer(&pb, st->codecpar->extradata, extradd);
bytestream2_put_buffer(&pb, pkt->data, found_aud - pkt->data);
bytestream2_put_buffer(&pb, found_aud_end, buf_end - found_aud_end);
av_assert0(new_pkt_size == bytestream2_tell_p(&pb));
buf = data;
size = new_pkt_size;
}
} else if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
if (pkt->size < 2) {

View File

@@ -114,7 +114,7 @@ static int rka_read_header(AVFormatContext *s)
par->ch_layout.nb_channels = channels;
par->sample_rate = samplerate;
par->bits_per_raw_sample = bps;
st->duration = nb_samples / (channels * (bps >> 3));
st->duration = 8LL*nb_samples / (channels * bps);
if (s->pb->seekable & AVIO_SEEKABLE_NORMAL)
ff_ape_parse_tag(s);

View File

@@ -22,6 +22,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
@@ -84,7 +85,9 @@ static int wavarc_read_header(AVFormatContext *s)
if (ret < 0)
return ret;
memcpy(par->extradata, data, sizeof(data));
avio_read(pb, par->extradata + sizeof(data), fmt_len);
ret = ffio_read_size(pb, par->extradata + sizeof(data), fmt_len);
if (ret < 0)
return ret;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->codec_id = AV_CODEC_ID_WAVARC;

View File

@@ -46,9 +46,9 @@ static const AVOption options[]={
OFFSET(user_out_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"out_channel_count" , "set output channel count (Deprecated, use out_chlayout)",
OFFSET(user_out_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"uch" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
{"used_channel_count" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM|DEPREC},
#endif
{"uch" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
{"used_channel_count" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
{"isr" , "set input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
{"in_sample_rate" , "set input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
{"osr" , "set output sample rate" , OFFSET(out_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
@@ -73,6 +73,8 @@ static const AVOption options[]={
{"in_chlayout" , "set input channel layout" , OFFSET(user_in_chlayout ), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, "chlayout"},
{"ochl" , "set output channel layout" , OFFSET(user_out_chlayout), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, "chlayout"},
{"out_chlayout" , "set output channel layout" , OFFSET(user_out_chlayout), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, "chlayout"},
{"uchl" , "set used channel layout" , OFFSET(user_used_chlayout), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, "chlayout"},
{"used_chlayout" , "set used channel layout" , OFFSET(user_used_chlayout), AV_OPT_TYPE_CHLAYOUT, {.str=NULL }, 0, 0 , PARAM, "chlayout"},
{"clev" , "set center mix level" , OFFSET(clev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM},
{"center_mix_level" , "set center mix level" , OFFSET(clev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM},
{"slev" , "set surround mix level" , OFFSET(slev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM},

View File

@@ -492,7 +492,7 @@ av_cold static int auto_matrix(SwrContext *s)
av_cold int swri_rematrix_init(SwrContext *s){
int i, j;
int nb_in = s->used_ch_count;
int nb_in = s->used_ch_layout.nb_channels;
int nb_out = s->out.ch_count;
s->mix_any_f = NULL;

View File

@@ -161,6 +161,7 @@ static void clear_context(SwrContext *s){
free_temp(&s->dither.temp);
av_channel_layout_uninit(&s->in_ch_layout);
av_channel_layout_uninit(&s->out_ch_layout);
av_channel_layout_uninit(&s->used_ch_layout);
swri_audio_convert_free(&s-> in_convert);
swri_audio_convert_free(&s->out_convert);
swri_audio_convert_free(&s->full_convert);
@@ -176,6 +177,7 @@ av_cold void swr_free(SwrContext **ss){
clear_context(s);
av_channel_layout_uninit(&s->user_in_chlayout);
av_channel_layout_uninit(&s->user_out_chlayout);
av_channel_layout_uninit(&s->user_used_chlayout);
if (s->resampler)
s->resampler->free(&s->resample);
@@ -211,12 +213,20 @@ av_cold int swr_init(struct SwrContext *s){
av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is invalid\n", s->out_sample_rate);
return AVERROR(EINVAL);
}
s->used_ch_count = s->user_used_ch_count;
#if FF_API_OLD_CHANNEL_LAYOUT
s->out.ch_count = s-> user_out_ch_count;
s-> in.ch_count = s-> user_in_ch_count;
// if the old/new fields are set inconsistently, prefer the old ones
if (s->user_used_ch_count && s->user_used_ch_count != s->user_used_chlayout.nb_channels) {
av_channel_layout_uninit(&s->used_ch_layout);
s->used_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
s->used_ch_layout.nb_channels = s->user_used_ch_count;
} else if (av_channel_layout_check(&s->user_used_chlayout)) {
ret = av_channel_layout_copy(&s->used_ch_layout, &s->user_used_chlayout);
if (ret < 0)
return ret;
}
if ((s->user_in_ch_count && s->user_in_ch_count != s->user_in_chlayout.nb_channels) ||
(s->user_in_ch_layout && (s->user_in_chlayout.order != AV_CHANNEL_ORDER_NATIVE ||
s->user_in_chlayout.u.mask != s->user_in_ch_layout))) {
@@ -243,9 +253,9 @@ av_cold int swr_init(struct SwrContext *s){
} else if (av_channel_layout_check(&s->user_out_chlayout))
av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout);
if (!s->out.ch_count && !s->user_out_ch_layout)
if (!s->out.ch_count)
s->out.ch_count = s->out_ch_layout.nb_channels;
if (!s-> in.ch_count && !s-> user_in_ch_layout)
if (!s-> in.ch_count)
s-> in.ch_count = s->in_ch_layout.nb_channels;
if (!(ret = av_channel_layout_check(&s->in_ch_layout)) || s->in_ch_layout.nb_channels > SWR_CH_MAX) {
@@ -281,6 +291,7 @@ av_cold int swr_init(struct SwrContext *s){
ret = av_channel_layout_copy(&s->in_ch_layout, &s->user_in_chlayout);
ret |= av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout);
ret |= av_channel_layout_copy(&s->used_ch_layout, &s->user_used_chlayout);
if (ret < 0)
return ret;
#endif
@@ -299,16 +310,19 @@ av_cold int swr_init(struct SwrContext *s){
return AVERROR(EINVAL);
}
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if (!av_channel_layout_check(&s->used_ch_layout))
av_channel_layout_default(&s->used_ch_layout, s->in.ch_count);
if (s->used_ch_count && s->in_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC && s->used_ch_count != s->in_ch_layout.nb_channels) {
av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n");
if (s->used_ch_layout.nb_channels != s->in_ch_layout.nb_channels)
av_channel_layout_uninit(&s->in_ch_layout);
}
if (s->in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
av_channel_layout_default(&s->in_ch_layout, s->used_ch_count);
if (s->used_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
av_channel_layout_default(&s->used_ch_layout, s->used_ch_layout.nb_channels);
if (s->in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
ret = av_channel_layout_copy(&s->in_ch_layout, &s->used_ch_layout);
if (ret < 0)
return ret;
}
if (s->out_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
av_channel_layout_default(&s->out_ch_layout, s->out.ch_count);
@@ -389,8 +403,8 @@ av_cold int swr_init(struct SwrContext *s){
#define RSC 1 //FIXME finetune
if(!s-> in.ch_count)
s-> in.ch_count = s->in_ch_layout.nb_channels;
if(!s->used_ch_count)
s->used_ch_count= s->in.ch_count;
if (!av_channel_layout_check(&s->used_ch_layout))
av_channel_layout_default(&s->used_ch_layout, s->in.ch_count);
if(!s->out.ch_count)
s->out.ch_count = s->out_ch_layout.nb_channels;
@@ -410,23 +424,23 @@ av_cold int swr_init(struct SwrContext *s){
}
#endif
av_channel_layout_describe(&s->in_ch_layout, l1, sizeof(l1));
if (s->in_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC && s->used_ch_count != s->in_ch_layout.nb_channels) {
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_count);
if (s->in_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC && s->used_ch_layout.nb_channels != s->in_ch_layout.nb_channels) {
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_layout.nb_channels);
ret = AVERROR(EINVAL);
goto fail;
}
if (( s->out_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC
|| s-> in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
|| s-> in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) && s->used_ch_layout.nb_channels != s->out.ch_count && !s->rematrix_custom) {
av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
"but there is not enough information to do it\n", l1, l2);
ret = AVERROR(EINVAL);
goto fail;
}
av_assert0(s->used_ch_count);
av_assert0(s->used_ch_layout.nb_channels);
av_assert0(s->out.ch_count);
s->resample_first= RSC*s->out.ch_count/s->used_ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
s->resample_first= RSC*s->out.ch_count/s->used_ch_layout.nb_channels - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
s->in_buffer= s->in;
s->silence = s->in;
@@ -442,7 +456,7 @@ av_assert0(s->out.ch_count);
}
s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
s-> in_sample_fmt, s->used_ch_layout.nb_channels, s->channel_map, 0);
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
s->int_sample_fmt, s->out.ch_count, NULL, 0);
@@ -457,9 +471,9 @@ av_assert0(s->out.ch_count);
if(s->channel_map){
s->postin.ch_count=
s->midbuf.ch_count= s->used_ch_count;
s->midbuf.ch_count= s->used_ch_layout.nb_channels;
if(s->resample)
s->in_buffer.ch_count= s->used_ch_count;
s->in_buffer.ch_count= s->used_ch_layout.nb_channels;
}
if(!s->resample_first){
s->midbuf.ch_count= s->out.ch_count;
@@ -697,7 +711,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
if((ret=swri_realloc_audio(&s->postin, in_count))<0)
return ret;
if(s->resample_first){
av_assert0(s->midbuf.ch_count == s->used_ch_count);
av_assert0(s->midbuf.ch_count == s->used_ch_layout.nb_channels);
if((ret=swri_realloc_audio(&s->midbuf, out_count))<0)
return ret;
}else{

View File

@@ -99,6 +99,7 @@ struct SwrContext {
enum AVSampleFormat in_sample_fmt; ///< input sample format
enum AVSampleFormat int_sample_fmt; ///< internal sample format (AV_SAMPLE_FMT_FLTP or AV_SAMPLE_FMT_S16P)
enum AVSampleFormat out_sample_fmt; ///< output sample format
AVChannelLayout used_ch_layout; ///< number of used input channels (mapped channel count if channel_map, otherwise in.ch_count)
AVChannelLayout in_ch_layout; ///< input channel layout
AVChannelLayout out_ch_layout; ///< output channel layout
int in_sample_rate; ///< input sample rate
@@ -111,16 +112,16 @@ struct SwrContext {
float rematrix_maxval; ///< maximum value for rematrixing output
int matrix_encoding; /**< matrixed stereo encoding */
const int *channel_map; ///< channel index (or -1 if muted channel) map
int used_ch_count; ///< number of used input channels (mapped channel count if channel_map, otherwise in.ch_count)
int engine;
int user_used_ch_count; ///< User set used channel count
#if FF_API_OLD_CHANNEL_LAYOUT
int user_used_ch_count; ///< User set used channel count
int user_in_ch_count; ///< User set input channel count
int user_out_ch_count; ///< User set output channel count
int64_t user_in_ch_layout; ///< User set input channel layout
int64_t user_out_ch_layout; ///< User set output channel layout
#endif
AVChannelLayout user_used_chlayout; ///< User set used channel layout
AVChannelLayout user_in_chlayout; ///< User set input channel layout
AVChannelLayout user_out_chlayout; ///< User set output channel layout
enum AVSampleFormat user_int_sample_fmt; ///< User set internal sample format

View File

@@ -33,7 +33,7 @@ D(int16, sse2)
av_cold int swri_rematrix_init_x86(struct SwrContext *s){
#if HAVE_X86ASM
int mm_flags = av_get_cpu_flags();
int nb_in = s->used_ch_count;
int nb_in = s->used_ch_layout.nb_channels;
int nb_out = s->out.ch_count;
int num = nb_in * nb_out;
int i,j;