mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-11 01:10:00 +01:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea3d24bbe3 | ||
|
|
ff5cce2eaf | ||
|
|
1eb1acb62b | ||
|
|
718d6c71ef | ||
|
|
8ab01c8b0d | ||
|
|
d1e446d570 | ||
|
|
8e478e0cb1 | ||
|
|
81d9c57c43 | ||
|
|
3ae6feff7e | ||
|
|
197dcd28ef | ||
|
|
bc531eedbd | ||
|
|
e4eed31133 | ||
|
|
c56f84e656 | ||
|
|
bbcf3f4234 | ||
|
|
8a6c037acd | ||
|
|
b59152b474 | ||
|
|
0c1e67ab14 | ||
|
|
ec5edc0946 | ||
|
|
6f1b24c4fe | ||
|
|
691d019899 | ||
|
|
65873ac3ee | ||
|
|
34a1403831 | ||
|
|
a34b348328 | ||
|
|
6112745d8e | ||
|
|
71534916df |
15
RELEASE_NOTES
Normal file
15
RELEASE_NOTES
Normal 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.
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user