Compare commits
70 Commits
n3.3.9
...
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 |
@@ -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);
|
||||
|
||||
+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;
|
||||
|
||||
+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)
|
||||
|
||||
+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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+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]++));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
+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; \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
+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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
+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)
|
||||
|
||||
+35
-29
@@ -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);
|
||||
@@ -3954,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;
|
||||
@@ -5822,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++) {
|
||||
@@ -6025,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));
|
||||
|
||||
@@ -6085,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 &&
|
||||
@@ -6105,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;
|
||||
}
|
||||
@@ -6121,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;
|
||||
@@ -6146,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:
|
||||
@@ -6155,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;
|
||||
}
|
||||
@@ -6164,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;
|
||||
}
|
||||
@@ -6173,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;
|
||||
}
|
||||
@@ -6183,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)
|
||||
@@ -6341,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;
|
||||
|
||||
@@ -6352,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;
|
||||
|
||||
+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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+9
-4
@@ -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);
|
||||
|
||||
@@ -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
@@ -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.
|
||||
|
||||
+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