Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e12af29d1 | ||
|
|
716b5c6ec9 | ||
|
|
9d921e38f4 | ||
|
|
c49dfee90b | ||
|
|
3f3cfddb37 | ||
|
|
b7897f0319 | ||
|
|
6eac7d79f4 | ||
|
|
04e1d16f65 | ||
|
|
49b60a9a52 | ||
|
|
3201350dc7 | ||
|
|
157bbc779c | ||
|
|
bf29cf8eb6 | ||
|
|
6e64260a19 | ||
|
|
7754a2ea12 | ||
|
|
d84b9ab4ab | ||
|
|
f172490742 | ||
|
|
330a757d41 | ||
|
|
ea27fe480e | ||
|
|
db2002aee7 | ||
|
|
788a7c027b | ||
|
|
7c0a9ff9c0 | ||
|
|
30d66abc80 | ||
|
|
5171e0ee18 | ||
|
|
245d0f1889 | ||
|
|
0260352d92 | ||
|
|
a2ab8babef | ||
|
|
751f285152 | ||
|
|
2c738c7521 | ||
|
|
82d70d8038 | ||
|
|
cc948a1c8c | ||
|
|
5c1e458b34 | ||
|
|
8bdc64d45f | ||
|
|
a3e0c9f8f0 | ||
|
|
95b9ac040e | ||
|
|
f823932349 | ||
|
|
fa0a71ac41 | ||
|
|
e149b24c63 | ||
|
|
2ce670fc48 | ||
|
|
6011484167 | ||
|
|
c372189443 | ||
|
|
335ddf2fe9 | ||
|
|
6514919306 | ||
|
|
0e51c7b64a | ||
|
|
28460ece95 | ||
|
|
63d14168a5 | ||
|
|
838e17ffec | ||
|
|
d078f39a51 | ||
|
|
e468d9248c | ||
|
|
e625d40b93 | ||
|
|
bb788dec83 | ||
|
|
611fc7244a | ||
|
|
8dee726b1a | ||
|
|
dba8e32e44 | ||
|
|
e6ab99f324 | ||
|
|
cdf88b5a0c | ||
|
|
3a390eadd2 | ||
|
|
e929799065 | ||
|
|
0c37321362 | ||
|
|
cfec756a6d | ||
|
|
569a9d3d70 | ||
|
|
52dc21a68d | ||
|
|
c1ebaffba9 |
15
RELEASE_NOTES
Normal file
15
RELEASE_NOTES
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
┌────────────────────────────────────┐
|
||||
│ RELEASE NOTES for FFmpeg 4.3 "4:3" │
|
||||
└────────────────────────────────────┘
|
||||
|
||||
The FFmpeg Project proudly presents FFmpeg 4.3 "4:3", about 10
|
||||
months after the release of FFmpeg 4.2.
|
||||
|
||||
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.freenode.net) 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 = 4.3
|
||||
|
||||
# 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
|
||||
|
||||
@@ -317,7 +317,7 @@ list are dropped. You may use the special @code{*} string to match all pages,
|
||||
or @code{subtitle} to match all subtitle pages.
|
||||
Default value is *.
|
||||
@item txt_default_region
|
||||
Set default G0 character set used for decoding, a value between 0 and 80 (see
|
||||
Set default character set used for decoding, a value between 0 and 87 (see
|
||||
ETS 300 706, Section 15, Table 32). Default value is -1, which does not
|
||||
override the libzvbi default. This option is needed for some legacy level 1.0
|
||||
transmissions which cannot signal the proper charset.
|
||||
|
||||
@@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
|
||||
memmove(units + position + 1, units + position,
|
||||
(frag->nb_units - position) * sizeof(*units));
|
||||
} else {
|
||||
units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
|
||||
units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
|
||||
if (!units)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
++frag->nb_units_allocated;
|
||||
frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;
|
||||
|
||||
if (position > 0)
|
||||
memcpy(units, frag->units, position * sizeof(*units));
|
||||
|
||||
@@ -711,10 +711,11 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc)
|
||||
|
||||
#define infer(name, value) do { \
|
||||
if (current->name != (value)) { \
|
||||
av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
|
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, \
|
||||
"%s does not match inferred value: " \
|
||||
"%"PRId64", but should be %"PRId64".\n", \
|
||||
#name, (int64_t)current->name, (int64_t)(value)); \
|
||||
return AVERROR_INVALIDDATA; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -408,10 +408,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
|
||||
|
||||
#define infer(name, value) do { \
|
||||
if (current->name != (value)) { \
|
||||
av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
|
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, \
|
||||
"%s does not match inferred value: " \
|
||||
"%"PRId64", but should be %"PRId64".\n", \
|
||||
#name, (int64_t)current->name, (int64_t)(value)); \
|
||||
return AVERROR_INVALIDDATA; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
|
||||
if (r < 0)
|
||||
return r;
|
||||
pcm = (int16_t *)frame->data[0];
|
||||
for (s = 0; s < duration; s++, ts++) {
|
||||
for (s = 0; s < duration; s++, ts+=(uint64_t)1) {
|
||||
memset(channels, 0, avc->channels * sizeof(*channels));
|
||||
if (ts >= ws->next_ts)
|
||||
wavesynth_enter_intervals(ws, ts);
|
||||
@@ -452,7 +452,7 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
|
||||
for (c = 0; c < avc->channels; c++)
|
||||
*(pcm++) = channels[c] >> 16;
|
||||
}
|
||||
ws->cur_ts += duration;
|
||||
ws->cur_ts += (uint64_t)duration;
|
||||
*rgot_frame = 1;
|
||||
return packet->size;
|
||||
}
|
||||
|
||||
@@ -142,10 +142,14 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
|
||||
int nalu_type;
|
||||
int is_irap, add_extradata, extra_size, prev_size;
|
||||
|
||||
if (bytestream2_get_bytes_left(&gb) < s->length_size) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
for (i = 0; i < s->length_size; i++)
|
||||
nalu_size = (nalu_size << 8) | bytestream2_get_byte(&gb);
|
||||
|
||||
if (nalu_size < 2) {
|
||||
if (nalu_size < 2 || nalu_size > bytestream2_get_bytes_left(&gb)) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -723,7 +723,7 @@ static void decode_deep_rle32(uint8_t *dst, const uint8_t *src, int src_size, in
|
||||
if (opcode >= 0) {
|
||||
int size = opcode + 1;
|
||||
for (i = 0; i < size; i++) {
|
||||
int length = FFMIN(size - i, width);
|
||||
int length = FFMIN(size - i, width - x);
|
||||
if (src_end - src < length * 4)
|
||||
return;
|
||||
memcpy(dst + y*linesize + x * 4, src, length * 4);
|
||||
|
||||
@@ -612,12 +612,19 @@ static int get_rgn(Jpeg2000DecoderContext *s, int n)
|
||||
// Currently compno cannot be greater than 4.
|
||||
// However, future implementation should support compno up to 65536
|
||||
if (compno < s->ncomponents) {
|
||||
if (s->curtileno == -1)
|
||||
s->roi_shift[compno] = bytestream2_get_byte(&s->g);
|
||||
else {
|
||||
int v;
|
||||
if (s->curtileno == -1) {
|
||||
v = bytestream2_get_byte(&s->g);
|
||||
if (v > 30)
|
||||
return AVERROR_PATCHWELCOME;
|
||||
s->roi_shift[compno] = v;
|
||||
} else {
|
||||
if (s->tile[s->curtileno].tp_idx != 0)
|
||||
return AVERROR_INVALIDDATA; // marker occurs only in first tile part of tile
|
||||
s->tile[s->curtileno].comp[compno].roi_shift = bytestream2_get_byte(&s->g);
|
||||
v = bytestream2_get_byte(&s->g);
|
||||
if (v > 30)
|
||||
return AVERROR_PATCHWELCOME;
|
||||
s->tile[s->curtileno].comp[compno].roi_shift = v;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1669,8 +1676,8 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
|
||||
ff_mqc_initdec(&t1->mqc, cblk->data, 0, 1);
|
||||
|
||||
while (passno--) {
|
||||
if (bpno < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "bpno became negative\n");
|
||||
if (bpno < 0 || bpno > 29) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "bpno became invalid\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
switch(pass_t) {
|
||||
|
||||
@@ -797,7 +797,7 @@ static void teletext_flush(AVCodecContext *avctx)
|
||||
#define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
{"txt_page", "page numbers to decode, subtitle for subtitles, * for all", OFFSET(pgno), AV_OPT_TYPE_STRING, {.str = "*"}, 0, 0, SD},
|
||||
{"txt_default_region", "default G0 character set used for decoding", OFFSET(default_region), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 80, SD},
|
||||
{"txt_default_region", "default G0 character set used for decoding", OFFSET(default_region), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 87, SD},
|
||||
{"txt_chop_top", "discards the top teletext line", OFFSET(chop_top), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, SD},
|
||||
{"txt_format", "format of the subtitles (bitmap or text or ass)", OFFSET(format_id), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, SD, "txt_format"},
|
||||
{"bitmap", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, SD, "txt_format"},
|
||||
|
||||
@@ -82,7 +82,7 @@ static inline void loco_update_rice_param(RICEContext *r, int val)
|
||||
|
||||
static inline int loco_get_rice(RICEContext *r)
|
||||
{
|
||||
int v;
|
||||
unsigned v;
|
||||
if (r->run > 0) { /* we have zero run */
|
||||
r->run--;
|
||||
loco_update_rice_param(r, 0);
|
||||
|
||||
@@ -27,7 +27,7 @@ static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2,
|
||||
const int16_t *v3,
|
||||
int order, int mul)
|
||||
{
|
||||
int res = 0;
|
||||
unsigned res = 0;
|
||||
|
||||
do {
|
||||
res += *v1 * *v2++;
|
||||
|
||||
@@ -492,10 +492,10 @@ static int mov_text_init(AVCodecContext *avctx) {
|
||||
return ff_ass_subtitle_header_full(avctx,
|
||||
m->frame_width, m->frame_height,
|
||||
m->d.font, m->d.fontsize,
|
||||
(255 - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
|
||||
(255 - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
|
||||
(255 - m->d.back_alpha) << 24 | RGB_TO_BGR(m->d.back_color),
|
||||
(255 - m->d.back_alpha) << 24 | RGB_TO_BGR(m->d.back_color),
|
||||
(255U - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
|
||||
(255U - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
|
||||
(255U - m->d.back_alpha) << 24 | RGB_TO_BGR(m->d.back_color),
|
||||
(255U - m->d.back_alpha) << 24 | RGB_TO_BGR(m->d.back_color),
|
||||
m->d.bold, m->d.italic, m->d.underline,
|
||||
ASS_DEFAULT_BORDERSTYLE, m->d.alignment);
|
||||
} else
|
||||
|
||||
@@ -221,7 +221,6 @@ end:
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this function can read out of range and crash for corrupt streams.
|
||||
* Changing this would eat up any speed benefits it has.
|
||||
* Do not use "fast" flag if you need the code to be robust.
|
||||
*/
|
||||
@@ -397,7 +396,6 @@ end:
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this function can read out of range and crash for corrupt streams.
|
||||
* Changing this would eat up any speed benefits it has.
|
||||
* Do not use "fast" flag if you need the code to be robust.
|
||||
*/
|
||||
@@ -559,7 +557,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this function can read out of range and crash for corrupt streams.
|
||||
* Changing this would eat up any speed benefits it has.
|
||||
* Do not use "fast" flag if you need the code to be robust.
|
||||
*/
|
||||
|
||||
@@ -610,7 +610,7 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n)
|
||||
dy -= 1 << (shift + a + 1);
|
||||
else
|
||||
dx -= 1 << (shift + a + 1);
|
||||
mb_v = s->sprite_offset[0][n] + dx * s->mb_x * 16 + dy * s->mb_y * 16;
|
||||
mb_v = s->sprite_offset[0][n] + dx * s->mb_x * 16U + dy * s->mb_y * 16U;
|
||||
|
||||
sum = 0;
|
||||
for (y = 0; y < 16; y++) {
|
||||
@@ -3134,6 +3134,7 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
|
||||
MpegEncContext *s = &ctx->m;
|
||||
int width, height;
|
||||
int bits_per_raw_sample;
|
||||
int rgb, chroma_format;
|
||||
|
||||
// random_accessible_vol and video_object_type_indication have already
|
||||
// been read by the caller decode_vol_header()
|
||||
@@ -3141,28 +3142,36 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
|
||||
ctx->shape = get_bits(gb, 2); /* video_object_layer_shape */
|
||||
skip_bits(gb, 4); /* video_object_layer_shape_extension */
|
||||
skip_bits1(gb); /* progressive_sequence */
|
||||
if (ctx->shape != RECT_SHAPE) {
|
||||
avpriv_request_sample(s->avctx, "MPEG-4 Studio profile non rectangular shape");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (ctx->shape != BIN_ONLY_SHAPE) {
|
||||
ctx->rgb = get_bits1(gb); /* rgb_components */
|
||||
s->chroma_format = get_bits(gb, 2); /* chroma_format */
|
||||
if (!s->chroma_format) {
|
||||
rgb = get_bits1(gb); /* rgb_components */
|
||||
chroma_format = get_bits(gb, 2); /* chroma_format */
|
||||
if (!chroma_format || chroma_format == CHROMA_420 || (rgb && chroma_format == CHROMA_422)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
bits_per_raw_sample = get_bits(gb, 4); /* bit_depth */
|
||||
if (bits_per_raw_sample == 10) {
|
||||
if (ctx->rgb) {
|
||||
if (rgb) {
|
||||
s->avctx->pix_fmt = AV_PIX_FMT_GBRP10;
|
||||
}
|
||||
else {
|
||||
s->avctx->pix_fmt = s->chroma_format == CHROMA_422 ? AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV444P10;
|
||||
s->avctx->pix_fmt = chroma_format == CHROMA_422 ? AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV444P10;
|
||||
}
|
||||
}
|
||||
else {
|
||||
avpriv_request_sample(s->avctx, "MPEG-4 Studio profile bit-depth %u", bits_per_raw_sample);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (rgb != ctx->rgb || s->chroma_format != chroma_format)
|
||||
s->context_reinit = 1;
|
||||
s->avctx->bits_per_raw_sample = bits_per_raw_sample;
|
||||
ctx->rgb = rgb;
|
||||
s->chroma_format = chroma_format;
|
||||
}
|
||||
if (ctx->shape == RECT_SHAPE) {
|
||||
check_marker(s->avctx, gb, "before video_object_layer_width");
|
||||
|
||||
@@ -410,6 +410,9 @@ static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame
|
||||
int ret;
|
||||
|
||||
mgb = *gb;
|
||||
if (get_bits_left(gb) < s->mode_size * 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
skip_bits_long(gb, s->mode_size * 8);
|
||||
|
||||
linesize[0] = frame->linesize[0];
|
||||
|
||||
@@ -221,7 +221,7 @@ static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
|
||||
length = 25 - nbits;
|
||||
|
||||
while (i < size) {
|
||||
if (state >> 8 != -3)
|
||||
if (((state >> 8) + 3) & 0xFFFFFFF)
|
||||
value = ff_clz((state >> 8) + 3) ^ 0x1F;
|
||||
else
|
||||
value = -1;
|
||||
|
||||
@@ -310,7 +310,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
|
||||
}
|
||||
|
||||
if (for_user) {
|
||||
dst->delay = src->thread_count - 1;
|
||||
#if FF_API_CODED_FRAME
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
dst->coded_frame = src->coded_frame;
|
||||
@@ -790,6 +789,9 @@ int ff_frame_thread_init(AVCodecContext *avctx)
|
||||
fctx->async_lock = 1;
|
||||
fctx->delaying = 1;
|
||||
|
||||
if (codec->type == AVMEDIA_TYPE_VIDEO)
|
||||
avctx->delay = src->thread_count - 1;
|
||||
|
||||
for (i = 0; i < thread_count; i++) {
|
||||
AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
|
||||
PerThreadContext *p = &fctx->threads[i];
|
||||
@@ -827,6 +829,8 @@ int ff_frame_thread_init(AVCodecContext *avctx)
|
||||
copy->internal->thread_ctx = p;
|
||||
copy->internal->last_pkt_props = &p->avpkt;
|
||||
|
||||
copy->delay = avctx->delay;
|
||||
|
||||
if (codec->priv_data_size) {
|
||||
copy->priv_data = av_mallocz(codec->priv_data_size);
|
||||
if (!copy->priv_data) {
|
||||
|
||||
@@ -117,7 +117,7 @@ static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer
|
||||
static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){
|
||||
const int w= b->width;
|
||||
int y;
|
||||
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
|
||||
const int qlog= av_clip(s->qlog + (int64_t)b->qlog, 0, QROOT*16);
|
||||
int qmul= ff_qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
|
||||
int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
|
||||
int new_index = 0;
|
||||
@@ -224,7 +224,7 @@ static int decode_q_branch(SnowContext *s, int level, int x, int y){
|
||||
|
||||
static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int start_y, int end_y){
|
||||
const int w= b->width;
|
||||
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
|
||||
const int qlog= av_clip(s->qlog + (int64_t)b->qlog, 0, QROOT*16);
|
||||
const int qmul= ff_qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
|
||||
const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
|
||||
int x,y;
|
||||
|
||||
@@ -1625,10 +1625,22 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
s->lambda = 0;
|
||||
}//else keep previous frame's qlog until after motion estimation
|
||||
|
||||
#if FF_API_CODED_FRAME
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
av_frame_unref(avctx->coded_frame);
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
if (s->current_picture->data[0]) {
|
||||
int w = s->avctx->width;
|
||||
int h = s->avctx->height;
|
||||
|
||||
#if FF_API_CODED_FRAME
|
||||
ret = av_frame_make_writable(s->current_picture);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
s->mpvencdsp.draw_edges(s->current_picture->data[0],
|
||||
s->current_picture->linesize[0], w , h ,
|
||||
EDGE_WIDTH , EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM);
|
||||
@@ -1646,7 +1658,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
ff_snow_frame_start(s);
|
||||
#if FF_API_CODED_FRAME
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
av_frame_unref(avctx->coded_frame);
|
||||
ret = av_frame_ref(avctx->coded_frame, s->current_picture);
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
@@ -140,7 +140,8 @@ static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_si
|
||||
if(get_rac(c, state+0))
|
||||
return 0;
|
||||
else{
|
||||
int i, e, a;
|
||||
int i, e;
|
||||
unsigned a;
|
||||
e= 0;
|
||||
while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
|
||||
e++;
|
||||
@@ -474,7 +475,7 @@ static int predictor_calc_error(int *k, int *state, int order, int error)
|
||||
for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--)
|
||||
{
|
||||
int k_value = *k_ptr, state_value = *state_ptr;
|
||||
x -= shift_down(k_value * state_value, LATTICE_SHIFT);
|
||||
x -= shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT);
|
||||
state_ptr[1] = state_value + shift_down(k_value * (unsigned)x, LATTICE_SHIFT);
|
||||
}
|
||||
#else
|
||||
@@ -1044,7 +1045,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
|
||||
x += s->channels;
|
||||
}
|
||||
|
||||
s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, s->coded_samples[ch][i] * quant);
|
||||
s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, s->coded_samples[ch][i] * (unsigned)quant);
|
||||
x += s->channels;
|
||||
}
|
||||
|
||||
|
||||
@@ -679,6 +679,9 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_dng && stride == 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for (line = 0; line < lines; line++) {
|
||||
if (src - ssrc > size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
|
||||
|
||||
@@ -184,7 +184,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
unsigned int channel_mask;
|
||||
int i, log2_max_num_subframes;
|
||||
|
||||
if (avctx->block_align <= 0) {
|
||||
if (avctx->block_align <= 0 || avctx->block_align > (1<<21)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "block_align is not set or invalid\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
@@ -218,6 +218,7 @@ static int fourxm_read_header(AVFormatContext *s)
|
||||
fourxm->track_count = 0;
|
||||
fourxm->tracks = NULL;
|
||||
fourxm->fps = (AVRational){1,1};
|
||||
fourxm->video_stream_index = -1;
|
||||
|
||||
/* skip the first 3 32-bit numbers */
|
||||
avio_skip(pb, 12);
|
||||
@@ -326,6 +327,8 @@ static int fourxm_read_packet(AVFormatContext *s,
|
||||
* and size */
|
||||
if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (fourxm->video_stream_index < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if ((ret = av_new_packet(pkt, size + 8)) < 0)
|
||||
return ret;
|
||||
pkt->stream_index = fourxm->video_stream_index;
|
||||
|
||||
@@ -83,6 +83,8 @@ typedef struct APEContext {
|
||||
uint8_t *bittable;
|
||||
} APEContext;
|
||||
|
||||
static int ape_read_close(AVFormatContext * s);
|
||||
|
||||
static int ape_probe(const AVProbeData * p)
|
||||
{
|
||||
int version = AV_RL16(p->buf+4);
|
||||
@@ -281,14 +283,18 @@ static int ape_read_header(AVFormatContext * s)
|
||||
|
||||
if (ape->seektablelength > 0) {
|
||||
ape->seektable = av_mallocz(ape->seektablelength);
|
||||
if (!ape->seektable)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!ape->seektable) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
for (i = 0; i < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; i++)
|
||||
ape->seektable[i] = avio_rl32(pb);
|
||||
if (ape->fileversion < 3810) {
|
||||
ape->bittable = av_mallocz(ape->totalframes);
|
||||
if (!ape->bittable)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!ape->bittable) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
|
||||
ape->bittable[i] = avio_r8(pb);
|
||||
}
|
||||
@@ -341,8 +347,10 @@ static int ape_read_header(AVFormatContext * s)
|
||||
|
||||
/* now we are ready: build format streams */
|
||||
st = avformat_new_stream(s, NULL);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!st) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
|
||||
|
||||
@@ -359,7 +367,7 @@ static int ape_read_header(AVFormatContext * s)
|
||||
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
|
||||
|
||||
if ((ret = ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE)) < 0)
|
||||
return ret;
|
||||
goto fail;
|
||||
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
|
||||
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
|
||||
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
|
||||
@@ -378,6 +386,10 @@ static int ape_read_header(AVFormatContext * s)
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
ape_read_close(s);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
|
||||
@@ -81,11 +81,11 @@ static int aqt_read_header(AVFormatContext *s)
|
||||
if (!new_event) {
|
||||
sub = ff_subtitles_queue_insert(&aqt->q, "\n", 1, 1);
|
||||
if (!sub)
|
||||
return AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
sub = ff_subtitles_queue_insert(&aqt->q, line, strlen(line), !new_event);
|
||||
if (!sub)
|
||||
return AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
if (new_event) {
|
||||
sub->pts = frame;
|
||||
sub->duration = -1;
|
||||
@@ -97,6 +97,9 @@ static int aqt_read_header(AVFormatContext *s)
|
||||
|
||||
ff_subtitles_queue_finalize(s, &aqt->q);
|
||||
return 0;
|
||||
fail:
|
||||
ff_subtitles_queue_clean(&aqt->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static int aqt_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
|
||||
@@ -160,6 +160,8 @@ static int ass_read_header(AVFormatContext *s)
|
||||
ff_subtitles_queue_finalize(s, &ass->q);
|
||||
|
||||
end:
|
||||
if (res < 0)
|
||||
ass_read_close(s);
|
||||
av_bprint_finalize(&header, NULL);
|
||||
av_bprint_finalize(&line, NULL);
|
||||
av_bprint_finalize(&rline, NULL);
|
||||
|
||||
@@ -311,6 +311,8 @@ static struct playlist *new_playlist(HLSContext *c, const char *url,
|
||||
return NULL;
|
||||
reset_packet(&pls->pkt);
|
||||
ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
|
||||
if (!pls->url[0])
|
||||
return NULL;
|
||||
pls->seek_timestamp = AV_NOPTS_VALUE;
|
||||
|
||||
pls->is_id3_timestamped = -1;
|
||||
@@ -416,6 +418,10 @@ static struct segment *new_init_section(struct playlist *pls,
|
||||
ptr = info->uri;
|
||||
} else {
|
||||
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri);
|
||||
if (!tmp_str[0]) {
|
||||
av_free(sec);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
sec->url = av_strdup(ptr);
|
||||
if (!sec->url) {
|
||||
@@ -841,6 +847,11 @@ static int parse_playlist(HLSContext *c, const char *url,
|
||||
|
||||
if (key_type != KEY_NONE) {
|
||||
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
|
||||
if (!tmp_str[0]) {
|
||||
av_free(cur_init_section);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
cur_init_section->key = av_strdup(tmp_str);
|
||||
if (!cur_init_section->key) {
|
||||
av_free(cur_init_section);
|
||||
@@ -883,8 +894,6 @@ static int parse_playlist(HLSContext *c, const char *url,
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
seg->duration = duration;
|
||||
seg->key_type = key_type;
|
||||
if (has_iv) {
|
||||
memcpy(seg->iv, iv, sizeof(iv));
|
||||
} else {
|
||||
@@ -895,6 +904,11 @@ static int parse_playlist(HLSContext *c, const char *url,
|
||||
|
||||
if (key_type != KEY_NONE) {
|
||||
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
|
||||
if (!tmp_str[0]) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
av_free(seg);
|
||||
goto fail;
|
||||
}
|
||||
seg->key = av_strdup(tmp_str);
|
||||
if (!seg->key) {
|
||||
av_free(seg);
|
||||
@@ -906,6 +920,13 @@ static int parse_playlist(HLSContext *c, const char *url,
|
||||
}
|
||||
|
||||
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line);
|
||||
if (!tmp_str[0]) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
if (seg->key)
|
||||
av_free(seg->key);
|
||||
av_free(seg);
|
||||
goto fail;
|
||||
}
|
||||
seg->url = av_strdup(tmp_str);
|
||||
if (!seg->url) {
|
||||
av_free(seg->key);
|
||||
@@ -914,6 +935,13 @@ static int parse_playlist(HLSContext *c, const char *url,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (duration < 0.001 * AV_TIME_BASE) {
|
||||
av_log(c->ctx, AV_LOG_WARNING, "Cannot get correct #EXTINF value of segment %s,"
|
||||
" set to default value to 1ms.\n", seg->url);
|
||||
duration = 0.001 * AV_TIME_BASE;
|
||||
}
|
||||
seg->duration = duration;
|
||||
seg->key_type = key_type;
|
||||
dynarray_add(&pls->segments, &pls->n_segments, seg);
|
||||
is_segment = 0;
|
||||
|
||||
|
||||
@@ -1993,7 +1993,7 @@ static int parse_variant_stream_mapstring(AVFormatContext *s)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
num = strtoll(val, &end, 0);
|
||||
num = strtoll(val, &end, 10);
|
||||
if (!av_isdigit(*val) || *end != '\0') {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid stream number: '%s'\n", val);
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
@@ -188,8 +188,10 @@ static int jacosub_read_header(AVFormatContext *s)
|
||||
AVPacket *sub;
|
||||
|
||||
sub = ff_subtitles_queue_insert(&jacosub->q, line, len, merge_line);
|
||||
if (!sub)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!sub) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
sub->pos = pos;
|
||||
merge_line = len > 1 && !strcmp(&line[len - 2], "\\\n");
|
||||
continue;
|
||||
|
||||
@@ -202,6 +202,7 @@ static int lrc_read_header(AVFormatContext *s)
|
||||
sub = ff_subtitles_queue_insert(&lrc->q, line.str + ts_strlength,
|
||||
line.len - ts_strlength, 0);
|
||||
if(!sub) {
|
||||
ff_subtitles_queue_clean(&lrc->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sub->pos = pos;
|
||||
|
||||
@@ -2938,9 +2938,8 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
|
||||
av_init_packet(pkt);
|
||||
pkt->buf = av_buffer_ref(attachments[j].bin.buf);
|
||||
if (!pkt->buf)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->buf = attachments[j].bin.buf;
|
||||
attachments[j].bin.buf = NULL;
|
||||
pkt->data = attachments[j].bin.data;
|
||||
pkt->size = attachments[j].bin.size;
|
||||
pkt->stream_index = st->index;
|
||||
@@ -3569,7 +3568,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
|
||||
|
||||
if (st->discard >= AVDISCARD_ALL)
|
||||
return res;
|
||||
av_assert1(block_duration != AV_NOPTS_VALUE);
|
||||
if (block_duration > INT64_MAX)
|
||||
block_duration = INT64_MAX;
|
||||
|
||||
block_time = sign_extend(AV_RB16(data), 16);
|
||||
data += 2;
|
||||
@@ -4180,15 +4180,18 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_ERROR, "Failed to read file headers\n");
|
||||
return -1;
|
||||
}
|
||||
if (!s->nb_streams) {
|
||||
matroska_read_close(s);
|
||||
av_log(s, AV_LOG_ERROR, "No streams found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (!matroska->tracks.nb_elem || !s->nb_streams) {
|
||||
av_log(s, AV_LOG_ERROR, "No track found\n");
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!matroska->is_live) {
|
||||
buf = av_asprintf("%g", matroska->duration);
|
||||
if (!buf) return AVERROR(ENOMEM);
|
||||
if (!buf) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
av_dict_set(&s->streams[0]->metadata, DURATION,
|
||||
buf, AV_DICT_DONT_STRDUP_VAL);
|
||||
|
||||
@@ -4211,7 +4214,7 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
|
||||
ret = webm_dash_manifest_cues(s, init_range);
|
||||
if (ret < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Error parsing Cues\n");
|
||||
return ret;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4221,6 +4224,9 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
|
||||
matroska->bandwidth, 0);
|
||||
}
|
||||
return 0;
|
||||
fail:
|
||||
matroska_read_close(s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int webm_dash_manifest_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
|
||||
@@ -2118,17 +2118,19 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac
|
||||
mkv_track *track = &mkv->tracks[pkt->stream_index];
|
||||
ebml_master blockgroup;
|
||||
int id_size, settings_size, size;
|
||||
uint8_t *id, *settings;
|
||||
const char *id, *settings;
|
||||
int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
|
||||
const int flags = 0;
|
||||
|
||||
id_size = 0;
|
||||
id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,
|
||||
&id_size);
|
||||
id = id ? id : "";
|
||||
|
||||
settings_size = 0;
|
||||
settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS,
|
||||
&settings_size);
|
||||
settings = settings ? settings : "";
|
||||
|
||||
size = id_size + 1 + settings_size + 1 + pkt->size;
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ static int microdvd_read_header(AVFormatContext *s)
|
||||
AVRational pts_info = (AVRational){ 2997, 125 }; /* default: 23.976 fps */
|
||||
MicroDVDContext *microdvd = s->priv_data;
|
||||
AVStream *st = avformat_new_stream(s, NULL);
|
||||
int i = 0;
|
||||
int i = 0, ret;
|
||||
char line_buf[MAX_LINESIZE];
|
||||
int has_real_fps = 0;
|
||||
|
||||
@@ -117,10 +117,10 @@ static int microdvd_read_header(AVFormatContext *s)
|
||||
continue;
|
||||
}
|
||||
if (!st->codecpar->extradata && sscanf(line, "{DEFAULT}{}%c", &c) == 1) {
|
||||
int ret, size = strlen(line + 11);
|
||||
int size = strlen(line + 11);
|
||||
ret = ff_alloc_extradata(st->codecpar, size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto fail;
|
||||
memcpy(st->codecpar->extradata, line + 11, size);
|
||||
continue;
|
||||
}
|
||||
@@ -138,8 +138,10 @@ static int microdvd_read_header(AVFormatContext *s)
|
||||
if (!*p)
|
||||
continue;
|
||||
sub = ff_subtitles_queue_insert(µdvd->q, p, strlen(p), 0);
|
||||
if (!sub)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!sub) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
sub->pos = pos;
|
||||
sub->pts = get_pts(line);
|
||||
sub->duration = get_duration(line);
|
||||
@@ -156,6 +158,9 @@ static int microdvd_read_header(AVFormatContext *s)
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||
st->codecpar->codec_id = AV_CODEC_ID_MICRODVD;
|
||||
return 0;
|
||||
fail:
|
||||
ff_subtitles_queue_clean(µdvd->q);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int microdvd_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
|
||||
@@ -2342,7 +2342,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
uint32_t format = AV_RB32(st->codecpar->extradata + 22);
|
||||
if (format == AV_RB32("name") && (int64_t)size >= (int64_t)len + 18) {
|
||||
uint16_t str_size = AV_RB16(st->codecpar->extradata + 26); /* string length */
|
||||
if (str_size > 0 && size >= (int)str_size + 26) {
|
||||
if (str_size > 0 && size >= (int)str_size + 30) {
|
||||
char *reel_name = av_malloc(str_size + 1);
|
||||
if (!reel_name)
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -4434,6 +4434,9 @@ static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
} else
|
||||
break;
|
||||
|
||||
if (*p)
|
||||
break;
|
||||
|
||||
*p = av_malloc(len + 1);
|
||||
if (!*p) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
@@ -7580,14 +7583,13 @@ static int mov_read_header(AVFormatContext *s)
|
||||
avio_seek(pb, 0, SEEK_SET);
|
||||
if ((err = mov_read_default(mov, pb, atom)) < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "error reading header\n");
|
||||
mov_read_close(s);
|
||||
return err;
|
||||
goto fail;
|
||||
}
|
||||
} while ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !mov->found_moov && !mov->moov_retry++);
|
||||
if (!mov->found_moov) {
|
||||
av_log(s, AV_LOG_ERROR, "moov atom not found\n");
|
||||
mov_read_close(s);
|
||||
return AVERROR_INVALIDDATA;
|
||||
err = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb));
|
||||
|
||||
@@ -7640,7 +7642,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
}
|
||||
if (st->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
|
||||
if ((err = mov_rewrite_dvd_sub_extradata(st)) < 0)
|
||||
return err;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (mov->handbrake_version &&
|
||||
@@ -7660,8 +7662,8 @@ static int mov_read_header(AVFormatContext *s)
|
||||
if (sc->data_size > INT64_MAX / sc->time_scale / 8) {
|
||||
av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n",
|
||||
sc->data_size, sc->time_scale);
|
||||
mov_read_close(s);
|
||||
return AVERROR_INVALIDDATA;
|
||||
err = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
|
||||
}
|
||||
@@ -7676,8 +7678,8 @@ static int mov_read_header(AVFormatContext *s)
|
||||
if (sc->data_size > INT64_MAX / sc->time_scale / 8) {
|
||||
av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n",
|
||||
sc->data_size, sc->time_scale);
|
||||
mov_read_close(s);
|
||||
return AVERROR_INVALIDDATA;
|
||||
err = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale /
|
||||
sc->duration_for_fps;
|
||||
@@ -7701,8 +7703,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
err = ff_replaygain_export(st, s->metadata);
|
||||
if (err < 0) {
|
||||
mov_read_close(s);
|
||||
return err;
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
@@ -7710,7 +7711,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
err = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix,
|
||||
sizeof(int32_t) * 9);
|
||||
if (err < 0)
|
||||
return err;
|
||||
goto fail;
|
||||
|
||||
sc->display_matrix = NULL;
|
||||
}
|
||||
@@ -7719,7 +7720,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
(uint8_t *)sc->stereo3d,
|
||||
sizeof(*sc->stereo3d));
|
||||
if (err < 0)
|
||||
return err;
|
||||
goto fail;
|
||||
|
||||
sc->stereo3d = NULL;
|
||||
}
|
||||
@@ -7728,7 +7729,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
(uint8_t *)sc->spherical,
|
||||
sc->spherical_size);
|
||||
if (err < 0)
|
||||
return err;
|
||||
goto fail;
|
||||
|
||||
sc->spherical = NULL;
|
||||
}
|
||||
@@ -7737,7 +7738,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
(uint8_t *)sc->mastering,
|
||||
sizeof(*sc->mastering));
|
||||
if (err < 0)
|
||||
return err;
|
||||
goto fail;
|
||||
|
||||
sc->mastering = NULL;
|
||||
}
|
||||
@@ -7746,7 +7747,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
(uint8_t *)sc->coll,
|
||||
sc->coll_size);
|
||||
if (err < 0)
|
||||
return err;
|
||||
goto fail;
|
||||
|
||||
sc->coll = NULL;
|
||||
}
|
||||
@@ -7760,6 +7761,9 @@ static int mov_read_header(AVFormatContext *s)
|
||||
mov->frag_index.item[i].headers_read = 1;
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
mov_read_close(s);
|
||||
return err;
|
||||
}
|
||||
|
||||
static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
|
||||
@@ -7776,7 +7780,7 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
|
||||
av_log(s, AV_LOG_TRACE, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts);
|
||||
if (!sample || (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && current_sample->pos < sample->pos) ||
|
||||
((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
|
||||
((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb &&
|
||||
((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && dts != AV_NOPTS_VALUE &&
|
||||
((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||
|
||||
(FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) {
|
||||
sample = current_sample;
|
||||
|
||||
@@ -55,7 +55,7 @@ static int mpl2_probe(const AVProbeData *p)
|
||||
return AVPROBE_SCORE_MAX;
|
||||
}
|
||||
|
||||
static int read_ts(char **line, int64_t *pts_start, int *duration)
|
||||
static int read_ts(char **line, int64_t *pts_start, int64_t *duration)
|
||||
{
|
||||
char c;
|
||||
int len;
|
||||
@@ -69,7 +69,10 @@ static int read_ts(char **line, int64_t *pts_start, int *duration)
|
||||
}
|
||||
if (sscanf(*line, "[%"SCNd64"][%"SCNd64"]%c%n",
|
||||
pts_start, &end, &c, &len) >= 3) {
|
||||
*duration = end - *pts_start;
|
||||
if (end < *pts_start || end - (uint64_t)*pts_start > INT64_MAX) {
|
||||
*duration = -1;
|
||||
} else
|
||||
*duration = end - *pts_start;
|
||||
*line += len - 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -97,7 +100,7 @@ static int mpl2_read_header(AVFormatContext *s)
|
||||
const int64_t pos = avio_tell(s->pb);
|
||||
int len = ff_get_line(s->pb, line, sizeof(line));
|
||||
int64_t pts_start;
|
||||
int duration;
|
||||
int64_t duration;
|
||||
|
||||
if (!len)
|
||||
break;
|
||||
@@ -108,8 +111,10 @@ static int mpl2_read_header(AVFormatContext *s)
|
||||
AVPacket *sub;
|
||||
|
||||
sub = ff_subtitles_queue_insert(&mpl2->q, p, strlen(p), 0);
|
||||
if (!sub)
|
||||
if (!sub) {
|
||||
ff_subtitles_queue_clean(&mpl2->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sub->pos = pos;
|
||||
sub->pts = pts_start;
|
||||
sub->duration = duration;
|
||||
|
||||
@@ -154,8 +154,10 @@ static int mpsub_read_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
st = avformat_new_stream(s, NULL);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!st) {
|
||||
res = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num);
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
|
||||
|
||||
@@ -867,6 +867,7 @@ static inline int mxf_read_utf16_string(AVIOContext *pb, int size, char** str, i
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
buf_size = size + size / 2 + 1;
|
||||
av_free(*str);
|
||||
*str = av_malloc(buf_size);
|
||||
if (!*str)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -226,9 +226,10 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* We only have a single stream anyway, so if there's a new stream with
|
||||
* a different codec just replace it */
|
||||
os = &ogg->streams[0];
|
||||
if (os->codec != codec)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
os->serial = serial;
|
||||
os->codec = codec;
|
||||
os->serial = serial;
|
||||
|
||||
@@ -79,6 +79,13 @@ typedef struct OMAContext {
|
||||
int (*read_packet)(AVFormatContext *s, AVPacket *pkt);
|
||||
} OMAContext;
|
||||
|
||||
static int oma_read_close(AVFormatContext *s)
|
||||
{
|
||||
OMAContext *oc = s->priv_data;
|
||||
av_freep(&oc->av_des);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hex_log(AVFormatContext *s, int level,
|
||||
const char *name, const uint8_t *value, int len)
|
||||
{
|
||||
@@ -402,11 +409,14 @@ static int oma_read_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
|
||||
if (ret < EA3_HEADER_SIZE)
|
||||
if (ret < EA3_HEADER_SIZE) {
|
||||
ff_id3v2_free_extra_meta(&extra_meta);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}), 3) ||
|
||||
buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
|
||||
ff_id3v2_free_extra_meta(&extra_meta);
|
||||
av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -425,8 +435,10 @@ static int oma_read_header(AVFormatContext *s)
|
||||
codec_params = AV_RB24(&buf[33]);
|
||||
|
||||
st = avformat_new_stream(s, NULL);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!st) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
st->start_time = 0;
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
@@ -441,7 +453,8 @@ static int oma_read_header(AVFormatContext *s)
|
||||
samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
|
||||
if (!samplerate) {
|
||||
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
if (samplerate != 44100)
|
||||
avpriv_request_sample(s, "Sample rate %d", samplerate);
|
||||
@@ -459,7 +472,7 @@ static int oma_read_header(AVFormatContext *s)
|
||||
/* fake the ATRAC3 extradata
|
||||
* (wav format, makes stream copy to wav work) */
|
||||
if ((ret = ff_alloc_extradata(st->codecpar, 14)) < 0)
|
||||
return ret;
|
||||
goto fail;
|
||||
|
||||
edata = st->codecpar->extradata;
|
||||
AV_WL16(&edata[0], 1); // always 1
|
||||
@@ -476,7 +489,8 @@ static int oma_read_header(AVFormatContext *s)
|
||||
if (!channel_id) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id);
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
st->codecpar->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1];
|
||||
st->codecpar->channels = ff_oma_chid_to_num_channels[channel_id - 1];
|
||||
@@ -484,7 +498,8 @@ static int oma_read_header(AVFormatContext *s)
|
||||
samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
|
||||
if (!samplerate) {
|
||||
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
st->codecpar->sample_rate = samplerate;
|
||||
st->codecpar->bit_rate = samplerate * framesize / (2048 / 8);
|
||||
@@ -524,12 +539,16 @@ static int oma_read_header(AVFormatContext *s)
|
||||
break;
|
||||
default:
|
||||
av_log(s, AV_LOG_ERROR, "Unsupported codec %d!\n", buf[32]);
|
||||
return AVERROR(ENOSYS);
|
||||
ret = AVERROR(ENOSYS);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
st->codecpar->block_align = framesize;
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
oma_read_close(s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
@@ -591,13 +610,6 @@ wipe:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int oma_read_close(AVFormatContext *s)
|
||||
{
|
||||
OMAContext *oc = s->priv_data;
|
||||
av_free(oc->av_des);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVInputFormat ff_oma_demuxer = {
|
||||
.name = "oma",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Sony OpenMG audio"),
|
||||
|
||||
@@ -94,8 +94,10 @@ static int pjs_read_header(AVFormatContext *s)
|
||||
|
||||
p[strcspn(p, "\"")] = 0;
|
||||
sub = ff_subtitles_queue_insert(&pjs->q, p, strlen(p), 0);
|
||||
if (!sub)
|
||||
if (!sub) {
|
||||
ff_subtitles_queue_clean(&pjs->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sub->pos = pos;
|
||||
sub->pts = pts_start;
|
||||
sub->duration = duration;
|
||||
|
||||
@@ -387,7 +387,7 @@ static int prompeg_write(URLContext *h, const uint8_t *buf, int size) {
|
||||
PrompegFec *fec_tmp;
|
||||
uint8_t *bitstring = NULL;
|
||||
int col_idx, col_out_idx, row_idx;
|
||||
int ret, written = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (s->init && ((ret = prompeg_init(h, buf, size)) < 0))
|
||||
goto end;
|
||||
@@ -403,7 +403,6 @@ static int prompeg_write(URLContext *h, const uint8_t *buf, int size) {
|
||||
if (!s->first || s->packet_idx > 0) {
|
||||
if ((ret = prompeg_write_fec(h, s->fec_row, PROMPEG_FEC_ROW)) < 0)
|
||||
goto end;
|
||||
written += ret;
|
||||
}
|
||||
memcpy(s->fec_row->bitstring, bitstring, s->bitstring_size);
|
||||
s->fec_row->sn = AV_RB16(buf + 2);
|
||||
@@ -434,7 +433,6 @@ static int prompeg_write(URLContext *h, const uint8_t *buf, int size) {
|
||||
col_out_idx = s->packet_idx / s->d;
|
||||
if ((ret = prompeg_write_fec(h, s->fec_col[col_out_idx], PROMPEG_FEC_COL)) < 0)
|
||||
goto end;
|
||||
written += ret;
|
||||
}
|
||||
|
||||
if (++s->packet_idx >= s->packet_idx_max) {
|
||||
@@ -443,7 +441,7 @@ static int prompeg_write(URLContext *h, const uint8_t *buf, int size) {
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
ret = written;
|
||||
ret = size;
|
||||
|
||||
end:
|
||||
av_free(bitstring);
|
||||
|
||||
@@ -108,6 +108,8 @@ static int sami_read_header(AVFormatContext *s)
|
||||
ff_subtitles_queue_finalize(s, &sami->q);
|
||||
|
||||
end:
|
||||
if (res < 0)
|
||||
ff_subtitles_queue_clean(&sami->q);
|
||||
av_bprint_finalize(&buf, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ try_again:
|
||||
|
||||
sub = ff_subtitles_queue_insert(&scc->q, out, i, 0);
|
||||
if (!sub)
|
||||
return AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
|
||||
sub->pos = current_pos;
|
||||
sub->pts = ts_start;
|
||||
@@ -155,6 +155,9 @@ try_again:
|
||||
ff_subtitles_queue_finalize(s, &scc->q);
|
||||
|
||||
return ret;
|
||||
fail:
|
||||
ff_subtitles_queue_clean(&scc->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static int scc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
|
||||
@@ -207,6 +207,8 @@ static int srt_read_header(AVFormatContext *s)
|
||||
ff_subtitles_queue_finalize(s, &srt->q);
|
||||
|
||||
end:
|
||||
if (res < 0)
|
||||
ff_subtitles_queue_clean(&srt->q);
|
||||
av_bprint_finalize(&buf, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -97,8 +97,10 @@ static int stl_read_header(AVFormatContext *s)
|
||||
if (pts_start != AV_NOPTS_VALUE) {
|
||||
AVPacket *sub;
|
||||
sub = ff_subtitles_queue_insert(&stl->q, p, strlen(p), 0);
|
||||
if (!sub)
|
||||
if (!sub) {
|
||||
ff_subtitles_queue_clean(&stl->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sub->pos = pos;
|
||||
sub->pts = pts_start;
|
||||
sub->duration = duration;
|
||||
|
||||
@@ -77,8 +77,10 @@ static int subviewer1_read_header(AVFormatContext *s)
|
||||
sub->duration = pts_start - sub->pts;
|
||||
} else {
|
||||
sub = ff_subtitles_queue_insert(&subviewer1->q, line, len, 0);
|
||||
if (!sub)
|
||||
if (!sub) {
|
||||
ff_subtitles_queue_clean(&subviewer1->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sub->pos = pos;
|
||||
sub->pts = pts_start;
|
||||
sub->duration = -1;
|
||||
|
||||
@@ -172,6 +172,8 @@ static int subviewer_read_header(AVFormatContext *s)
|
||||
ff_subtitles_queue_finalize(s, &subviewer->q);
|
||||
|
||||
end:
|
||||
if (res < 0)
|
||||
ff_subtitles_queue_clean(&subviewer->q);
|
||||
av_bprint_finalize(&header, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -275,10 +275,13 @@ static int parse_file(AVIOContext *pb, FFDemuxSubtitlesQueue *subs)
|
||||
static av_cold int tedcaptions_read_header(AVFormatContext *avf)
|
||||
{
|
||||
TEDCaptionsDemuxer *tc = avf->priv_data;
|
||||
AVStream *st;
|
||||
AVStream *st = avformat_new_stream(avf, NULL);
|
||||
int ret, i;
|
||||
AVPacket *last;
|
||||
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ret = parse_file(avf->pb, &tc->subs);
|
||||
if (ret < 0) {
|
||||
if (ret == AVERROR_INVALIDDATA)
|
||||
@@ -292,9 +295,6 @@ static av_cold int tedcaptions_read_header(AVFormatContext *avf)
|
||||
tc->subs.subs[i].pts += tc->start_time;
|
||||
|
||||
last = &tc->subs.subs[tc->subs.nb_subs - 1];
|
||||
st = avformat_new_stream(avf, NULL);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
|
||||
avpriv_set_pts_info(st, 64, 1, 1000);
|
||||
|
||||
@@ -75,6 +75,8 @@ static int thp_read_header(AVFormatContext *s)
|
||||
avio_rb32(pb); /* Max samples. */
|
||||
|
||||
thp->fps = av_d2q(av_int2float(avio_rb32(pb)), INT_MAX);
|
||||
if (thp->fps.den <= 0 || thp->fps.num < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
thp->framecnt = avio_rb32(pb);
|
||||
thp->first_framesz = avio_rb32(pb);
|
||||
pb->maxsize = avio_rb32(pb);
|
||||
|
||||
@@ -90,6 +90,8 @@ static void trim_double_dot_url(char *buf, const char *rel, int size)
|
||||
if (p && (sep = strstr(p, "://"))) {
|
||||
sep += 3;
|
||||
root = strchr(sep, '/');
|
||||
if (!root)
|
||||
return;
|
||||
}
|
||||
|
||||
/* set new current position if the root node is changed */
|
||||
@@ -150,6 +152,7 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
|
||||
}
|
||||
/* If rel actually is an absolute url, just copy it */
|
||||
if (!base || strstr(rel, "://") || rel[0] == '/') {
|
||||
memset(buf, 0, size);
|
||||
trim_double_dot_url(buf, rel, size);
|
||||
return;
|
||||
}
|
||||
@@ -177,6 +180,8 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
|
||||
if (sep) {
|
||||
sep += 3;
|
||||
root = strchr(sep, '/');
|
||||
if (!root)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,8 +83,10 @@ static int vplayer_read_header(AVFormatContext *s)
|
||||
AVPacket *sub;
|
||||
|
||||
sub = ff_subtitles_queue_insert(&vplayer->q, p, strlen(p), 0);
|
||||
if (!sub)
|
||||
if (!sub) {
|
||||
ff_subtitles_queue_clean(&vplayer->q);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sub->pos = pos;
|
||||
sub->pts = pts_start;
|
||||
sub->duration = -1;
|
||||
|
||||
@@ -164,6 +164,8 @@ static int webvtt_read_header(AVFormatContext *s)
|
||||
ff_subtitles_queue_finalize(s, &webvtt->q);
|
||||
|
||||
end:
|
||||
if (res < 0)
|
||||
ff_subtitles_queue_clean(&webvtt->q);
|
||||
av_bprint_finalize(&cue, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user