Compare commits
121 Commits
n3.3.8
...
release/3.3
| Author | SHA1 | Date | |
|---|---|---|---|
| af8d5aab74 | |||
| eb89291877 | |||
| 25a0887c5a | |||
| e5655c0444 | |||
| 0b4a122a5a | |||
| d4f2de5151 | |||
| 32c81dffb0 | |||
| 3c891c3613 | |||
| 94d7fbe373 | |||
| 2c5943a384 | |||
| 3eafbebe11 | |||
| 2b177a46d2 | |||
| f4bcf5742e | |||
| 594dd57af4 | |||
| 788a580620 | |||
| fbaa2dce42 | |||
| 5f288e1b29 | |||
| 8bac2df94a | |||
| 9b84d1d505 | |||
| 7c50575dcf | |||
| a828461303 | |||
| 5808413509 | |||
| d8c5124ad9 | |||
| f8d1b5d769 | |||
| 1cf9ba634e | |||
| 49196e704c | |||
| 8120d1ddcf | |||
| ba1f99c86a | |||
| c9b6385c16 | |||
| f26395604c | |||
| c253f384dc | |||
| ed1f68ccfe | |||
| 1b99059359 | |||
| e95ebaa332 | |||
| 1a01d3cbb8 | |||
| 80b4dd41ff | |||
| 950b32a2e8 | |||
| 19b1f676f6 | |||
| da59fe3eea | |||
| b5e9226dad | |||
| c6ee2f7c90 | |||
| b9b845e98a | |||
| 7b80a7e498 | |||
| f17200f600 | |||
| 397705d4c1 | |||
| 445fee99b8 | |||
| 3f165b3e63 | |||
| a92b9ed7e3 | |||
| 590a168cf9 | |||
| 4639e4743f | |||
| 98efb7afc9 | |||
| ff1a79d7f3 | |||
| 3f4195d9ef | |||
| ac6fd4546a | |||
| 013e49ab52 | |||
| 4c7f9a32f9 | |||
| c103c203dd | |||
| 8c9132a88e | |||
| e40aff3fdb | |||
| 3a4be74dcd | |||
| d04829a36b | |||
| b6f31b41cc | |||
| 706ae61cf3 | |||
| 364a80ecb9 | |||
| 1a577c59d0 | |||
| 174ce949d7 | |||
| c13febd843 | |||
| 9d3509f401 | |||
| 884ecede17 | |||
| 3d5762380d | |||
| 9cba90e5ef | |||
| 14778d3fda | |||
| 3c4a874388 | |||
| 2661025679 | |||
| 14c8795361 | |||
| ecbf42e13a | |||
| 6fe9f36dd9 | |||
| 72e1c43d6d | |||
| 2405af5081 | |||
| 98444e0222 | |||
| 947f7af048 | |||
| 65710b7e6c | |||
| caddb7890a | |||
| a1f4fe165a | |||
| 1e59d05e48 | |||
| a9ce7cfc59 | |||
| 6177ed2a9b | |||
| 43a80efee6 | |||
| 7fb45ccf4e | |||
| bf4026fcbe | |||
| 3c3b437d79 | |||
| 46875255bc | |||
| fa5498cb4d | |||
| 5c91bb1881 | |||
| 78a1db00c4 | |||
| 1acec9bbf5 | |||
| 7266a6d23c | |||
| 66331499a7 | |||
| 347c50b0d4 | |||
| dc8ec1a5bc | |||
| b80d7d4a09 | |||
| 24add16a32 | |||
| 44ebea8657 | |||
| 907699d120 | |||
| 298ca73ab1 | |||
| d16d851238 | |||
| 488c246bf5 | |||
| 0ea1b62b9a | |||
| 0678985c14 | |||
| 0026d00742 | |||
| e2d052d5c8 | |||
| 1e1c02c51b | |||
| c1a3212d45 | |||
| c07d568603 | |||
| ee5b42ce2f | |||
| d5c48e8536 | |||
| 922a29142e | |||
| 31262860cc | |||
| ea160f0213 | |||
| 5c98f8d80a | |||
| 660e4c0c96 |
@@ -1,6 +1,58 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 3.3.9:
|
||||
- avcodec/pngdec: Check compression method
|
||||
- fftools/ffmpeg: Repair reinit_filter feature
|
||||
- avcodec/shorten: Fix integer overflow with offset
|
||||
- avcodec/cavsdec: Propagate error codes inside decode_mb_i()
|
||||
- avcodec/mpegaudio_parser: Consume more than 0 bytes in case of the unsupported mp3adu case
|
||||
- avutil/integer: Fix integer overflow in av_mul_i()
|
||||
- avcodec/msrle: Check that the input is large enough to contain a end of picture code
|
||||
- avcodec/jpeg2000dec: Fix off by 1 error in JPEG2000_PGOD_CPRL handling
|
||||
- avcodec/mpeg4videodec: Fix typo in sprite delta check
|
||||
- avcodec/h264_cavlc: Check mb_skip_run
|
||||
- avcodec/ra144: Fix integer overflow in add_wav()
|
||||
- avformat/utils: Never store negative values in last_IP_duration
|
||||
- avformat/utils: Fix integer overflow in discontinuity check
|
||||
- avcodec/unary: Improve get_unary() docs
|
||||
- avcodec/dvdsubdec: Sanity check len in decode_rle()
|
||||
- avcodec/mpeg4videodec: Fix undefined shift in get_amv()
|
||||
- avcodec/zmbv: Check that the decompressed data size is correct
|
||||
- avcodec/zmbv: Update decomp_len in raw frames
|
||||
- avcodec/shorten: Fix bitstream end check in read_header()
|
||||
- avcodec/dvdsubdec: Avoid branch in decode_run_8bit()
|
||||
- avcodec/h264_refs: Document last if() in ff_h264_execute_ref_pic_marking()
|
||||
- avcodec/ra144: Fix undefined integer overflow in add_wav()
|
||||
- avcodec/indeo4: Check dimensions in decode_pic_hdr()
|
||||
- avformat/mov: Error on too large stsd entry counts.
|
||||
- examples: Fix use of AV_CODEC_FLAG_GLOBAL_HEADER
|
||||
- avcodec/hq_hqa: Check remaining input bits in hqa_decode_mb()
|
||||
- avcodec/vb: Check for end of bytestream before reading blocktype
|
||||
- avcodec/snowdec: Fix integer overflow with motion vector residual
|
||||
- avformat/nsvdec: Do not parse multiple NSVf
|
||||
- avformat/mlvdec: read_string() received unsigned size, make the argument unsigned
|
||||
- avformat/rmdec: Fix EOF check in the stream loop in ivr_read_header()
|
||||
- avcodec/scpr: Check for min > max in decompress_p()
|
||||
- avcodec/shorten: Fix signed 32bit overflow in shift in shorten_decode_frame()
|
||||
- avcodec/shorten: Fix integer overflow in residual/LPC combination
|
||||
- avcodec/shorten: Check verbatim length
|
||||
- avcodec/mpegaudio_parser: Initialize poutbuf*
|
||||
- avcodec/aacpsdsp_template: Fix integer overflow in ps_stereo_interpolate_c()
|
||||
- avformat/flvenc: Check audio packet size
|
||||
- lavc/svq3: Fix regression decoding some files.
|
||||
- avcodec/qtrle: Check remaining bytestream in qtrle_decode_XYbpp()
|
||||
- avcodec/diracdec: Check bytes count in else branch in decode_lowdelay() too
|
||||
- avcodec/diracdec: Check slice numbers for overflows in relation to picture dimensions
|
||||
- avcodec/diracdec: Change frame_number to 64bit as its a 32bit from the bitstream and we also have a -1 special case
|
||||
- avcodec/dirac_dwt_template: Fix several integer overflows in horizontal_compose_daub97i()
|
||||
- avcodec/diracdec: Prevent integer overflow in intermediate in global_mv()
|
||||
- swresample/swresample: Fix input channel count in resample_first computation
|
||||
- avutil/pixfmt: Document chroma plane size for odd resolutions
|
||||
- avcodec/cuviddec: properly take deinterlacing and display delay into account for buffer_full check
|
||||
- avcodec/bitstream_filters: check the input argument of av_bsf_get_by_name() for NULL
|
||||
|
||||
|
||||
version 3.3.8:
|
||||
- avcodec/dvdsub_parser: Allocate input padding
|
||||
- avcodec/dvdsub_parser: Init output buf/size
|
||||
|
||||
+1
-1
@@ -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 = 3.3.8
|
||||
PROJECT_NUMBER = 3.3.9
|
||||
|
||||
# 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
|
||||
|
||||
@@ -173,6 +173,9 @@ static int open_output_file(const char *filename)
|
||||
enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
|
||||
}
|
||||
|
||||
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
/* Third parameter can be used to pass settings to encoder */
|
||||
ret = avcodec_open2(enc_ctx, encoder, NULL);
|
||||
if (ret < 0) {
|
||||
@@ -184,8 +187,6 @@ static int open_output_file(const char *filename)
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to copy encoder parameters to output stream #%u\n", i);
|
||||
return ret;
|
||||
}
|
||||
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
out_stream->time_base = enc_ctx->time_base;
|
||||
stream_ctx[i].enc_ctx = enc_ctx;
|
||||
|
||||
@@ -554,6 +554,7 @@ static void ffmpeg_cleanup(int ret)
|
||||
ost->audio_channels_mapped = 0;
|
||||
|
||||
av_dict_free(&ost->sws_dict);
|
||||
av_dict_free(&ost->swr_opts);
|
||||
|
||||
avcodec_free_context(&ost->enc_ctx);
|
||||
avcodec_parameters_free(&ost->ref_par);
|
||||
@@ -2154,9 +2155,6 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
|
||||
|
||||
/* determine if the parameters for this input changed */
|
||||
need_reinit = ifilter->format != frame->format;
|
||||
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
|
||||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
|
||||
need_reinit = 1;
|
||||
|
||||
switch (ifilter->ist->st->codecpar->codec_type) {
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
@@ -2170,6 +2168,13 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ifilter->ist->reinit_filters && fg->graph)
|
||||
need_reinit = 0;
|
||||
|
||||
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
|
||||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
|
||||
need_reinit = 1;
|
||||
|
||||
if (need_reinit) {
|
||||
ret = ifilter_parameters_from_frame(ifilter, frame);
|
||||
if (ret < 0)
|
||||
|
||||
+8
-4
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* ffmpeg option parsing
|
||||
*
|
||||
@@ -2303,12 +2304,14 @@ loop_end:
|
||||
o->attachments[i]);
|
||||
exit_program(1);
|
||||
}
|
||||
if (!(attachment = av_malloc(len))) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n",
|
||||
if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE ||
|
||||
!(attachment = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Attachment %s too large.\n",
|
||||
o->attachments[i]);
|
||||
exit_program(1);
|
||||
}
|
||||
avio_read(pb, attachment, len);
|
||||
memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
ost = new_attachment_stream(o, oc, -1);
|
||||
ost->stream_copy = 0;
|
||||
@@ -2700,13 +2703,14 @@ static int opt_target(void *optctx, const char *opt, const char *arg)
|
||||
} else {
|
||||
/* Try to determine PAL/NTSC by peeking in the input files */
|
||||
if (nb_input_files) {
|
||||
int i, j, fr;
|
||||
int i, j;
|
||||
for (j = 0; j < nb_input_files; j++) {
|
||||
for (i = 0; i < input_files[j]->nb_streams; i++) {
|
||||
AVStream *st = input_files[j]->ctx->streams[i];
|
||||
int64_t fr;
|
||||
if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
|
||||
continue;
|
||||
fr = st->time_base.den * 1000 / st->time_base.num;
|
||||
fr = st->time_base.den * 1000LL / st->time_base.num;
|
||||
if (fr == 25000) {
|
||||
norm = PAL;
|
||||
break;
|
||||
|
||||
@@ -149,10 +149,10 @@ static void ps_stereo_interpolate_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2],
|
||||
INTFLOAT h1 = h[0][1];
|
||||
INTFLOAT h2 = h[0][2];
|
||||
INTFLOAT h3 = h[0][3];
|
||||
INTFLOAT hs0 = h_step[0][0];
|
||||
INTFLOAT hs1 = h_step[0][1];
|
||||
INTFLOAT hs2 = h_step[0][2];
|
||||
INTFLOAT hs3 = h_step[0][3];
|
||||
UINTFLOAT hs0 = h_step[0][0];
|
||||
UINTFLOAT hs1 = h_step[0][1];
|
||||
UINTFLOAT hs2 = h_step[0][2];
|
||||
UINTFLOAT hs3 = h_step[0][3];
|
||||
int n;
|
||||
|
||||
for (n = 0; n < len; n++) {
|
||||
|
||||
+1
-1
@@ -1065,7 +1065,7 @@ static int bit_alloc(AC3EncodeContext *s, int snr_offset)
|
||||
{
|
||||
int blk, ch;
|
||||
|
||||
snr_offset = (snr_offset - 240) << 2;
|
||||
snr_offset = (snr_offset - 240) * 4;
|
||||
|
||||
reset_block_bap(s);
|
||||
for (blk = 0; blk < s->num_blocks; blk++) {
|
||||
|
||||
+8
-8
@@ -1182,8 +1182,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
for (count2 = 0; count2 < 28; count2++) {
|
||||
byte = bytestream2_get_byteu(&gb);
|
||||
next_left_sample = sign_extend(byte >> 4, 4) << shift_left;
|
||||
next_right_sample = sign_extend(byte, 4) << shift_right;
|
||||
next_left_sample = sign_extend(byte >> 4, 4) * (1 << shift_left);
|
||||
next_right_sample = sign_extend(byte, 4) * (1 << shift_right);
|
||||
|
||||
next_left_sample = (next_left_sample +
|
||||
(current_left_sample * coeff1l) +
|
||||
@@ -1222,7 +1222,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (st) byte[1] = bytestream2_get_byteu(&gb);
|
||||
for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
|
||||
for(channel = 0; channel < avctx->channels; channel++) {
|
||||
int sample = sign_extend(byte[channel] >> i, 4) << shift[channel];
|
||||
int sample = sign_extend(byte[channel] >> i, 4) * (1 << shift[channel]);
|
||||
sample = (sample +
|
||||
c->status[channel].sample1 * coeff[channel][0] +
|
||||
c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
|
||||
@@ -1337,11 +1337,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int level, pred;
|
||||
int byte = bytestream2_get_byteu(&gb);
|
||||
|
||||
level = sign_extend(byte >> 4, 4) << shift[n];
|
||||
level = sign_extend(byte >> 4, 4) * (1 << shift[n]);
|
||||
pred = s[-1] * coeff[0][n] + s[-2] * coeff[1][n];
|
||||
s[0] = av_clip_int16((level + pred + 0x80) >> 8);
|
||||
|
||||
level = sign_extend(byte, 4) << shift[n];
|
||||
level = sign_extend(byte, 4) * (1 << shift[n]);
|
||||
pred = s[0] * coeff[0][n] + s[-1] * coeff[1][n];
|
||||
s[1] = av_clip_int16((level + pred + 0x80) >> 8);
|
||||
}
|
||||
@@ -1498,8 +1498,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
sampledat = sign_extend(byte >> 4, 4);
|
||||
}
|
||||
|
||||
sampledat = ((prev1 * factor1 + prev2 * factor2) +
|
||||
((sampledat * scale) << 11)) >> 11;
|
||||
sampledat = ((prev1 * factor1 + prev2 * factor2) >> 11) +
|
||||
sampledat * scale;
|
||||
*samples = av_clip_int16(sampledat);
|
||||
prev2 = prev1;
|
||||
prev1 = *samples++;
|
||||
@@ -1576,7 +1576,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
|
||||
sampledat = ((c->status[ch].sample1 * factor1
|
||||
+ c->status[ch].sample2 * factor2) >> 11) + (sampledat << exp);
|
||||
+ c->status[ch].sample2 * factor2) >> 11) + sampledat * (1 << exp);
|
||||
*samples = av_clip_int16(sampledat);
|
||||
c->status[ch].sample2 = c->status[ch].sample1;
|
||||
c->status[ch].sample1 = *samples++;
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
|
||||
s2 = prev->s2;
|
||||
for (i = 0, j = 0; j < 32; i += channels, j++) {
|
||||
s0 = wav[i];
|
||||
d = ((s0 << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
|
||||
d = s0 + ((-c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS);
|
||||
if (max < d)
|
||||
max = d;
|
||||
if (min > d)
|
||||
@@ -79,13 +79,13 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
|
||||
s1 = prev->s1;
|
||||
s2 = prev->s2;
|
||||
for (i = 0, j = 0; j < 32; i += channels, j++) {
|
||||
d = ((wav[i] << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
|
||||
d = wav[i] + ((-c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS);
|
||||
|
||||
d = av_clip_intp2(ROUNDED_DIV(d, scale), 3);
|
||||
|
||||
put_sbits(&pb, 4, d);
|
||||
|
||||
s0 = ((d << COEFF_BITS) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS;
|
||||
s0 = d * scale + ((c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS);
|
||||
s2 = s1;
|
||||
s1 = s0;
|
||||
}
|
||||
|
||||
@@ -162,9 +162,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
|
||||
uint32_t code;
|
||||
volatile VLC_TYPE (* volatile table)[2]; // the double volatile is needed to prevent an internal compiler error in gcc 4.2
|
||||
|
||||
table_size = 1 << table_nb_bits;
|
||||
if (table_nb_bits > 30)
|
||||
return -1;
|
||||
table_size = 1 << table_nb_bits;
|
||||
table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);
|
||||
ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
|
||||
if (table_index < 0)
|
||||
|
||||
@@ -59,6 +59,9 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; bitstream_filters[i]; i++) {
|
||||
const AVBitStreamFilter *f = bitstream_filters[i];
|
||||
if (!strcmp(f->name, name))
|
||||
|
||||
+21
-8
@@ -591,14 +591,21 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
|
||||
}
|
||||
|
||||
|
||||
static inline void decode_residual_chroma(AVSContext *h)
|
||||
static inline int decode_residual_chroma(AVSContext *h)
|
||||
{
|
||||
if (h->cbp & (1 << 4))
|
||||
decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
if (h->cbp & (1 << 4)) {
|
||||
int ret = decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
ff_cavs_chroma_qp[h->qp], h->cu, h->c_stride);
|
||||
if (h->cbp & (1 << 5))
|
||||
decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (h->cbp & (1 << 5)) {
|
||||
int ret = decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
ff_cavs_chroma_qp[h->qp], h->cv, h->c_stride);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int decode_residual_inter(AVSContext *h)
|
||||
@@ -649,6 +656,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
|
||||
uint8_t top[18];
|
||||
uint8_t *left = NULL;
|
||||
uint8_t *d;
|
||||
int ret;
|
||||
|
||||
ff_cavs_init_mb(h);
|
||||
|
||||
@@ -692,8 +700,11 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
|
||||
ff_cavs_load_intra_pred_luma(h, top, &left, block);
|
||||
h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]
|
||||
(d, top, left, h->l_stride);
|
||||
if (h->cbp & (1<<block))
|
||||
decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride);
|
||||
if (h->cbp & (1<<block)) {
|
||||
ret = decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* chroma intra prediction */
|
||||
@@ -703,7 +714,9 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
|
||||
h->intra_pred_c[pred_mode_uv](h->cv, &h->top_border_v[h->mbx * 10],
|
||||
h->left_border_v, h->c_stride);
|
||||
|
||||
decode_residual_chroma(h);
|
||||
ret = decode_residual_chroma(h);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ff_cavs_filter(h, I_8X8);
|
||||
set_mv_intra(h);
|
||||
return 0;
|
||||
|
||||
+24
-24
@@ -201,20 +201,20 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, ptrdiff_t stride)
|
||||
src[0][0] += 8;
|
||||
|
||||
for( i = 0; i < 8; i++ ) {
|
||||
const int a0 = 3*src[i][1] - (src[i][7]<<1);
|
||||
const int a1 = 3*src[i][3] + (src[i][5]<<1);
|
||||
const int a2 = (src[i][3]<<1) - 3*src[i][5];
|
||||
const int a3 = (src[i][1]<<1) + 3*src[i][7];
|
||||
const int a0 = 3 * src[i][1] - 2 * src[i][7];
|
||||
const int a1 = 3 * src[i][3] + 2 * src[i][5];
|
||||
const int a2 = 2 * src[i][3] - 3 * src[i][5];
|
||||
const int a3 = 2 * src[i][1] + 3 * src[i][7];
|
||||
|
||||
const int b4 = ((a0 + a1 + a3)<<1) + a1;
|
||||
const int b5 = ((a0 - a1 + a2)<<1) + a0;
|
||||
const int b6 = ((a3 - a2 - a1)<<1) + a3;
|
||||
const int b7 = ((a0 - a2 - a3)<<1) - a2;
|
||||
const int b4 = 2 * (a0 + a1 + a3) + a1;
|
||||
const int b5 = 2 * (a0 - a1 + a2) + a0;
|
||||
const int b6 = 2 * (a3 - a2 - a1) + a3;
|
||||
const int b7 = 2 * (a0 - a2 - a3) - a2;
|
||||
|
||||
const int a7 = (src[i][2]<<2) - 10*src[i][6];
|
||||
const int a6 = (src[i][6]<<2) + 10*src[i][2];
|
||||
const int a5 = ((src[i][0] - src[i][4]) << 3) + 4;
|
||||
const int a4 = ((src[i][0] + src[i][4]) << 3) + 4;
|
||||
const int a7 = 4 * src[i][2] - 10 * src[i][6];
|
||||
const int a6 = 4 * src[i][6] + 10 * src[i][2];
|
||||
const int a5 = 8 * (src[i][0] - src[i][4]) + 4;
|
||||
const int a4 = 8 * (src[i][0] + src[i][4]) + 4;
|
||||
|
||||
const int b0 = a4 + a6;
|
||||
const int b1 = a5 + a7;
|
||||
@@ -231,20 +231,20 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, ptrdiff_t stride)
|
||||
src[i][7] = (b0 - b4) >> 3;
|
||||
}
|
||||
for( i = 0; i < 8; i++ ) {
|
||||
const int a0 = 3*src[1][i] - (src[7][i]<<1);
|
||||
const int a1 = 3*src[3][i] + (src[5][i]<<1);
|
||||
const int a2 = (src[3][i]<<1) - 3*src[5][i];
|
||||
const int a3 = (src[1][i]<<1) + 3*src[7][i];
|
||||
const int a0 = 3 * src[1][i] - 2 * src[7][i];
|
||||
const int a1 = 3 * src[3][i] + 2 * src[5][i];
|
||||
const int a2 = 2 * src[3][i] - 3 * src[5][i];
|
||||
const int a3 = 2 * src[1][i] + 3 * src[7][i];
|
||||
|
||||
const int b4 = ((a0 + a1 + a3)<<1) + a1;
|
||||
const int b5 = ((a0 - a1 + a2)<<1) + a0;
|
||||
const int b6 = ((a3 - a2 - a1)<<1) + a3;
|
||||
const int b7 = ((a0 - a2 - a3)<<1) - a2;
|
||||
const int b4 = 2 * (a0 + a1 + a3) + a1;
|
||||
const int b5 = 2 * (a0 - a1 + a2) + a0;
|
||||
const int b6 = 2 * (a3 - a2 - a1) + a3;
|
||||
const int b7 = 2 * (a0 - a2 - a3) - a2;
|
||||
|
||||
const int a7 = (src[2][i]<<2) - 10*src[6][i];
|
||||
const int a6 = (src[6][i]<<2) + 10*src[2][i];
|
||||
const int a5 = (src[0][i] - src[4][i]) << 3;
|
||||
const int a4 = (src[0][i] + src[4][i]) << 3;
|
||||
const int a7 = 4 * src[2][i] - 10 * src[6][i];
|
||||
const int a6 = 4 * src[6][i] + 10 * src[2][i];
|
||||
const int a5 = 8 * (src[0][i] - src[4][i]);
|
||||
const int a4 = 8 * (src[0][i] + src[4][i]);
|
||||
|
||||
const int b0 = a4 + a6;
|
||||
const int b1 = a5 + a7;
|
||||
|
||||
+5
-1
@@ -367,13 +367,17 @@ static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt)
|
||||
AVPacket filter_packet = { 0 };
|
||||
AVPacket filtered_packet = { 0 };
|
||||
int ret = 0, eret = 0, is_flush = ctx->decoder_flushing;
|
||||
int delay = ctx->cuparseinfo.ulMaxDisplayDelay;
|
||||
|
||||
av_log(avctx, AV_LOG_TRACE, "cuvid_decode_packet\n");
|
||||
|
||||
if (is_flush && avpkt && avpkt->size)
|
||||
return AVERROR_EOF;
|
||||
|
||||
if ((av_fifo_size(ctx->frame_queue) / sizeof(CuvidParsedFrame)) + 2 > ctx->nb_surfaces && avpkt && avpkt->size)
|
||||
if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave && !ctx->drop_second_field)
|
||||
delay *= 2;
|
||||
|
||||
if ((av_fifo_size(ctx->frame_queue) / sizeof(CuvidParsedFrame)) + delay >= ctx->nb_surfaces && avpkt && avpkt->size)
|
||||
return AVERROR(EAGAIN);
|
||||
|
||||
if (ctx->bsf && avpkt && avpkt->size) {
|
||||
|
||||
@@ -190,15 +190,15 @@ static void RENAME(horizontal_compose_daub97i)(uint8_t *_b, uint8_t *_temp, int
|
||||
|
||||
// second stage combined with interleave and shift
|
||||
b0 = b2 = COMPOSE_DAUB97iL0(temp[w2], temp[0], temp[w2]);
|
||||
b[0] = (b0 + 1) >> 1;
|
||||
b[0] = ~((~b0) >> 1);
|
||||
for (x = 1; x < w2; x++) {
|
||||
b2 = COMPOSE_DAUB97iL0(temp[x+w2-1], temp[x ], temp[x+w2]);
|
||||
b1 = COMPOSE_DAUB97iH0( b0, temp[x+w2-1], b2 );
|
||||
b[2*x-1] = (b1 + 1) >> 1;
|
||||
b[2*x ] = (b2 + 1) >> 1;
|
||||
b[2*x-1] = ~((~b1) >> 1);
|
||||
b[2*x ] = ~((~b2) >> 1);
|
||||
b0 = b2;
|
||||
}
|
||||
b[w-1] = (COMPOSE_DAUB97iH0(b2, temp[w-1], b2) + 1) >> 1;
|
||||
b[w-1] = ~((~COMPOSE_DAUB97iH0(b2, temp[w-1], b2)) >> 1);
|
||||
}
|
||||
|
||||
static void RENAME(vertical_compose_dirac53iH0)(uint8_t *_b0, uint8_t *_b1, uint8_t *_b2,
|
||||
|
||||
+12
-5
@@ -140,7 +140,7 @@ typedef struct DiracContext {
|
||||
GetBitContext gb;
|
||||
AVDiracSeqHeader seq;
|
||||
int seen_sequence_header;
|
||||
int frame_number; /* number of the next frame to display */
|
||||
int64_t frame_number; /* number of the next frame to display */
|
||||
Plane plane[3];
|
||||
int chroma_x_shift;
|
||||
int chroma_y_shift;
|
||||
@@ -985,6 +985,10 @@ static int decode_lowdelay(DiracContext *s)
|
||||
for (slice_x = 0; bufsize > 0 && slice_x < s->num_x; slice_x++) {
|
||||
bytes = (slice_num+1) * (int64_t)s->lowdelay.bytes.num / s->lowdelay.bytes.den
|
||||
- slice_num * (int64_t)s->lowdelay.bytes.num / s->lowdelay.bytes.den;
|
||||
if (bytes >= INT_MAX || bytes*8 > bufsize) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "too many bytes\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
slices[slice_num].bytes = bytes;
|
||||
slices[slice_num].slice_x = slice_x;
|
||||
slices[slice_num].slice_y = slice_y;
|
||||
@@ -1242,7 +1246,10 @@ static int dirac_unpack_idwt_params(DiracContext *s)
|
||||
else {
|
||||
s->num_x = get_interleaved_ue_golomb(gb);
|
||||
s->num_y = get_interleaved_ue_golomb(gb);
|
||||
if (s->num_x * s->num_y == 0 || s->num_x * (uint64_t)s->num_y > INT_MAX) {
|
||||
if (s->num_x * s->num_y == 0 || s->num_x * (uint64_t)s->num_y > INT_MAX ||
|
||||
s->num_x * (uint64_t)s->avctx->width > INT_MAX ||
|
||||
s->num_y * (uint64_t)s->avctx->height > INT_MAX
|
||||
) {
|
||||
av_log(s->avctx,AV_LOG_ERROR,"Invalid numx/y\n");
|
||||
s->num_x = s->num_y = 0;
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -1399,8 +1406,8 @@ static void global_mv(DiracContext *s, DiracBlock *block, int x, int y, int ref)
|
||||
int *c = s->globalmc[ref].perspective;
|
||||
|
||||
int m = (1<<ep) - (c[0]*x + c[1]*y);
|
||||
int64_t mx = m * (int64_t)((A[0][0] * x + A[0][1]*y) + (1<<ez) * b[0]);
|
||||
int64_t my = m * (int64_t)((A[1][0] * x + A[1][1]*y) + (1<<ez) * b[1]);
|
||||
int64_t mx = m * (int64_t)((A[0][0] * (int64_t)x + A[0][1]*(int64_t)y) + (1<<ez) * b[0]);
|
||||
int64_t my = m * (int64_t)((A[1][0] * (int64_t)x + A[1][1]*(int64_t)y) + (1<<ez) * b[1]);
|
||||
|
||||
block->u.mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep);
|
||||
block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep);
|
||||
@@ -2300,7 +2307,7 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
}
|
||||
|
||||
if (*got_frame)
|
||||
s->frame_number = picture->display_picture_number + 1;
|
||||
s->frame_number = picture->display_picture_number + 1LL;
|
||||
|
||||
return buf_idx;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ static av_cold int dnxhd_init_vlc(DNXHDEncContext *ctx)
|
||||
ctx->vlc_bits += max_level * 2;
|
||||
for (level = -max_level; level < max_level; level++) {
|
||||
for (run = 0; run < 2; run++) {
|
||||
int index = (level << 1) | run;
|
||||
int index = level * (1 << 1) | run;
|
||||
int sign, offset = 0, alevel = level;
|
||||
|
||||
MASK_ABS(sign, alevel);
|
||||
@@ -618,7 +618,7 @@ void dnxhd_encode_block(DNXHDEncContext *ctx, int16_t *block,
|
||||
slevel = block[j];
|
||||
if (slevel) {
|
||||
int run_level = i - last_non_zero - 1;
|
||||
int rlevel = (slevel << 1) | !!run_level;
|
||||
int rlevel = slevel * (1 << 1) | !!run_level;
|
||||
put_bits(&ctx->m.pb, ctx->vlc_bits[rlevel], ctx->vlc_codes[rlevel]);
|
||||
if (run_level)
|
||||
put_bits(&ctx->m.pb, ctx->run_bits[run_level],
|
||||
@@ -698,7 +698,7 @@ int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, int16_t *block, int last_index)
|
||||
level = block[j];
|
||||
if (level) {
|
||||
int run_level = i - last_non_zero - 1;
|
||||
bits += ctx->vlc_bits[(level << 1) |
|
||||
bits += ctx->vlc_bits[level * (1 << 1) |
|
||||
!!run_level] + ctx->run_bits[run_level];
|
||||
last_non_zero = i;
|
||||
}
|
||||
|
||||
@@ -82,10 +82,7 @@ static int decode_run_8bit(GetBitContext *gb, int *color)
|
||||
{
|
||||
int len;
|
||||
int has_run = get_bits1(gb);
|
||||
if (get_bits1(gb))
|
||||
*color = get_bits(gb, 8);
|
||||
else
|
||||
*color = get_bits(gb, 2);
|
||||
*color = get_bits(gb, 2 + 6*get_bits1(gb));
|
||||
if (has_run) {
|
||||
if (get_bits1(gb)) {
|
||||
len = get_bits(gb, 7);
|
||||
@@ -127,6 +124,8 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
|
||||
len = decode_run_8bit(&gb, &color);
|
||||
else
|
||||
len = decode_run_2bit(&gb, &color);
|
||||
if (len != INT_MAX && len > w - x)
|
||||
return AVERROR_INVALIDDATA;
|
||||
len = FFMIN(len, w - x);
|
||||
memset(d + x, color, len);
|
||||
x += len;
|
||||
|
||||
+1
-1
@@ -892,7 +892,7 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
|
||||
in = ptr[3] + s->xdelta;
|
||||
|
||||
for (j = 0; j < s->xdelta; ++j) {
|
||||
uint32_t diff = (*(ptr[0]++) << 24) |
|
||||
uint32_t diff = ((uint32_t)*(ptr[0]++) << 24) |
|
||||
(*(ptr[1]++) << 16) |
|
||||
(*(ptr[2]++) << 8 ) |
|
||||
(*(ptr[3]++));
|
||||
|
||||
@@ -714,8 +714,14 @@ int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl)
|
||||
cbp = 0; /* avoid warning. FIXME: find a solution without slowing
|
||||
down the code */
|
||||
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
|
||||
if (sl->mb_skip_run == -1)
|
||||
sl->mb_skip_run = get_ue_golomb_long(&sl->gb);
|
||||
if (sl->mb_skip_run == -1) {
|
||||
unsigned mb_skip_run = get_ue_golomb_long(&sl->gb);
|
||||
if (mb_skip_run > h->mb_num) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "mb_skip_run %d is invalid\n", mb_skip_run);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
sl->mb_skip_run = mb_skip_run;
|
||||
}
|
||||
|
||||
if (sl->mb_skip_run--) {
|
||||
if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) {
|
||||
|
||||
@@ -806,6 +806,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
|
||||
}
|
||||
}
|
||||
|
||||
// Detect unmarked random access points
|
||||
if ( err >= 0
|
||||
&& h->long_ref_count==0
|
||||
&& ( h->short_ref_count<=2
|
||||
|
||||
@@ -2799,6 +2799,10 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
|
||||
return ret;
|
||||
|
||||
if (s->sh.first_slice_in_pic_flag) {
|
||||
if (s->ref) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first in the same frame.\n");
|
||||
goto fail;
|
||||
}
|
||||
if (s->max_ra == INT_MAX) {
|
||||
if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) {
|
||||
s->max_ra = s->poc;
|
||||
|
||||
@@ -181,6 +181,9 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
|
||||
int flag = 0;
|
||||
int i, ret, cbp;
|
||||
|
||||
if (get_bits_left(gb) < 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
cbp = get_vlc2(gb, c->hqa_cbp_vlc.table, 5, 1);
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#define BITSTREAM_READER_LE
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "indeo4data.h"
|
||||
#include "internal.h"
|
||||
#include "ivi.h"
|
||||
@@ -178,6 +179,13 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
||||
pic_conf.chroma_bands = 0;
|
||||
if (pic_conf.luma_bands)
|
||||
pic_conf.chroma_bands = decode_plane_subdivision(&ctx->gb);
|
||||
|
||||
if (av_image_check_size2(pic_conf.pic_width, pic_conf.pic_height, avctx->max_pixels, AV_PIX_FMT_YUV410P, 0, avctx) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "picture dimensions %d %d cannot be decoded\n",
|
||||
pic_conf.pic_width, pic_conf.pic_height);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
|
||||
if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
|
||||
|
||||
@@ -1266,7 +1266,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
|
||||
for(i=0; i<13; i++){
|
||||
for(j=0; j<3; j++){
|
||||
int v= get_bits(&s->gb, 8);
|
||||
v |= get_sbits(&s->gb, 8)<<8;
|
||||
v |= get_sbits(&s->gb, 8) * (1 << 8);
|
||||
av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
|
||||
}
|
||||
av_log(s->avctx, AV_LOG_DEBUG, "\n");
|
||||
|
||||
@@ -1128,7 +1128,7 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
|
||||
step_x = 32;
|
||||
step_y = 32;
|
||||
|
||||
if (RSpoc > FFMIN(codsty->nreslevels, REpoc))
|
||||
if (RSpoc >= FFMIN(codsty->nreslevels, REpoc))
|
||||
continue;
|
||||
|
||||
for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) {
|
||||
|
||||
@@ -255,7 +255,7 @@ static void dwt_encode97_int(DWTContext *s, int *t)
|
||||
line += 5;
|
||||
|
||||
for (i = 0; i < w * h; i++)
|
||||
t[i] <<= I_PRESHIFT;
|
||||
t[i] *= 1 << I_PRESHIFT;
|
||||
|
||||
for (lev = s->ndeclevels-1; lev >= 0; lev--){
|
||||
int lh = s->linelen[lev][0],
|
||||
|
||||
@@ -279,7 +279,6 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
if ((discard_padding < avctx->frame_size) != (avpkt->duration > 0)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n");
|
||||
av_packet_unref(avpkt);
|
||||
av_free(avpkt);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if ((!s->delay_sent && avctx->initial_padding > 0) || discard_padding > 0) {
|
||||
@@ -288,7 +287,6 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
10);
|
||||
if(!side_data) {
|
||||
av_packet_unref(avpkt);
|
||||
av_free(avpkt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
if (!s->delay_sent) {
|
||||
|
||||
@@ -482,7 +482,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
// Check if subtraction resulted in an overflow
|
||||
if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
|
||||
av_packet_unref(avpkt);
|
||||
av_free(avpkt);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (discard_padding > 0) {
|
||||
@@ -491,7 +490,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
10);
|
||||
if(!side_data) {
|
||||
av_packet_unref(avpkt);
|
||||
av_free(avpkt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
AV_WL32(side_data + 4, discard_padding);
|
||||
|
||||
@@ -860,7 +860,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
cx_frame->sz_alpha + 8);
|
||||
if(!side_data) {
|
||||
av_packet_unref(pkt);
|
||||
av_free(pkt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
AV_WB64(side_data, 1);
|
||||
|
||||
@@ -392,7 +392,7 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
|
||||
llabs(sprite_offset[0][i] + sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
|
||||
llabs(sprite_offset[0][i] + sprite_delta[i][0] * (w+16LL) + sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
|
||||
llabs(sprite_delta[i][0] * (w+16LL)) >= INT_MAX ||
|
||||
llabs(sprite_delta[i][1] * (w+16LL)) >= INT_MAX ||
|
||||
llabs(sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
|
||||
llabs(sd[0]) >= INT_MAX ||
|
||||
llabs(sd[1]) >= INT_MAX ||
|
||||
llabs(sprite_offset[0][i] + sd[0] * (w+16LL)) >= INT_MAX ||
|
||||
@@ -539,7 +539,7 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n)
|
||||
len >>= s->quarter_sample;
|
||||
|
||||
if (s->real_sprite_warping_points == 1) {
|
||||
if (ctx->divx_version == 500 && ctx->divx_build == 413)
|
||||
if (ctx->divx_version == 500 && ctx->divx_build == 413 && a >= s->quarter_sample)
|
||||
sum = s->sprite_offset[0][n] / (1 << (a - s->quarter_sample));
|
||||
else
|
||||
sum = RSHIFT(s->sprite_offset[0][n] * (1 << s->quarter_sample), a);
|
||||
|
||||
@@ -98,7 +98,9 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
|
||||
} else if (codec_id == AV_CODEC_ID_MP3ADU) {
|
||||
avpriv_report_missing_feature(avctx,
|
||||
"MP3ADU full parser");
|
||||
return 0; /* parsers must not return error codes */
|
||||
*poutbuf = NULL;
|
||||
*poutbuf_size = 0;
|
||||
return buf_size; /* parsers must not return error codes */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -95,6 +95,9 @@ static int msrle_decode_frame(AVCodecContext *avctx,
|
||||
s->buf = buf;
|
||||
s->size = buf_size;
|
||||
|
||||
if (buf_size < 2) //Minimally a end of picture code should be there
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
+2
-2
@@ -290,7 +290,7 @@ static av_cold int pcm_decode_close(AVCodecContext *avctx)
|
||||
#define DECODE(size, endian, src, dst, n, shift, offset) \
|
||||
for (; n > 0; n--) { \
|
||||
uint ## size ## _t v = bytestream_get_ ## endian(&src); \
|
||||
AV_WN ## size ## A(dst, (v - offset) << shift); \
|
||||
AV_WN ## size ## A(dst, (uint ## size ## _t)(v - offset) << shift); \
|
||||
dst += size / 8; \
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ static av_cold int pcm_decode_close(AVCodecContext *avctx)
|
||||
dst = frame->extended_data[c]; \
|
||||
for (i = n; i > 0; i--) { \
|
||||
uint ## size ## _t v = bytestream_get_ ## endian(&src); \
|
||||
AV_WN ## size ## A(dst, (v - offset) << shift); \
|
||||
AV_WN ## size ## A(dst, (uint ## size ##_t)(v - offset) << shift); \
|
||||
dst += size / 8; \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -577,6 +577,10 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
}
|
||||
s->color_type = bytestream2_get_byte(&s->gb);
|
||||
s->compression_type = bytestream2_get_byte(&s->gb);
|
||||
if (s->compression_type) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid compression method %d\n", s->compression_type);
|
||||
goto error;
|
||||
}
|
||||
s->filter_type = bytestream2_get_byte(&s->gb);
|
||||
s->interlace_type = bytestream2_get_byte(&s->gb);
|
||||
bytestream2_skip(&s->gb, 4); /* crc */
|
||||
|
||||
@@ -183,7 +183,7 @@ static void encode_codeword(PutBitContext *pb, int val, int codebook)
|
||||
}
|
||||
|
||||
#define QSCALE(qmat,ind,val) ((val) / ((qmat)[ind]))
|
||||
#define TO_GOLOMB(val) (((val) << 1) ^ ((val) >> 31))
|
||||
#define TO_GOLOMB(val) (((val) * 2) ^ ((val) >> 31))
|
||||
#define DIFF_SIGN(val, sign) (((val) >> 31) ^ (sign))
|
||||
#define IS_NEGATIVE(val) ((((val) >> 31) ^ -1) + 1)
|
||||
#define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
|
||||
|
||||
@@ -155,6 +155,8 @@ static inline void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr,
|
||||
CHECK_PIXEL_PTR(0);
|
||||
|
||||
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
|
||||
if (bytestream2_get_bytes_left(&s->g) < 1)
|
||||
return;
|
||||
if (rle_code == 0) {
|
||||
/* there's another skip code in the stream */
|
||||
pixel_ptr += (num_pixels * (bytestream2_get_byte(&s->g) - 1));
|
||||
@@ -210,6 +212,8 @@ static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
|
||||
CHECK_PIXEL_PTR(0);
|
||||
|
||||
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
|
||||
if (bytestream2_get_bytes_left(&s->g) < 1)
|
||||
return;
|
||||
if (rle_code == 0) {
|
||||
/* there's another skip code in the stream */
|
||||
pixel_ptr += (4 * (bytestream2_get_byte(&s->g) - 1));
|
||||
@@ -259,6 +263,8 @@ static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change
|
||||
CHECK_PIXEL_PTR(0);
|
||||
|
||||
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
|
||||
if (bytestream2_get_bytes_left(&s->g) < 1)
|
||||
return;
|
||||
if (rle_code == 0) {
|
||||
/* there's another skip code in the stream */
|
||||
pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 2;
|
||||
@@ -303,6 +309,8 @@ static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change
|
||||
CHECK_PIXEL_PTR(0);
|
||||
|
||||
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
|
||||
if (bytestream2_get_bytes_left(&s->g) < 1)
|
||||
return;
|
||||
if (rle_code == 0) {
|
||||
/* there's another skip code in the stream */
|
||||
pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 3;
|
||||
@@ -350,6 +358,8 @@ static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change
|
||||
CHECK_PIXEL_PTR(0);
|
||||
|
||||
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
|
||||
if (bytestream2_get_bytes_left(&s->g) < 1)
|
||||
return;
|
||||
if (rle_code == 0) {
|
||||
/* there's another skip code in the stream */
|
||||
pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 4;
|
||||
|
||||
+1
-1
@@ -1516,7 +1516,7 @@ static void add_wav(int16_t *dest, int n, int skip_first, int *m,
|
||||
|
||||
if (v[0]) {
|
||||
for (i=0; i < BLOCKSIZE; i++)
|
||||
dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12;
|
||||
dest[i] = (int)((s1[i]*(unsigned)v[0]) + s2[i]*v[1] + s3[i]*v[2]) >> 12;
|
||||
} else {
|
||||
for (i=0; i < BLOCKSIZE; i++)
|
||||
dest[i] = ( s2[i]*v[1] + s3[i]*v[2]) >> 12;
|
||||
|
||||
@@ -477,8 +477,8 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
LPC_ORDER, 16, lpc_coefs, shift, FF_LPC_TYPE_LEVINSON,
|
||||
0, ORDER_METHOD_EST, 0, 12, 0);
|
||||
for (i = 0; i < LPC_ORDER; i++)
|
||||
block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
|
||||
(12 - shift[LPC_ORDER - 1]));
|
||||
block_coefs[NBLOCKS - 1][i] = -lpc_coefs[LPC_ORDER - 1][i]
|
||||
* (1 << (12 - shift[LPC_ORDER - 1]));
|
||||
|
||||
/**
|
||||
* TODO: apply perceptual weighting of the input speech through bandwidth
|
||||
|
||||
@@ -522,6 +522,9 @@ static int decompress_p(AVCodecContext *avctx,
|
||||
return ret;
|
||||
|
||||
max += temp << 8;
|
||||
if (min > max)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount);
|
||||
|
||||
while (min <= max) {
|
||||
|
||||
+10
-5
@@ -382,7 +382,7 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
|
||||
/* subtract offset from previous samples to use in prediction */
|
||||
if (command == FN_QLPC && coffset)
|
||||
for (i = -pred_order; i < 0; i++)
|
||||
s->decoded[channel][i] -= coffset;
|
||||
s->decoded[channel][i] -= (unsigned)coffset;
|
||||
|
||||
/* decode residual and do LPC prediction */
|
||||
init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset;
|
||||
@@ -391,13 +391,13 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
|
||||
for (j = 0; j < pred_order; j++)
|
||||
sum += coeffs[j] * (unsigned)s->decoded[channel][i - j - 1];
|
||||
s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) +
|
||||
(sum >> qshift);
|
||||
(unsigned)(sum >> qshift);
|
||||
}
|
||||
|
||||
/* add offset to current samples */
|
||||
if (command == FN_QLPC && coffset)
|
||||
for (i = 0; i < s->blocksize; i++)
|
||||
s->decoded[channel][i] += coffset;
|
||||
s->decoded[channel][i] += (unsigned)coffset;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ static int read_header(ShortenContext *s)
|
||||
}
|
||||
|
||||
skip_bytes = get_uint(s, NSKIPSIZE);
|
||||
if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) {
|
||||
if ((unsigned)skip_bytes > FFMAX(get_bits_left(&s->gb), 0)/8) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "invalid skip_bytes: %d\n", skip_bytes);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -623,6 +623,11 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
|
||||
switch (cmd) {
|
||||
case FN_VERBATIM:
|
||||
len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
|
||||
if (len < 0 || len > get_bits_left(&s->gb)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "verbatim length %d invalid\n",
|
||||
len);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
while (len--)
|
||||
get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
|
||||
break;
|
||||
@@ -706,7 +711,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (s->version < 2)
|
||||
s->offset[channel][s->nmean - 1] = sum / s->blocksize;
|
||||
else
|
||||
s->offset[channel][s->nmean - 1] = s->bitshift == 32 ? 0 : (sum / s->blocksize) * (1 << s->bitshift);
|
||||
s->offset[channel][s->nmean - 1] = s->bitshift == 32 ? 0 : (sum / s->blocksize) * (1LL << s->bitshift);
|
||||
}
|
||||
|
||||
/* copy wrap samples for use with next block */
|
||||
|
||||
@@ -208,8 +208,8 @@ static int decode_q_branch(SnowContext *s, int level, int x, int y){
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
pred_mv(s, &mx, &my, ref, left, top, tr);
|
||||
mx+= get_symbol(&s->c, &s->block_state[128 + 32*(mx_context + 16*!!ref)], 1);
|
||||
my+= get_symbol(&s->c, &s->block_state[128 + 32*(my_context + 16*!!ref)], 1);
|
||||
mx+= (unsigned)get_symbol(&s->c, &s->block_state[128 + 32*(mx_context + 16*!!ref)], 1);
|
||||
my+= (unsigned)get_symbol(&s->c, &s->block_state[128 + 32*(my_context + 16*!!ref)], 1);
|
||||
}
|
||||
set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type);
|
||||
}else{
|
||||
|
||||
+4
-5
@@ -1065,16 +1065,15 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
|
||||
av_log(s->avctx, AV_LOG_ERROR, "illegal slice type %u \n", slice_id);
|
||||
return -1;
|
||||
}
|
||||
if (get_bits1(&s->gb_slice)) {
|
||||
avpriv_report_missing_feature(s->avctx, "Media key encryption");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
s->slice_type = ff_h264_golomb_to_pict_type[slice_id];
|
||||
|
||||
if ((header & 0x9F) == 2) {
|
||||
i = (s->mb_num < 64) ? 5 : av_log2(s->mb_num - 1);
|
||||
i = (s->mb_num < 64) ? 6 : (1 + av_log2(s->mb_num - 1));
|
||||
get_bits(&s->gb_slice, i);
|
||||
} else if (get_bits1(&s->gb_slice)) {
|
||||
avpriv_report_missing_feature(s->avctx, "Media key encryption");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
s->slice_num = get_bits(&s->gb_slice, 8);
|
||||
|
||||
+3
-3
@@ -187,7 +187,7 @@ static void tdsc_paint_cursor(AVCodecContext *avctx, uint8_t *dst, int stride)
|
||||
static int tdsc_load_cursor(AVCodecContext *avctx)
|
||||
{
|
||||
TDSCContext *ctx = avctx->priv_data;
|
||||
int i, j, k, ret, bits, cursor_fmt;
|
||||
int i, j, k, ret, cursor_fmt;
|
||||
uint8_t *dst;
|
||||
|
||||
ctx->cursor_hot_x = bytestream2_get_le16(&ctx->gbc);
|
||||
@@ -231,7 +231,7 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
|
||||
case CUR_FMT_MONO:
|
||||
for (j = 0; j < ctx->cursor_h; j++) {
|
||||
for (i = 0; i < ctx->cursor_w; i += 32) {
|
||||
bits = bytestream2_get_be32(&ctx->gbc);
|
||||
uint32_t bits = bytestream2_get_be32(&ctx->gbc);
|
||||
for (k = 0; k < 32; k++) {
|
||||
dst[0] = !!(bits & 0x80000000);
|
||||
dst += 4;
|
||||
@@ -244,7 +244,7 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
|
||||
dst = ctx->cursor;
|
||||
for (j = 0; j < ctx->cursor_h; j++) {
|
||||
for (i = 0; i < ctx->cursor_w; i += 32) {
|
||||
bits = bytestream2_get_be32(&ctx->gbc);
|
||||
uint32_t bits = bytestream2_get_be32(&ctx->gbc);
|
||||
for (k = 0; k < 32; k++) {
|
||||
int mask_bit = !!(bits & 0x80000000);
|
||||
switch (dst[0] * 2 + mask_bit) {
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ pkt_alloc:
|
||||
put_bits(&pb, 31, 0x7FFFFFFF);
|
||||
unary -= 31;
|
||||
} else {
|
||||
put_bits(&pb, unary, (1 << unary) - 1);
|
||||
put_bits(&pb, unary, (1U << unary) - 1);
|
||||
unary = 0;
|
||||
}
|
||||
} while (unary);
|
||||
|
||||
+14
-1
@@ -28,7 +28,20 @@
|
||||
* @param gb GetBitContext
|
||||
* @param[in] stop The bitstop value (unary code of 1's or 0's)
|
||||
* @param[in] len Maximum length
|
||||
* @return Unary length/index
|
||||
* @return unary 0 based code index. This is also the length in bits of the
|
||||
* code excluding the stop bit.
|
||||
* (in case len=1)
|
||||
* 1 0
|
||||
* 0 1
|
||||
* (in case len=2)
|
||||
* 1 0
|
||||
* 01 1
|
||||
* 00 2
|
||||
* (in case len=3)
|
||||
* 1 0
|
||||
* 01 1
|
||||
* 001 2
|
||||
* 000 3
|
||||
*/
|
||||
static inline int get_unary(GetBitContext *gb, int stop, int len)
|
||||
{
|
||||
|
||||
@@ -107,6 +107,10 @@ static int vb_decode_framedata(VBDecContext *c, int offset)
|
||||
blk2 = 0;
|
||||
for (blk = 0; blk < blocks; blk++) {
|
||||
if (!(blk & 3)) {
|
||||
if (bytestream2_get_bytes_left(&g) < 1) {
|
||||
av_log(c->avctx, AV_LOG_ERROR, "Insufficient data\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
blocktypes = bytestream2_get_byte(&g);
|
||||
}
|
||||
switch (blocktypes & 0xC0) {
|
||||
|
||||
@@ -529,9 +529,9 @@ static int8_t store_weight(int weight)
|
||||
|
||||
static int restore_weight(int8_t weight)
|
||||
{
|
||||
int result;
|
||||
int result = 8 * weight;
|
||||
|
||||
if ((result = (int) weight << 3) > 0)
|
||||
if (result > 0)
|
||||
result += (result + 64) >> 7;
|
||||
|
||||
return result;
|
||||
@@ -2571,7 +2571,7 @@ static int wavpack_encode_block(WavPackEncodeContext *s,
|
||||
ret = wv_mono(s, samples_l, !s->num_terms, 1);
|
||||
} else {
|
||||
for (i = 0; i < nb_samples; i++)
|
||||
crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + samples_r[i];
|
||||
crc += (crc << 3) + ((uint32_t)samples_l[i] << 1) + samples_l[i] + samples_r[i];
|
||||
|
||||
if (s->num_passes)
|
||||
ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1);
|
||||
|
||||
@@ -408,6 +408,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
int zret = Z_OK; // Zlib return code
|
||||
int len = buf_size;
|
||||
int hi_ver, lo_ver, ret;
|
||||
int expected_size;
|
||||
|
||||
/* parse header */
|
||||
if (len < 1)
|
||||
@@ -504,6 +505,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
|
||||
c->decode_intra= decode_intra;
|
||||
}
|
||||
if (c->flags & ZMBV_KEYFRAME) {
|
||||
expected_size = avctx->width * avctx->height * (c->bpp / 8);
|
||||
} else {
|
||||
expected_size = (c->bx * c->by * 2 + 3) & ~3;
|
||||
}
|
||||
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
|
||||
(c->flags & (ZMBV_DELTAPAL | ZMBV_KEYFRAME)))
|
||||
expected_size += 768;
|
||||
|
||||
if (!c->decode_intra) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
|
||||
@@ -519,6 +528,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
memcpy(c->decomp_buf, buf, len);
|
||||
c->decomp_len = len;
|
||||
} else { // ZLIB-compressed data
|
||||
c->zstream.total_in = c->zstream.total_out = 0;
|
||||
c->zstream.next_in = (uint8_t*)buf;
|
||||
@@ -532,6 +542,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
}
|
||||
c->decomp_len = c->zstream.total_out;
|
||||
}
|
||||
if (expected_size > c->decomp_len ||
|
||||
(c->flags & ZMBV_KEYFRAME) && expected_size < c->decomp_len) {
|
||||
av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (c->flags & ZMBV_KEYFRAME) {
|
||||
frame->key_frame = 1;
|
||||
frame->pict_type = AV_PICTURE_TYPE_I;
|
||||
|
||||
@@ -186,8 +186,17 @@ static int config_input(AVFilterLink *inlink)
|
||||
|
||||
s->start_duration = av_rescale(s->start_duration, inlink->sample_rate,
|
||||
AV_TIME_BASE);
|
||||
if (s->start_duration < 0) {
|
||||
av_log(ctx, AV_LOG_WARNING, "start duration must be non-negative\n");
|
||||
s->start_duration = -s->start_duration;
|
||||
}
|
||||
|
||||
s->stop_duration = av_rescale(s->stop_duration, inlink->sample_rate,
|
||||
AV_TIME_BASE);
|
||||
if (s->stop_duration < 0) {
|
||||
av_log(ctx, AV_LOG_WARNING, "stop duration must be non-negative\n");
|
||||
s->stop_duration = -s->stop_duration;
|
||||
}
|
||||
|
||||
s->start_holdoff = av_malloc_array(FFMAX(s->start_duration, 1),
|
||||
sizeof(*s->start_holdoff) *
|
||||
|
||||
@@ -523,7 +523,7 @@ static av_cold int init(AVFilterContext *ctx)
|
||||
int startg = FFMAX3(-bg, -rg, 0);
|
||||
int endg = FFMIN3(255-bg, 255-rg, 255);
|
||||
uint32_t y = (uint32_t)(( 299*rg + 1000*startg + 114*bg)/1000);
|
||||
c = bg + (rg<<16) + 0x010101 * startg;
|
||||
c = bg + rg * (1 << 16) + 0x010101 * startg;
|
||||
for (g = startg; g <= endg; g++) {
|
||||
hqx->rgbtoyuv[c] = ((y++) << 16) + (u << 8) + v;
|
||||
c+= 0x010101;
|
||||
|
||||
@@ -395,7 +395,7 @@ static int init(AVFilterContext *ctx)
|
||||
int startg = FFMAX3(-bg, -rg, 0);
|
||||
int endg = FFMIN3(255-bg, 255-rg, 255);
|
||||
uint32_t y = (uint32_t)(( 299*rg + 1000*startg + 114*bg)/1000);
|
||||
c = bg + (rg<<16) + 0x010101 * startg;
|
||||
c = bg + rg * (1 << 16) + 0x010101 * startg;
|
||||
for (g = startg; g <= endg; g++) {
|
||||
s->rgbtoyuv[c] = ((y++) << 16) + (u << 8) + v;
|
||||
c+= 0x010101;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1209,7 +1209,7 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
|
||||
unsigned new_size, new_allocated_size;
|
||||
|
||||
/* reallocate buffer if needed */
|
||||
new_size = d->pos + buf_size;
|
||||
new_size = (unsigned)d->pos + buf_size;
|
||||
new_allocated_size = d->allocated_size;
|
||||
if (new_size < d->pos || new_size > INT_MAX/2)
|
||||
return -1;
|
||||
|
||||
@@ -146,9 +146,13 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
|
||||
}
|
||||
|
||||
do{
|
||||
vidbuf_start = av_fast_realloc(vidbuf_start, &vidbuf_capacity, vidbuf_nbytes + BUFFER_PADDING_SIZE);
|
||||
if(!vidbuf_start)
|
||||
return AVERROR(ENOMEM);
|
||||
uint8_t *tmp = av_fast_realloc(vidbuf_start, &vidbuf_capacity,
|
||||
vidbuf_nbytes + BUFFER_PADDING_SIZE);
|
||||
if (!tmp) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
vidbuf_start = tmp;
|
||||
|
||||
code = avio_r8(pb);
|
||||
vidbuf_start[vidbuf_nbytes++] = code;
|
||||
|
||||
@@ -879,6 +879,11 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
int flags = -1, flags_size, ret;
|
||||
int64_t cur_offset = avio_tell(pb);
|
||||
|
||||
if (par->codec_type == AVMEDIA_TYPE_AUDIO && !pkt->size) {
|
||||
av_log(s, AV_LOG_WARNING, "Empty audio Packet\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A ||
|
||||
par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC)
|
||||
flags_size = 2;
|
||||
|
||||
+4
-3
@@ -70,6 +70,7 @@ static int hnm_read_header(AVFormatContext *s)
|
||||
Hnm4DemuxContext *hnm = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
AVStream *vst;
|
||||
int ret;
|
||||
|
||||
/* default context members */
|
||||
hnm->pts = 0;
|
||||
@@ -113,10 +114,10 @@ static int hnm_read_header(AVFormatContext *s)
|
||||
vst->codecpar->codec_tag = 0;
|
||||
vst->codecpar->width = hnm->width;
|
||||
vst->codecpar->height = hnm->height;
|
||||
vst->codecpar->extradata = av_mallocz(1);
|
||||
if ((ret = ff_alloc_extradata(vst->codecpar, 1)) < 0)
|
||||
return ret;
|
||||
|
||||
vst->codecpar->extradata_size = 1;
|
||||
memcpy(vst->codecpar->extradata, &hnm->version, 1);
|
||||
vst->codecpar->extradata[0] = hnm->version;
|
||||
|
||||
vst->start_time = 0;
|
||||
|
||||
|
||||
@@ -187,8 +187,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;
|
||||
|
||||
@@ -681,7 +681,7 @@ static const EbmlSyntax matroska_segments[] = {
|
||||
};
|
||||
|
||||
static const EbmlSyntax matroska_blockmore[] = {
|
||||
{ MATROSKA_ID_BLOCKADDID, EBML_UINT, 0, offsetof(MatroskaBlock,additional_id) },
|
||||
{ MATROSKA_ID_BLOCKADDID, EBML_UINT, 0, offsetof(MatroskaBlock,additional_id), { .u = 1 } },
|
||||
{ MATROSKA_ID_BLOCKADDITIONAL, EBML_BIN, 0, offsetof(MatroskaBlock,additional) },
|
||||
{ 0 }
|
||||
};
|
||||
@@ -1316,7 +1316,7 @@ static int matroska_probe(AVProbeData *p)
|
||||
}
|
||||
|
||||
static MatroskaTrack *matroska_find_track_by_num(MatroskaDemuxContext *matroska,
|
||||
int num)
|
||||
uint64_t num)
|
||||
{
|
||||
MatroskaTrack *tracks = matroska->tracks.elem;
|
||||
int i;
|
||||
@@ -1325,7 +1325,7 @@ static MatroskaTrack *matroska_find_track_by_num(MatroskaDemuxContext *matroska,
|
||||
if (tracks[i].num == num)
|
||||
return &tracks[i];
|
||||
|
||||
av_log(matroska->ctx, AV_LOG_ERROR, "Invalid track number %d\n", num);
|
||||
av_log(matroska->ctx, AV_LOG_ERROR, "Invalid track number %"PRIu64"\n", num);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3279,7 +3279,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
|
||||
st = track->stream;
|
||||
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;
|
||||
@@ -3894,9 +3895,9 @@ 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) {
|
||||
if (!matroska->tracks.nb_elem || !s->nb_streams) {
|
||||
matroska_read_close(s);
|
||||
av_log(s, AV_LOG_ERROR, "No streams found\n");
|
||||
av_log(s, AV_LOG_ERROR, "No track found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
||||
+28
-15
@@ -1457,6 +1457,7 @@ static int mkv_write_chapters(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Invalid chapter start (%"PRId64") or end (%"PRId64").\n",
|
||||
chapterstart, chapterend);
|
||||
ffio_free_dyn_buf(&dyn_cp);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
@@ -2055,13 +2056,13 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
|
||||
unsigned int blockid, AVPacket *pkt, int keyframe)
|
||||
static int mkv_write_block(AVFormatContext *s, AVIOContext *pb,
|
||||
uint32_t blockid, AVPacket *pkt, int keyframe)
|
||||
{
|
||||
MatroskaMuxContext *mkv = s->priv_data;
|
||||
AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
|
||||
uint8_t *data = NULL, *side_data = NULL;
|
||||
int offset = 0, size = pkt->size, side_data_size = 0;
|
||||
int err = 0, offset = 0, size = pkt->size, side_data_size = 0;
|
||||
int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
|
||||
uint64_t additional_id = 0;
|
||||
int64_t discard_padding = 0;
|
||||
@@ -2074,20 +2075,22 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
|
||||
keyframe != 0);
|
||||
if (par->codec_id == AV_CODEC_ID_H264 && par->extradata_size > 0 &&
|
||||
(AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1))
|
||||
ff_avc_parse_nal_units_buf(pkt->data, &data, &size);
|
||||
err = ff_avc_parse_nal_units_buf(pkt->data, &data, &size);
|
||||
else if (par->codec_id == AV_CODEC_ID_HEVC && par->extradata_size > 6 &&
|
||||
(AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1))
|
||||
/* extradata is Annex B, assume the bitstream is too and convert it */
|
||||
ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL);
|
||||
err = ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL);
|
||||
else if (par->codec_id == AV_CODEC_ID_WAVPACK) {
|
||||
int ret = mkv_strip_wavpack(pkt->data, &data, &size);
|
||||
if (ret < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Error stripping a WavPack packet.\n");
|
||||
return;
|
||||
}
|
||||
err = mkv_strip_wavpack(pkt->data, &data, &size);
|
||||
} else
|
||||
data = pkt->data;
|
||||
|
||||
if (err < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Error when reformatting data of "
|
||||
"a packet from stream %d.\n", pkt->stream_index);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (par->codec_id == AV_CODEC_ID_PRORES && size >= 8) {
|
||||
/* Matroska specification requires to remove the first QuickTime atom
|
||||
*/
|
||||
@@ -2109,9 +2112,13 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
|
||||
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
|
||||
&side_data_size);
|
||||
if (side_data) {
|
||||
additional_id = AV_RB64(side_data);
|
||||
side_data += 8;
|
||||
side_data_size -= 8;
|
||||
if (side_data_size < 8) {
|
||||
side_data_size = 0;
|
||||
} else {
|
||||
additional_id = AV_RB64(side_data);
|
||||
side_data += 8;
|
||||
side_data_size -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
if ((side_data_size && additional_id == 1) || discard_padding) {
|
||||
@@ -2152,6 +2159,8 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
|
||||
if ((side_data_size && additional_id == 1) || discard_padding) {
|
||||
end_ebml_master(pb, block_group);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
|
||||
@@ -2159,17 +2168,19 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p
|
||||
MatroskaMuxContext *mkv = s->priv_data;
|
||||
ebml_master blockgroup;
|
||||
int id_size, settings_size, size;
|
||||
uint8_t *id, *settings;
|
||||
const char *id, *settings;
|
||||
int64_t ts = mkv->tracks[pkt->stream_index].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;
|
||||
|
||||
@@ -2295,7 +2306,9 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_
|
||||
relative_packet_pos = avio_tell(pb);
|
||||
|
||||
if (par->codec_type != AVMEDIA_TYPE_SUBTITLE) {
|
||||
mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe);
|
||||
ret = mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && (par->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) {
|
||||
ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, dash_tracknum, ts, mkv->cluster_pos, relative_packet_pos, -1);
|
||||
if (ret < 0) return ret;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -116,8 +116,10 @@ static int microdvd_read_header(AVFormatContext *s)
|
||||
}
|
||||
if (!st->codecpar->extradata && sscanf(line, "{DEFAULT}{}%c", &c) == 1) {
|
||||
st->codecpar->extradata = av_strdup(line + 11);
|
||||
if (!st->codecpar->extradata)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!st->codecpar->extradata) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
st->codecpar->extradata_size = strlen(st->codecpar->extradata) + 1;
|
||||
continue;
|
||||
}
|
||||
@@ -135,8 +137,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);
|
||||
@@ -153,6 +157,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)
|
||||
|
||||
@@ -77,7 +77,7 @@ static int check_file_header(AVIOContext *pb, uint64_t guid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void read_string(AVFormatContext *avctx, AVIOContext *pb, const char *tag, int size)
|
||||
static void read_string(AVFormatContext *avctx, AVIOContext *pb, const char *tag, unsigned size)
|
||||
{
|
||||
char * value = av_malloc(size + 1);
|
||||
if (!value) {
|
||||
|
||||
+37
-30
@@ -2118,7 +2118,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);
|
||||
@@ -2356,7 +2356,8 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
avio_rb24(pb); /* flags */
|
||||
entries = avio_rb32(pb);
|
||||
|
||||
if (entries <= 0) {
|
||||
/* Each entry contains a size (4 bytes) and format (4 bytes). */
|
||||
if (entries <= 0 || entries > atom.size / 8) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "invalid STSD entries %d\n", entries);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -3953,6 +3954,9 @@ static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
} else
|
||||
break;
|
||||
|
||||
if (*p)
|
||||
break;
|
||||
|
||||
*p = av_malloc(len + 1);
|
||||
if (!*p)
|
||||
break;
|
||||
@@ -5821,10 +5825,9 @@ static int mov_read_close(AVFormatContext *s)
|
||||
av_freep(&sc->spherical);
|
||||
}
|
||||
|
||||
if (mov->dv_demux) {
|
||||
avformat_free_context(mov->dv_fctx);
|
||||
mov->dv_fctx = NULL;
|
||||
}
|
||||
av_freep(&mov->dv_demux);
|
||||
avformat_free_context(mov->dv_fctx);
|
||||
mov->dv_fctx = NULL;
|
||||
|
||||
if (mov->meta_keys) {
|
||||
for (i = 1; i < mov->meta_keys_count; i++) {
|
||||
@@ -6024,14 +6027,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));
|
||||
|
||||
@@ -6084,7 +6086,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 &&
|
||||
@@ -6104,8 +6106,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;
|
||||
}
|
||||
@@ -6120,8 +6122,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;
|
||||
@@ -6145,8 +6147,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:
|
||||
@@ -6154,7 +6155,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;
|
||||
}
|
||||
@@ -6163,7 +6164,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;
|
||||
}
|
||||
@@ -6172,7 +6173,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;
|
||||
}
|
||||
@@ -6182,6 +6183,9 @@ static int mov_read_header(AVFormatContext *s)
|
||||
ff_configure_buffers_for_index(s, AV_TIME_BASE);
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
mov_read_close(s);
|
||||
return err;
|
||||
}
|
||||
|
||||
static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
|
||||
@@ -6340,6 +6344,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#if CONFIG_DV_DEMUXER
|
||||
if (mov->dv_demux && sc->dv_audio_container) {
|
||||
AVBufferRef *buf = pkt->buf;
|
||||
ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);
|
||||
pkt->buf = buf;
|
||||
av_packet_unref(pkt);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = avpriv_dv_get_packet(mov->dv_demux, pkt);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
if (sc->has_palette) {
|
||||
uint8_t *pal;
|
||||
|
||||
@@ -6351,16 +6368,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
sc->has_palette = 0;
|
||||
}
|
||||
}
|
||||
#if CONFIG_DV_DEMUXER
|
||||
if (mov->dv_demux && sc->dv_audio_container) {
|
||||
avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);
|
||||
av_freep(&pkt->data);
|
||||
pkt->size = 0;
|
||||
ret = avpriv_dv_get_packet(mov->dv_demux, pkt);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) {
|
||||
if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0)
|
||||
st->need_parsing = AVSTREAM_PARSE_FULL;
|
||||
|
||||
@@ -4180,7 +4180,8 @@ static int mov_write_sidx_tag(AVIOContext *pb,
|
||||
{
|
||||
int64_t pos = avio_tell(pb), offset_pos, end_pos;
|
||||
int64_t presentation_time, duration, offset;
|
||||
int starts_with_SAP, i, entries;
|
||||
unsigned starts_with_SAP;
|
||||
int i, entries;
|
||||
|
||||
if (track->entry) {
|
||||
entries = 1;
|
||||
|
||||
@@ -108,8 +108,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;
|
||||
|
||||
@@ -97,8 +97,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;
|
||||
|
||||
@@ -176,6 +176,7 @@ typedef struct NSVContext {
|
||||
int16_t avsync;
|
||||
AVRational framerate;
|
||||
uint32_t *nsvs_timestamps;
|
||||
int nsvf;
|
||||
} NSVContext;
|
||||
|
||||
static const AVCodecTag nsv_codec_video_tags[] = {
|
||||
@@ -266,6 +267,12 @@ static int nsv_parse_NSVf_header(AVFormatContext *s)
|
||||
|
||||
nsv->state = NSV_UNSYNC; /* in case we fail */
|
||||
|
||||
if (nsv->nsvf) {
|
||||
av_log(s, AV_LOG_TRACE, "Multiple NSVf\n");
|
||||
return 0;
|
||||
}
|
||||
nsv->nsvf = 1;
|
||||
|
||||
size = avio_rl32(pb);
|
||||
if (size < 28)
|
||||
return -1;
|
||||
|
||||
+28
-16
@@ -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)
|
||||
{
|
||||
@@ -398,11 +405,14 @@ static int oma_read_header(AVFormatContext *s)
|
||||
|
||||
ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta, 0);
|
||||
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;
|
||||
}
|
||||
@@ -421,8 +431,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;
|
||||
@@ -437,7 +449,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);
|
||||
@@ -454,8 +467,8 @@ static int oma_read_header(AVFormatContext *s)
|
||||
|
||||
/* fake the ATRAC3 extradata
|
||||
* (wav format, makes stream copy to wav work) */
|
||||
if (ff_alloc_extradata(st->codecpar, 14))
|
||||
return AVERROR(ENOMEM);
|
||||
if ((ret = ff_alloc_extradata(st->codecpar, 14)) < 0)
|
||||
goto fail;
|
||||
|
||||
edata = st->codecpar->extradata;
|
||||
AV_WL16(&edata[0], 1); // always 1
|
||||
@@ -472,7 +485,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];
|
||||
@@ -480,7 +494,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);
|
||||
@@ -520,12 +535,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)
|
||||
@@ -587,13 +606,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"),
|
||||
|
||||
@@ -92,8 +92,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;
|
||||
|
||||
@@ -1270,6 +1270,8 @@ static int ivr_read_header(AVFormatContext *s)
|
||||
if (avio_rb32(pb) == MKBETAG('M', 'L', 'T', 'I')) {
|
||||
ret = rm_read_multi(s, pb, st, NULL);
|
||||
} else {
|
||||
if (avio_feof(pb))
|
||||
return AVERROR_INVALIDDATA;
|
||||
avio_seek(pb, -4, SEEK_CUR);
|
||||
ret = ff_rm_read_mdpr_codecdata(s, pb, st, st->priv_data, len, NULL);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ static int scc_read_header(AVFormatContext *s)
|
||||
|
||||
sub = ff_subtitles_queue_insert(&scc->q, out, i, 0);
|
||||
if (!sub)
|
||||
return AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
|
||||
sub->pos = pos;
|
||||
sub->pts = ts_start;
|
||||
@@ -144,6 +144,9 @@ static int scc_read_header(AVFormatContext *s)
|
||||
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)
|
||||
|
||||
@@ -331,12 +331,11 @@ static int ism_write_header(AVFormatContext *s)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctx = avformat_alloc_context();
|
||||
os->ctx = ctx = avformat_alloc_context();
|
||||
if (!ctx || ff_copy_whiteblacklists(ctx, s) < 0) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
os->ctx = ctx;
|
||||
ctx->oformat = oformat;
|
||||
ctx->interrupt_callback = s->interrupt_callback;
|
||||
|
||||
@@ -356,12 +355,13 @@ static int ism_write_header(AVFormatContext *s)
|
||||
|
||||
av_dict_set_int(&opts, "ism_lookahead", c->lookahead_count, 0);
|
||||
av_dict_set(&opts, "movflags", "frag_custom", 0);
|
||||
if ((ret = avformat_write_header(ctx, &opts)) < 0) {
|
||||
ret = avformat_write_header(ctx, &opts);
|
||||
av_dict_free(&opts);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
os->ctx_inited = 1;
|
||||
avio_flush(ctx->pb);
|
||||
av_dict_free(&opts);
|
||||
s->streams[i]->time_base = st->time_base;
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
c->has_video = 1;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -132,9 +132,10 @@ AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q,
|
||||
if (!subs)
|
||||
return NULL;
|
||||
q->subs = subs;
|
||||
sub = &subs[q->nb_subs++];
|
||||
sub = &subs[q->nb_subs];
|
||||
if (av_new_packet(sub, len) < 0)
|
||||
return NULL;
|
||||
q->nb_subs++;
|
||||
sub->flags |= AV_PKT_FLAG_KEY;
|
||||
sub->pts = sub->dts = 0;
|
||||
memcpy(sub->data, event, len);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -156,6 +156,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);
|
||||
|
||||
+13
-7
@@ -604,22 +604,24 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
|
||||
level = AV_LOG_ERROR;
|
||||
av_log(s, level, "Discarding ID3 tags because more suitable tags were found.\n");
|
||||
av_dict_free(&s->internal->id3v2_meta);
|
||||
if (s->error_recognition & AV_EF_EXPLODE)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (s->error_recognition & AV_EF_EXPLODE) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto close;
|
||||
}
|
||||
}
|
||||
|
||||
if (id3v2_extra_meta) {
|
||||
if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
|
||||
!strcmp(s->iformat->name, "tta")) {
|
||||
if ((ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0)
|
||||
goto fail;
|
||||
goto close;
|
||||
} else
|
||||
av_log(s, AV_LOG_DEBUG, "demuxer does not support additional id3 data, skipping\n");
|
||||
}
|
||||
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
|
||||
|
||||
if ((ret = avformat_queue_attached_pictures(s)) < 0)
|
||||
goto fail;
|
||||
goto close;
|
||||
|
||||
if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
|
||||
s->internal->data_offset = avio_tell(s->pb);
|
||||
@@ -638,6 +640,9 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
|
||||
*ps = s;
|
||||
return 0;
|
||||
|
||||
close:
|
||||
if (s->iformat->read_close)
|
||||
s->iformat->read_close(s);
|
||||
fail:
|
||||
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
|
||||
av_dict_free(&tmp);
|
||||
@@ -1311,7 +1316,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
|
||||
|
||||
/* This is tricky: the dts must be incremented by the duration
|
||||
* of the frame we are displaying, i.e. the last I- or P-frame. */
|
||||
if (st->last_IP_duration == 0)
|
||||
if (st->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX)
|
||||
st->last_IP_duration = pkt->duration;
|
||||
if (pkt->dts != AV_NOPTS_VALUE)
|
||||
st->cur_dts = pkt->dts + st->last_IP_duration;
|
||||
@@ -1323,7 +1328,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
|
||||
next_pts != AV_NOPTS_VALUE)
|
||||
pkt->pts = next_dts;
|
||||
|
||||
st->last_IP_duration = pkt->duration;
|
||||
if ((uint64_t)pkt->duration <= INT32_MAX)
|
||||
st->last_IP_duration = pkt->duration;
|
||||
st->last_IP_pts = pkt->pts;
|
||||
/* Cannot compute PTS if not present (we can compute it only
|
||||
* by knowing the future. */
|
||||
@@ -3622,7 +3628,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
* sequence, we treat it as a discontinuity. */
|
||||
if (st->info->fps_last_dts != AV_NOPTS_VALUE &&
|
||||
st->info->fps_last_dts_idx > st->info->fps_first_dts_idx &&
|
||||
(pkt->dts - st->info->fps_last_dts) / 1000 >
|
||||
(pkt->dts - (uint64_t)st->info->fps_last_dts) / 1000 >
|
||||
(st->info->fps_last_dts - (uint64_t)st->info->fps_first_dts) /
|
||||
(st->info->fps_last_dts_idx - st->info->fps_first_dts_idx)) {
|
||||
av_log(ic, AV_LOG_WARNING,
|
||||
|
||||
@@ -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;
|
||||
|
||||
+23
-21
@@ -162,7 +162,7 @@ static int chunk_start(AVFormatContext *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int chunk_end(AVFormatContext *s)
|
||||
static int chunk_end(AVFormatContext *s, int flush)
|
||||
{
|
||||
WebMChunkContext *wc = s->priv_data;
|
||||
AVFormatContext *oc = wc->avf;
|
||||
@@ -173,11 +173,14 @@ static int chunk_end(AVFormatContext *s)
|
||||
char filename[MAX_FILENAME_SIZE];
|
||||
AVDictionary *options = NULL;
|
||||
|
||||
if (wc->chunk_start_index == wc->chunk_index)
|
||||
if (!oc->pb)
|
||||
return 0;
|
||||
// Flush the cluster in WebM muxer.
|
||||
oc->oformat->write_packet(oc, NULL);
|
||||
|
||||
if (flush)
|
||||
// Flush the cluster in WebM muxer.
|
||||
oc->oformat->write_packet(oc, NULL);
|
||||
buffer_size = avio_close_dyn_buf(oc->pb, &buffer);
|
||||
oc->pb = NULL;
|
||||
ret = get_chunk_filename(s, 0, filename);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
@@ -188,7 +191,6 @@ static int chunk_end(AVFormatContext *s)
|
||||
goto fail;
|
||||
avio_write(pb, buffer, buffer_size);
|
||||
ff_format_io_close(s, &pb);
|
||||
oc->pb = NULL;
|
||||
fail:
|
||||
av_dict_free(&options);
|
||||
av_free(buffer);
|
||||
@@ -210,27 +212,19 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
|
||||
// For video, a new chunk is started only on key frames. For audio, a new
|
||||
// chunk is started based on chunk_duration.
|
||||
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
// chunk is started based on chunk_duration. Also, a new chunk is started
|
||||
// unconditionally if there is no currently open chunk.
|
||||
if (!oc->pb || (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
(pkt->flags & AV_PKT_FLAG_KEY)) ||
|
||||
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
(pkt->pts == 0 || wc->duration_written >= wc->chunk_duration))) {
|
||||
wc->duration_written >= wc->chunk_duration)) {
|
||||
wc->duration_written = 0;
|
||||
if ((ret = chunk_end(s)) < 0 || (ret = chunk_start(s)) < 0) {
|
||||
goto fail;
|
||||
if ((ret = chunk_end(s, 1)) < 0 || (ret = chunk_start(s)) < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = oc->oformat->write_packet(oc, pkt);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
fail:
|
||||
if (ret < 0) {
|
||||
oc->streams = NULL;
|
||||
oc->nb_streams = 0;
|
||||
avformat_free_context(oc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -239,12 +233,20 @@ static int webm_chunk_write_trailer(AVFormatContext *s)
|
||||
{
|
||||
WebMChunkContext *wc = s->priv_data;
|
||||
AVFormatContext *oc = wc->avf;
|
||||
int ret;
|
||||
|
||||
if (!oc->pb) {
|
||||
ret = chunk_start(s);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
oc->oformat->write_trailer(oc);
|
||||
chunk_end(s);
|
||||
ret = chunk_end(s, 0);
|
||||
fail:
|
||||
oc->streams = NULL;
|
||||
oc->nb_streams = 0;
|
||||
avformat_free_context(oc);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(WebMChunkContext, x)
|
||||
|
||||
@@ -456,11 +456,12 @@ static int parse_adaptation_sets(AVFormatContext *s)
|
||||
state = parsing_streams;
|
||||
} else if (state == parsing_streams) {
|
||||
struct AdaptationSet *as = &w->as[w->nb_as - 1];
|
||||
int ret = av_reallocp_array(&as->streams, ++as->nb_streams,
|
||||
sizeof(*as->streams));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
q = p;
|
||||
while (*q != '\0' && *q != ',' && *q != ' ') q++;
|
||||
as->streams = av_realloc(as->streams, sizeof(*as->streams) * ++as->nb_streams);
|
||||
if (as->streams == NULL)
|
||||
return AVERROR(ENOMEM);
|
||||
as->streams[as->nb_streams - 1] = to_integer(p, q - p + 1);
|
||||
if (as->streams[as->nb_streams - 1] < 0 ||
|
||||
as->streams[as->nb_streams - 1] >= s->nb_streams) {
|
||||
@@ -483,6 +484,14 @@ static int webm_dash_manifest_write_header(AVFormatContext *s)
|
||||
double start = 0.0;
|
||||
int ret;
|
||||
WebMDashMuxContext *w = s->priv_data;
|
||||
|
||||
for (unsigned i = 0; i < s->nb_streams; i++) {
|
||||
enum AVCodecID codec_id = s->streams[i]->codecpar->codec_id;
|
||||
if (codec_id != AV_CODEC_ID_VP8 && codec_id != AV_CODEC_ID_VP9 &&
|
||||
codec_id != AV_CODEC_ID_VORBIS && codec_id != AV_CODEC_ID_OPUS)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = parse_adaptation_sets(s);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
|
||||
@@ -165,6 +165,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);
|
||||
av_bprint_finalize(&header, NULL);
|
||||
return res;
|
||||
|
||||
@@ -992,8 +992,10 @@ static int read_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
ret = parse_chunks(s, SEEK_TO_DATA, 0, 0);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
wtvfile_close(wtv->pb);
|
||||
return ret;
|
||||
}
|
||||
avio_seek(wtv->pb, -32, SEEK_CUR);
|
||||
|
||||
timeline_pos = avio_tell(s->pb); // save before opening another file
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ AVInteger av_mul_i(AVInteger a, AVInteger b){
|
||||
|
||||
if(a.v[i])
|
||||
for(j=i; j<AV_INTEGER_SIZE && j-i<=nb; j++){
|
||||
carry= (carry>>16) + out.v[j] + a.v[i]*b.v[j-i];
|
||||
carry= (carry>>16) + out.v[j] + a.v[i]*(unsigned)b.v[j-i];
|
||||
out.v[j]= carry;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -338,7 +338,7 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||
* @warning Unlike av_malloc(), the allocated memory is not guaranteed to be
|
||||
* correctly aligned.
|
||||
*/
|
||||
av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size);
|
||||
int av_reallocp_array(void *ptr, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* Reallocate the given buffer if it is not large enough, otherwise do nothing.
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
* This is stored as BGRA on little-endian CPU architectures and ARGB on
|
||||
* big-endian CPUs.
|
||||
*
|
||||
* @note
|
||||
* If the resolution is not a multiple of the chroma subsampling factor
|
||||
* then the chroma plane resolution must be rounded up.
|
||||
*
|
||||
* @par
|
||||
* When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized
|
||||
* image data is stored in AVFrame.data[0]. The palette is transported in
|
||||
|
||||
@@ -318,7 +318,7 @@ av_cold int swr_init(struct SwrContext *s){
|
||||
|
||||
av_assert0(s->used_ch_count);
|
||||
av_assert0(s->out.ch_count);
|
||||
s->resample_first= RSC*s->out.ch_count/s->in.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_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;
|
||||
|
||||
s->in_buffer= s->in;
|
||||
s->silence = s->in;
|
||||
|
||||
+1
-1
@@ -378,7 +378,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
|
||||
(*filterPos)[i] = xx;
|
||||
// bilinear upscale / linear interpolate / area averaging
|
||||
for (j = 0; j < filterSize; j++) {
|
||||
int64_t coeff= fone - FFABS(((int64_t)xx<<16) - xDstInSrc)*(fone>>16);
|
||||
int64_t coeff = fone - FFABS((int64_t)xx * (1 << 16) - xDstInSrc) * (fone >> 16);
|
||||
if (coeff < 0)
|
||||
coeff = 0;
|
||||
filter[i * filterSize + j] = coeff;
|
||||
|
||||
@@ -160,7 +160,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB
|
||||
*(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
|
||||
lumMmxFilter[s*i+APCK_COEF/4 ]=
|
||||
lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
|
||||
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
|
||||
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1] * (1 << 16) : 0);
|
||||
if (CONFIG_SWSCALE_ALPHA && hasAlpha) {
|
||||
*(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
|
||||
*(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
|
||||
@@ -173,7 +173,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB
|
||||
*(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
|
||||
chrMmxFilter[s*i+APCK_COEF/4 ]=
|
||||
chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
|
||||
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
|
||||
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1] * (1 << 16) : 0);
|
||||
}
|
||||
} else {
|
||||
for (i=0; i<vLumFilterSize; i++) {
|
||||
|
||||
Reference in New Issue
Block a user