New upstream version 2.8.9
Andreas Cadhalpun
7 years ago
0 | 0 | Entries are sorted chronologically from oldest to youngest within each release, |
1 | 1 | releases are sorted from youngest to oldest. |
2 | ||
3 | version 2.8.9 | |
4 | - avcodec/flacdec: Fix undefined shift in decode_subframe() | |
5 | - avcodec/get_bits: Fix get_sbits_long(0) | |
6 | - avformat/ffmdec: Check media type for chunks | |
7 | - avcodec/flacdec: Fix signed integer overflow in decode_subframe_fixed() | |
8 | - avcodec/flacdsp_template: Fix undefined shift in flac_decorrelate_indep_c | |
9 | - avformat/oggparsespeex: Check frames_per_packet and packet_size | |
10 | - avformat/utils: Check start/end before computing duration in update_stream_timings() | |
11 | - avcodec/flac_parser: Update nb_headers_buffered | |
12 | - avformat/idroqdec: Check chunk_size for being too large | |
13 | - filmstripdec: correctly check image dimensions | |
14 | - mss2: only use error correction for matching block counts | |
15 | - softfloat: decrease MIN_EXP to cover full float range | |
16 | - libopusdec: default to stereo for invalid number of channels | |
17 | - sbgdec: prevent NULL pointer access | |
18 | - smacker: limit recursion depth of smacker_decode_bigtree | |
19 | - mxfdec: fix NULL pointer dereference in mxf_read_packet_old | |
20 | - libschroedingerdec: fix leaking of framewithpts | |
21 | - libschroedingerdec: don't produce empty frames | |
22 | - softfloat: handle -INT_MAX correctly | |
23 | - pnmdec: make sure v is capped by maxval | |
24 | - smvjpegdec: make sure cur_frame is not negative | |
25 | - icodec: correctly check avio_read return value | |
26 | - icodec: fix leaking pkt on error | |
27 | - dvbsubdec: fix division by zero in compute_default_clut | |
28 | - proresdec_lgpl: explicitly check coff[3] against slice_data_size | |
29 | - escape124: reject codebook size 0 | |
30 | - mpegts: prevent division by zero | |
31 | - matroskadec: fix NULL pointer dereference in webm_dash_manifest_read_header | |
32 | - mpegaudio_parser: don't return AVERROR_PATCHWELCOME | |
33 | - mxfdec: fix NULL pointer dereference | |
34 | - diracdec: check return code of get_buffer_with_edge | |
35 | - ppc: pixblockdsp: do unaligned block accesses correctly again | |
36 | - mpeg12dec: unref discarded picture from extradata | |
37 | - cavsdec: unref frame before referencing again | |
38 | - avformat: prevent triggering request_probe assert in ff_read_packet | |
39 | - avformat/mpeg: Adjust vid probe threshold to correct mis-detection | |
40 | - avcodec/rv40: Test remaining space in loop of get_dimension() | |
41 | - avcodec/ituh263dec: Avoid spending a long time in slice sync | |
42 | - avcodec/movtextdec: Add error message for tsmb_size check | |
43 | - avcodec/movtextdec: Fix tsmb_size check==0 check | |
44 | - avcodec/movtextdec: Fix potential integer overflow | |
45 | - avcodec/sunrast: Fix input buffer pointer check | |
46 | - avcodec/tscc: Check side data size before use | |
47 | - avcodec/rawdec: Check side data size before use | |
48 | - avcodec/msvideo1: Check side data size before use | |
49 | - avcodec/qpeg: Check side data size before use | |
50 | - avcodec/qtrle: Check side data size before use | |
51 | - avcodec/msrle: Check side data size before use | |
52 | - avcodec/kmvc: Check side data size before use | |
53 | - avcodec/idcinvideo: Check side data size before use | |
54 | - avcodec/cinepak: Check side data size before use | |
55 | - avcodec/8bps: Check side data size before use | |
56 | - avcodec/dvdsubdec: Fix off by 1 error | |
57 | - avcodec/dvdsubdec: Fix buf_size check | |
58 | - vp9: change order of operations in adapt_prob(). | |
59 | - avcodec/interplayvideo: Check side data size before use | |
60 | - avformat/mxfdec: Check size to avoid integer overflow in mxf_read_utf16_string() | |
61 | - avcodec/mpegvideo_enc: Clear mmx state in ff_mpv_reallocate_putbitbuffer() | |
62 | - avcodec/utils: Clear MMX state before returning from avcodec_default_execute*() | |
63 | - cmdutils: fix typos | |
64 | - lavfi: fix typos | |
65 | - lavc: fix typos | |
66 | - tools: fix grammar error | |
67 | - avutil/mips/generic_macros_msa: rename macro variable which causes segfault for mips r6 | |
68 | - videodsp: fix 1-byte overread in top/bottom READ_NUM_BYTES iterations. | |
69 | - avformat/avidec: Check nb_streams in read_gab2_sub() | |
70 | - avformat/avidec: Remove ancient assert | |
71 | - lavc/movtextdec.c: Avoid infinite loop on invalid data. | |
72 | - avcodec/ansi: Check dimensions | |
73 | - avcodec/cavsdsp: use av_clip_uint8() for idct | |
2 | 74 | |
3 | 75 | version 2.8.8 |
4 | 76 | - avformat/movenc: Check packet in mov_write_single_packet() too |
2074 | 2074 | if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) |
2075 | 2075 | return AVERROR(EINVAL); |
2076 | 2076 | |
2077 | printf("Audo-detected sources for %s:\n", fmt->name); | |
2077 | printf("Auto-detected sources for %s:\n", fmt->name); | |
2078 | 2078 | if (!fmt->get_device_list) { |
2079 | 2079 | ret = AVERROR(ENOSYS); |
2080 | 2080 | printf("Cannot list sources. Not implemented.\n"); |
2104 | 2104 | if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) |
2105 | 2105 | return AVERROR(EINVAL); |
2106 | 2106 | |
2107 | printf("Audo-detected sinks for %s:\n", fmt->name); | |
2107 | printf("Auto-detected sinks for %s:\n", fmt->name); | |
2108 | 2108 | if (!fmt->get_device_list) { |
2109 | 2109 | ret = AVERROR(ENOSYS); |
2110 | 2110 | printf("Cannot list sinks. Not implemented.\n"); |
449 | 449 | |
450 | 450 | #if CONFIG_AVDEVICE |
451 | 451 | /** |
452 | * Print a listing containing audodetected sinks of the output device. | |
452 | * Print a listing containing autodetected sinks of the output device. | |
453 | 453 | * Device name with options may be passed as an argument to limit results. |
454 | 454 | */ |
455 | 455 | int show_sinks(void *optctx, const char *opt, const char *arg); |
456 | 456 | |
457 | 457 | /** |
458 | * Print a listing containing audodetected sources of the input device. | |
458 | * Print a listing containing autodetected sources of the input device. | |
459 | 459 | * Device name with options may be passed as an argument to limit results. |
460 | 460 | */ |
461 | 461 | int show_sources(void *optctx, const char *opt, const char *arg); |
30 | 30 | # This could be handy for archiving the generated documentation or |
31 | 31 | # if some version control system is used. |
32 | 32 | |
33 | PROJECT_NUMBER = 2.8.8 | |
33 | PROJECT_NUMBER = 2.8.9 | |
34 | 34 | |
35 | 35 | # With the PROJECT_LOGO tag one can specify a logo or icon that is included |
36 | 36 | # in the documentation. The maximum height of the logo should not exceed 55 |
119 | 119 | } |
120 | 120 | |
121 | 121 | if (avctx->bits_per_coded_sample <= 8) { |
122 | int size; | |
122 | 123 | const uint8_t *pal = av_packet_get_side_data(avpkt, |
123 | 124 | AV_PKT_DATA_PALETTE, |
124 | NULL); | |
125 | if (pal) { | |
125 | &size); | |
126 | if (pal && size == AVPALETTE_SIZE) { | |
126 | 127 | frame->palette_has_changed = 1; |
127 | 128 | memcpy(c->pal, pal, AVPALETTE_SIZE); |
129 | } else if (pal) { | |
130 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); | |
128 | 131 | } |
129 | 132 | |
130 | 133 | memcpy (frame->data[1], c->pal, AVPALETTE_SIZE); |
93 | 93 | int ret = ff_set_dimensions(avctx, 80 << 3, 25 << 4); |
94 | 94 | if (ret < 0) |
95 | 95 | return ret; |
96 | } else if (avctx->width % FONT_WIDTH || avctx->height % s->font_height) { | |
97 | av_log(avctx, AV_LOG_ERROR, "Invalid dimensions %d %d\n", avctx->width, avctx->height); | |
98 | return AVERROR(EINVAL); | |
96 | 99 | } |
97 | 100 | return 0; |
98 | 101 | } |
60 | 60 | } else { |
61 | 61 | put_bits(pb, ff_asv2_level_tab[31][1], ff_asv2_level_tab[31][0]); |
62 | 62 | if (level < -128 || level > 127) { |
63 | av_log(a->avctx, AV_LOG_WARNING, "Cliping level %d, increase qscale\n", level); | |
63 | av_log(a->avctx, AV_LOG_WARNING, "Clipping level %d, increase qscale\n", level); | |
64 | 64 | level = av_clip_int8(level); |
65 | 65 | } |
66 | 66 | asv2_put_bits(pb, 8, level & 0xFF); |
1217 | 1217 | h->got_keyframe = 1; |
1218 | 1218 | } |
1219 | 1219 | case PIC_PB_START_CODE: |
1220 | if (*got_frame) | |
1221 | av_frame_unref(data); | |
1220 | 1222 | *got_frame = 0; |
1221 | 1223 | if (!h->got_keyframe) |
1222 | 1224 | break; |
187 | 187 | static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) { |
188 | 188 | int i; |
189 | 189 | int16_t (*src)[8] = (int16_t(*)[8])block; |
190 | const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; | |
191 | 190 | |
192 | 191 | src[0][0] += 8; |
193 | 192 | |
242 | 241 | const int b2 = a5 - a7; |
243 | 242 | const int b3 = a4 - a6; |
244 | 243 | |
245 | dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4) >> 7)]; | |
246 | dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5) >> 7)]; | |
247 | dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6) >> 7)]; | |
248 | dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7) >> 7)]; | |
249 | dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7) >> 7)]; | |
250 | dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6) >> 7)]; | |
251 | dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5) >> 7)]; | |
252 | dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4) >> 7)]; | |
244 | dst[i + 0*stride] = av_clip_uint8( dst[i + 0*stride] + ((b0 + b4) >> 7)); | |
245 | dst[i + 1*stride] = av_clip_uint8( dst[i + 1*stride] + ((b1 + b5) >> 7)); | |
246 | dst[i + 2*stride] = av_clip_uint8( dst[i + 2*stride] + ((b2 + b6) >> 7)); | |
247 | dst[i + 3*stride] = av_clip_uint8( dst[i + 3*stride] + ((b3 + b7) >> 7)); | |
248 | dst[i + 4*stride] = av_clip_uint8( dst[i + 4*stride] + ((b3 - b7) >> 7)); | |
249 | dst[i + 5*stride] = av_clip_uint8( dst[i + 5*stride] + ((b2 - b6) >> 7)); | |
250 | dst[i + 6*stride] = av_clip_uint8( dst[i + 6*stride] + ((b1 - b5) >> 7)); | |
251 | dst[i + 7*stride] = av_clip_uint8( dst[i + 7*stride] + ((b0 - b4) >> 7)); | |
253 | 252 | } |
254 | 253 | } |
255 | 254 |
442 | 442 | return ret; |
443 | 443 | |
444 | 444 | if (s->palette_video) { |
445 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
446 | if (pal) { | |
445 | int size; | |
446 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); | |
447 | if (pal && size == AVPALETTE_SIZE) { | |
447 | 448 | s->frame->palette_has_changed = 1; |
448 | 449 | memcpy(s->pal, pal, AVPALETTE_SIZE); |
450 | } else if (pal) { | |
451 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); | |
449 | 452 | } |
450 | 453 | } |
451 | 454 |
1766 | 1766 | for (j = 0; j < MAX_FRAMES; j++) |
1767 | 1767 | if (!s->all_frames[j].avframe->data[0]) { |
1768 | 1768 | s->ref_pics[i] = &s->all_frames[j]; |
1769 | get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF); | |
1769 | ret = get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF); | |
1770 | if (ret < 0) | |
1771 | return ret; | |
1770 | 1772 | break; |
1771 | 1773 | } |
1772 | 1774 |
809 | 809 | list_inv[ i ] = bestv; |
810 | 810 | } |
811 | 811 | |
812 | count = i - 1; | |
812 | count = FFMAX(i - 1, 1); | |
813 | 813 | for (i--; i>=0; i--) { |
814 | 814 | int v = i*255/count; |
815 | 815 | AV_WN32(frame->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v)); |
184 | 184 | for(i = 0; i < 4; i++) { |
185 | 185 | if (alpha[i] != 0) { |
186 | 186 | if (!color_used[colormap[i]]) { |
187 | level = level_map[nb_opaque_colors][j]; | |
187 | level = level_map[nb_opaque_colors - 1][j]; | |
188 | 188 | r = (((subtitle_color >> 16) & 0xff) * level) >> 8; |
189 | 189 | g = (((subtitle_color >> 8) & 0xff) * level) >> 8; |
190 | 190 | b = (((subtitle_color >> 0) & 0xff) * level) >> 8; |
515 | 515 | { |
516 | 516 | DVDSubContext *ctx = avctx->priv_data; |
517 | 517 | |
518 | if (ctx->buf_size >= sizeof(ctx->buf) - buf_size) { | |
518 | av_assert0(buf_size >= 0 && ctx->buf_size <= sizeof(ctx->buf)); | |
519 | if (buf_size >= sizeof(ctx->buf) - ctx->buf_size) { | |
519 | 520 | av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct " |
520 | 521 | "too large SPU packets aborted.\n"); |
521 | 522 | ctx->buf_size = 0; |
249 | 249 | // This codebook can be cut off at places other than |
250 | 250 | // powers of 2, leaving some of the entries undefined. |
251 | 251 | cb_size = get_bits_long(&gb, 20); |
252 | if (!cb_size) { | |
253 | av_log(avctx, AV_LOG_ERROR, "Invalid codebook size 0.\n"); | |
254 | return AVERROR_INVALIDDATA; | |
255 | } | |
252 | 256 | cb_depth = av_log2(cb_size - 1) + 1; |
253 | 257 | } else { |
254 | 258 | cb_depth = get_bits(&gb, 4); |
585 | 585 | temp = curr->next; |
586 | 586 | av_freep(&curr->link_penalty); |
587 | 587 | av_free(curr); |
588 | fpc->nb_headers_buffered--; | |
588 | 589 | } |
589 | 590 | fpc->headers = fpc->best_header->next; |
590 | 591 | av_freep(&fpc->best_header->link_penalty); |
591 | 592 | av_freep(&fpc->best_header); |
593 | fpc->nb_headers_buffered--; | |
592 | 594 | } |
593 | 595 | |
594 | 596 | /* Find and score new headers. */ |
267 | 267 | int pred_order, int bps) |
268 | 268 | { |
269 | 269 | const int blocksize = s->blocksize; |
270 | int av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d), i; | |
270 | unsigned av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d); | |
271 | int i; | |
271 | 272 | int ret; |
272 | 273 | |
273 | 274 | /* warm up samples */ |
446 | 447 | if (wasted) { |
447 | 448 | int i; |
448 | 449 | for (i = 0; i < s->blocksize; i++) |
449 | decoded[i] <<= wasted; | |
450 | decoded[i] = (unsigned)decoded[i] << wasted; | |
450 | 451 | } |
451 | 452 | |
452 | 453 | return 0; |
55 | 55 | |
56 | 56 | for (j = 0; j < len; j++) |
57 | 57 | for (i = 0; i < channels; i++) |
58 | S(samples, i, j) = in[i][j] << shift; | |
58 | S(samples, i, j) = (int)((unsigned)in[i][j] << shift); | |
59 | 59 | } |
60 | 60 | |
61 | 61 | static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in, |
373 | 373 | */ |
374 | 374 | static inline int get_sbits_long(GetBitContext *s, int n) |
375 | 375 | { |
376 | // sign_extend(x, 0) is undefined | |
377 | if (!n) | |
378 | return 0; | |
379 | ||
376 | 380 | return sign_extend(get_bits_long(s, n), n); |
377 | 381 | } |
378 | 382 |
213 | 213 | const uint8_t *buf = avpkt->data; |
214 | 214 | int buf_size = avpkt->size; |
215 | 215 | IdcinContext *s = avctx->priv_data; |
216 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
216 | int pal_size; | |
217 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); | |
217 | 218 | AVFrame *frame = data; |
218 | 219 | int ret; |
219 | 220 | |
226 | 227 | if (idcin_decode_vlcs(s, frame)) |
227 | 228 | return AVERROR_INVALIDDATA; |
228 | 229 | |
229 | if (pal) { | |
230 | if (pal && pal_size == AVPALETTE_SIZE) { | |
230 | 231 | frame->palette_has_changed = 1; |
231 | 232 | memcpy(s->pal, pal, AVPALETTE_SIZE); |
233 | } else if (pal) { | |
234 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size); | |
232 | 235 | } |
233 | 236 | /* make the palette available on the way out */ |
234 | 237 | memcpy(frame->data[1], s->pal, AVPALETTE_SIZE); |
1011 | 1011 | return ret; |
1012 | 1012 | |
1013 | 1013 | if (!s->is_16bpp) { |
1014 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
1015 | if (pal) { | |
1014 | int size; | |
1015 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); | |
1016 | if (pal && size == AVPALETTE_SIZE) { | |
1016 | 1017 | frame->palette_has_changed = 1; |
1017 | 1018 | memcpy(s->pal, pal, AVPALETTE_SIZE); |
1019 | } else if (pal) { | |
1020 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); | |
1018 | 1021 | } |
1019 | 1022 | } |
1020 | 1023 |
166 | 166 | /* We have a GBSC probably with GSTUFF */ |
167 | 167 | skip_bits(&s->gb, 16); /* Drop the zeros */ |
168 | 168 | left= get_bits_left(&s->gb); |
169 | left = FFMIN(left, 32); | |
169 | 170 | //MN: we must check the bits left or we might end in a infinite loop (or segfault) |
170 | 171 | for(;left>13; left--){ |
171 | 172 | if(get_bits1(&s->gb)) break; /* Seek the '1' bit */ |
267 | 267 | int i, ret; |
268 | 268 | int header; |
269 | 269 | int blocksize; |
270 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
270 | int pal_size; | |
271 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); | |
271 | 272 | |
272 | 273 | bytestream2_init(&ctx->g, avpkt->data, avpkt->size); |
273 | 274 | |
302 | 303 | } |
303 | 304 | } |
304 | 305 | |
305 | if (pal) { | |
306 | if (pal && pal_size == AVPALETTE_SIZE) { | |
306 | 307 | frame->palette_has_changed = 1; |
307 | 308 | memcpy(ctx->pal, pal, AVPALETTE_SIZE); |
309 | } else if (pal) { | |
310 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size); | |
308 | 311 | } |
309 | 312 | |
310 | 313 | if (ctx->setpal) { |
44 | 44 | struct libopus_context *opus = avc->priv_data; |
45 | 45 | int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled; |
46 | 46 | uint8_t mapping_arr[8] = { 0, 1 }, *mapping; |
47 | ||
48 | avc->channels = avc->extradata_size >= 10 ? avc->extradata[9] : (avc->channels == 1) ? 1 : 2; | |
49 | if (avc->channels <= 0) { | |
50 | av_log(avc, AV_LOG_WARNING, | |
51 | "Invalid number of channels %d, defaulting to stereo\n", avc->channels); | |
52 | avc->channels = 2; | |
53 | } | |
47 | 54 | |
48 | 55 | avc->sample_rate = 48000; |
49 | 56 | avc->sample_fmt = avc->request_sample_fmt == AV_SAMPLE_FMT_FLT ? |
217 | 217 | int outer = 1; |
218 | 218 | SchroParseUnitContext parse_ctx; |
219 | 219 | LibSchroFrameContext *framewithpts = NULL; |
220 | int ret; | |
220 | 221 | |
221 | 222 | *got_frame = 0; |
222 | 223 | |
306 | 307 | /* Grab next frame to be returned from the top of the queue. */ |
307 | 308 | framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue); |
308 | 309 | |
309 | if (framewithpts && framewithpts->frame) { | |
310 | int ret; | |
310 | if (framewithpts && framewithpts->frame && framewithpts->frame->components[0].stride) { | |
311 | 311 | |
312 | 312 | if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0) |
313 | return ret; | |
313 | goto end; | |
314 | 314 | |
315 | 315 | memcpy(avframe->data[0], |
316 | 316 | framewithpts->frame->components[0].data, |
331 | 331 | avframe->linesize[2] = framewithpts->frame->components[2].stride; |
332 | 332 | |
333 | 333 | *got_frame = 1; |
334 | ||
335 | /* Now free the frame resources. */ | |
336 | libschroedinger_decode_frame_free(framewithpts->frame); | |
337 | av_free(framewithpts); | |
338 | 334 | } else { |
339 | 335 | data = NULL; |
340 | 336 | *got_frame = 0; |
341 | 337 | } |
342 | return buf_size; | |
338 | ret = buf_size; | |
339 | end: | |
340 | /* Now free the frame resources. */ | |
341 | if (framewithpts && framewithpts->frame) | |
342 | libschroedinger_decode_frame_free(framewithpts->frame); | |
343 | av_freep(&framewithpts); | |
344 | return ret; | |
343 | 345 | } |
344 | 346 | |
345 | 347 |
485 | 485 | m->size_var = 8; |
486 | 486 | //size_var is equal to 8 or 16 depending on the size of box |
487 | 487 | |
488 | if (m->tracksize + tsmb_size > avpkt->size) | |
488 | if (tsmb_size == 0) { | |
489 | av_log(avctx, AV_LOG_ERROR, "tsmb_size is 0\n"); | |
490 | return AVERROR_INVALIDDATA; | |
491 | } | |
492 | ||
493 | if (tsmb_size > avpkt->size - m->tracksize) | |
489 | 494 | break; |
490 | 495 | |
491 | 496 | for (size_t i = 0; i < box_count; i++) { |
2428 | 2428 | tc = avctx->timecode_frame_start = get_bits(&s->gb, 25); |
2429 | 2429 | |
2430 | 2430 | s->closed_gop = get_bits1(&s->gb); |
2431 | /* broken_link indicate that after editing the | |
2431 | /* broken_link indicates that after editing the | |
2432 | 2432 | * reference frames of the first B-Frames after GOP I-Frame |
2433 | 2433 | * are missing (open gop) */ |
2434 | 2434 | broken_link = get_bits1(&s->gb); |
2823 | 2823 | avctx->extradata, avctx->extradata_size); |
2824 | 2824 | if (*got_output) { |
2825 | 2825 | av_log(avctx, AV_LOG_ERROR, "picture in extradata\n"); |
2826 | av_frame_unref(picture); | |
2826 | 2827 | *got_output = 0; |
2827 | 2828 | } |
2828 | 2829 | s->extradata_decoded = 1; |
97 | 97 | } else if (codec_id == AV_CODEC_ID_MP3ADU) { |
98 | 98 | avpriv_report_missing_feature(avctx, |
99 | 99 | "MP3ADU full parser"); |
100 | return AVERROR_PATCHWELCOME; | |
100 | return 0; /* parsers must not return error codes */ | |
101 | 101 | } |
102 | 102 | |
103 | 103 | break; |
2786 | 2786 | av_log(s->avctx, AV_LOG_ERROR, "Cannot reallocate putbit buffer\n"); |
2787 | 2787 | return AVERROR(ENOMEM); |
2788 | 2788 | } |
2789 | ||
2790 | emms_c(); | |
2789 | 2791 | |
2790 | 2792 | av_fast_padded_malloc(&new_buffer, &new_buffer_size, |
2791 | 2793 | s->avctx->internal->byte_buffer_size + size_increase); |
98 | 98 | return ret; |
99 | 99 | |
100 | 100 | if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) { |
101 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
101 | int size; | |
102 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); | |
102 | 103 | |
103 | if (pal) { | |
104 | if (pal && size == AVPALETTE_SIZE) { | |
104 | 105 | s->frame->palette_has_changed = 1; |
105 | 106 | memcpy(s->pal, pal, AVPALETTE_SIZE); |
107 | } else if (pal) { | |
108 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); | |
106 | 109 | } |
107 | 110 | /* make the palette available */ |
108 | 111 | memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE); |
421 | 421 | |
422 | 422 | ff_vc1_decode_blocks(v); |
423 | 423 | |
424 | ff_er_frame_end(&s->er); | |
424 | if (v->end_mb_x == s->mb_width && s->end_mb_y == s->mb_height) { | |
425 | ff_er_frame_end(&s->er); | |
426 | } else { | |
427 | av_log(v->s.avctx, AV_LOG_WARNING, | |
428 | "disabling error correction due to block count mismatch %dx%d != %dx%d\n", | |
429 | v->end_mb_x, s->end_mb_y, s->mb_width, s->mb_height); | |
430 | } | |
425 | 431 | |
426 | 432 | ff_mpv_frame_end(s); |
427 | 433 |
305 | 305 | return ret; |
306 | 306 | |
307 | 307 | if (s->mode_8bit) { |
308 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
309 | ||
310 | if (pal) { | |
308 | int size; | |
309 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); | |
310 | ||
311 | if (pal && size == AVPALETTE_SIZE) { | |
311 | 312 | memcpy(s->pal, pal, AVPALETTE_SIZE); |
312 | 313 | s->frame->palette_has_changed = 1; |
314 | } else if (pal) { | |
315 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); | |
313 | 316 | } |
314 | 317 | } |
315 | 318 |
42 | 42 | int buf_size = avpkt->size; |
43 | 43 | PNMContext * const s = avctx->priv_data; |
44 | 44 | AVFrame * const p = data; |
45 | int i, j, n, linesize, h, upgrade = 0, is_mono = 0; | |
45 | int i, j, k, n, linesize, h, upgrade = 0, is_mono = 0; | |
46 | 46 | unsigned char *ptr; |
47 | 47 | int components, sample_len, ret; |
48 | 48 | |
142 | 142 | v = (*s->bytestream++)&1; |
143 | 143 | } else { |
144 | 144 | /* read a sequence of digits */ |
145 | do { | |
145 | for (k = 0; k < 5 && c <= 9; k += 1) { | |
146 | 146 | v = 10*v + c; |
147 | 147 | c = (*s->bytestream++) - '0'; |
148 | } while (c <= 9); | |
148 | } | |
149 | if (v > s->maxval) { | |
150 | av_log(avctx, AV_LOG_ERROR, "value %d larger than maxval %d\n", v, s->maxval); | |
151 | return AVERROR_INVALIDDATA; | |
152 | } | |
149 | 153 | } |
150 | 154 | if (sample_len == 16) { |
151 | 155 | ((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval; |
66 | 66 | ptrdiff_t line_size) |
67 | 67 | { |
68 | 68 | int i; |
69 | vec_u8 perm = vec_lvsl(0, pixels); | |
70 | 69 | const vec_u8 zero = (const vec_u8)vec_splat_u8(0); |
71 | 70 | |
72 | 71 | for (i = 0; i < 8; i++) { |
72 | vec_u8 perm = vec_lvsl(0, pixels); | |
73 | 73 | /* Read potentially unaligned pixels. |
74 | 74 | * We're reading 16 pixels, and actually only want 8, |
75 | 75 | * but we simply ignore the extras. */ |
156 | 156 | const uint8_t *s2, int stride) |
157 | 157 | { |
158 | 158 | int i; |
159 | vec_u8 perm1 = vec_lvsl(0, s1); | |
160 | vec_u8 perm2 = vec_lvsl(0, s2); | |
159 | vec_u8 perm; | |
161 | 160 | const vec_u8 zero = (const vec_u8)vec_splat_u8(0); |
162 | 161 | vec_s16 shorts1, shorts2; |
163 | 162 | |
165 | 164 | /* Read potentially unaligned pixels. |
166 | 165 | * We're reading 16 pixels, and actually only want 8, |
167 | 166 | * but we simply ignore the extras. */ |
167 | perm = vec_lvsl(0, s1); | |
168 | 168 | vec_u8 pixl = vec_ld(0, s1); |
169 | 169 | vec_u8 pixr = vec_ld(15, s1); |
170 | vec_u8 bytes = vec_perm(pixl, pixr, perm1); | |
170 | vec_u8 bytes = vec_perm(pixl, pixr, perm); | |
171 | 171 | |
172 | 172 | // Convert the bytes into shorts. |
173 | 173 | shorts1 = (vec_s16)vec_mergeh(zero, bytes); |
174 | 174 | |
175 | 175 | // Do the same for the second block of pixels. |
176 | perm = vec_lvsl(0, s2); | |
176 | 177 | pixl = vec_ld(0, s2); |
177 | 178 | pixr = vec_ld(15, s2); |
178 | bytes = vec_perm(pixl, pixr, perm2); | |
179 | bytes = vec_perm(pixl, pixr, perm); | |
179 | 180 | |
180 | 181 | // Convert the bytes into shorts. |
181 | 182 | shorts2 = (vec_s16)vec_mergeh(zero, bytes); |
196 | 197 | /* Read potentially unaligned pixels. |
197 | 198 | * We're reading 16 pixels, and actually only want 8, |
198 | 199 | * but we simply ignore the extras. */ |
200 | perm = vec_lvsl(0, s1); | |
199 | 201 | pixl = vec_ld(0, s1); |
200 | 202 | pixr = vec_ld(15, s1); |
201 | bytes = vec_perm(pixl, pixr, perm1); | |
203 | bytes = vec_perm(pixl, pixr, perm); | |
202 | 204 | |
203 | 205 | // Convert the bytes into shorts. |
204 | 206 | shorts1 = (vec_s16)vec_mergeh(zero, bytes); |
205 | 207 | |
206 | 208 | // Do the same for the second block of pixels. |
209 | perm = vec_lvsl(0, s2); | |
207 | 210 | pixl = vec_ld(0, s2); |
208 | 211 | pixr = vec_ld(15, s2); |
209 | bytes = vec_perm(pixl, pixr, perm2); | |
212 | bytes = vec_perm(pixl, pixr, perm); | |
210 | 213 | |
211 | 214 | // Convert the bytes into shorts. |
212 | 215 | shorts2 = (vec_s16)vec_mergeh(zero, bytes); |
624 | 624 | |
625 | 625 | /* if V or alpha component size is negative that means that previous |
626 | 626 | component sizes are too large */ |
627 | if (v_data_size < 0 || a_data_size < 0 || hdr_size < 6) { | |
627 | if (v_data_size < 0 || a_data_size < 0 || hdr_size < 6 || coff[3] > slice_data_size) { | |
628 | 628 | av_log(avctx, AV_LOG_ERROR, "invalid data size\n"); |
629 | 629 | return AVERROR_INVALIDDATA; |
630 | 630 | } |
259 | 259 | AVFrame * const ref = a->ref; |
260 | 260 | uint8_t* outdata; |
261 | 261 | int delta, ret; |
262 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
262 | int pal_size; | |
263 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); | |
263 | 264 | |
264 | 265 | if (avpkt->size < 0x86) { |
265 | 266 | av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); |
286 | 287 | } |
287 | 288 | |
288 | 289 | /* make the palette available on the way out */ |
289 | if (pal) { | |
290 | if (pal && pal_size == AVPALETTE_SIZE) { | |
290 | 291 | p->palette_has_changed = 1; |
291 | 292 | memcpy(a->pal, pal, AVPALETTE_SIZE); |
293 | } else if (pal) { | |
294 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size); | |
292 | 295 | } |
293 | 296 | memcpy(p->data[1], a->pal, AVPALETTE_SIZE); |
294 | 297 |
484 | 484 | } |
485 | 485 | |
486 | 486 | if(has_palette) { |
487 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
488 | ||
489 | if (pal) { | |
487 | int size; | |
488 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); | |
489 | ||
490 | if (pal && size == AVPALETTE_SIZE) { | |
490 | 491 | s->frame->palette_has_changed = 1; |
491 | 492 | memcpy(s->pal, pal, AVPALETTE_SIZE); |
493 | } else if (pal) { | |
494 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); | |
492 | 495 | } |
493 | 496 | |
494 | 497 | /* make the palette available on the way out */ |
270 | 270 | } |
271 | 271 | |
272 | 272 | if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { |
273 | int pal_size; | |
273 | 274 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, |
274 | NULL); | |
275 | &pal_size); | |
276 | if (pal_size != AVPALETTE_SIZE) { | |
277 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size); | |
278 | pal = NULL; | |
279 | } | |
275 | 280 | |
276 | 281 | if (pal) { |
277 | 282 | av_buffer_unref(&context->palette); |
108 | 108 | val = dim[get_bits1(gb) - val]; |
109 | 109 | if(!val){ |
110 | 110 | do{ |
111 | if (get_bits_left(gb) < 8) | |
112 | return AVERROR_INVALIDDATA; | |
111 | 113 | t = get_bits(gb, 8); |
112 | 114 | val += t << 2; |
113 | 115 | }while(t == 0xFF); |
130 | 130 | /** |
131 | 131 | * Decode header tree |
132 | 132 | */ |
133 | static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx) | |
133 | static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx, int length) | |
134 | 134 | { |
135 | if(length > 500) { // Larger length can cause segmentation faults due to too deep recursion. | |
136 | av_log(NULL, AV_LOG_ERROR, "length too long\n"); | |
137 | return AVERROR_INVALIDDATA; | |
138 | } | |
135 | 139 | if (hc->current + 1 >= hc->length) { |
136 | 140 | av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n"); |
137 | 141 | return AVERROR_INVALIDDATA; |
160 | 164 | int r = 0, r_new, t; |
161 | 165 | |
162 | 166 | t = hc->current++; |
163 | r = smacker_decode_bigtree(gb, hc, ctx); | |
167 | r = smacker_decode_bigtree(gb, hc, ctx, length + 1); | |
164 | 168 | if(r < 0) |
165 | 169 | return r; |
166 | 170 | hc->values[t] = SMK_NODE | r; |
167 | 171 | r++; |
168 | r_new = smacker_decode_bigtree(gb, hc, ctx); | |
172 | r_new = smacker_decode_bigtree(gb, hc, ctx, length + 1); | |
169 | 173 | if (r_new < 0) |
170 | 174 | return r_new; |
171 | 175 | return r + r_new; |
276 | 280 | goto error; |
277 | 281 | } |
278 | 282 | |
279 | if (smacker_decode_bigtree(gb, &huff, &ctx) < 0) | |
283 | if (smacker_decode_bigtree(gb, &huff, &ctx, 0) < 0) | |
280 | 284 | err = -1; |
281 | 285 | skip_bits1(gb); |
282 | 286 | if(ctx.last[0] == -1) ctx.last[0] = huff.current++; |
150 | 150 | int i, cur_frame = 0, ret = 0; |
151 | 151 | |
152 | 152 | cur_frame = avpkt->pts % s->frames_per_jpeg; |
153 | ||
154 | /* cur_frame is later used to calculate the buffer offset, so it mustn't be negative */ | |
155 | if (cur_frame < 0) | |
156 | cur_frame += s->frames_per_jpeg; | |
153 | 157 | |
154 | 158 | /* Are we at the start of a block? */ |
155 | 159 | if (!cur_frame) { |
167 | 167 | } |
168 | 168 | } else { |
169 | 169 | for (y = 0; y < h; y++) { |
170 | if (buf_end - buf < len) | |
170 | if (buf_end - buf < alen) | |
171 | 171 | break; |
172 | 172 | memcpy(ptr, buf, len); |
173 | 173 | ptr += stride; |
98 | 98 | |
99 | 99 | /* make the palette available on the way out */ |
100 | 100 | if (c->avctx->pix_fmt == AV_PIX_FMT_PAL8) { |
101 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); | |
101 | int size; | |
102 | const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); | |
102 | 103 | |
103 | if (pal) { | |
104 | if (pal && size == AVPALETTE_SIZE) { | |
104 | 105 | frame->palette_has_changed = 1; |
105 | 106 | memcpy(c->pal, pal, AVPALETTE_SIZE); |
107 | } else if (pal) { | |
108 | av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); | |
106 | 109 | } |
107 | 110 | memcpy(frame->data[1], c->pal, AVPALETTE_SIZE); |
108 | 111 | } |
1117 | 1117 | if (ret) |
1118 | 1118 | ret[i] = r; |
1119 | 1119 | } |
1120 | emms_c(); | |
1120 | 1121 | return 0; |
1121 | 1122 | } |
1122 | 1123 | |
1129 | 1130 | if (ret) |
1130 | 1131 | ret[i] = r; |
1131 | 1132 | } |
1133 | emms_c(); | |
1132 | 1134 | return 0; |
1133 | 1135 | } |
1134 | 1136 |
3724 | 3724 | if (!ct) |
3725 | 3725 | return; |
3726 | 3726 | |
3727 | update_factor = FASTDIV(update_factor * FFMIN(ct, max_count), max_count); | |
3727 | 3728 | p1 = *p; |
3728 | p2 = ((ct0 << 8) + (ct >> 1)) / ct; | |
3729 | p2 = ((((int64_t) ct0) << 8) + (ct >> 1)) / ct; | |
3729 | 3730 | p2 = av_clip(p2, 1, 255); |
3730 | ct = FFMIN(ct, max_count); | |
3731 | update_factor = FASTDIV(update_factor * ct, max_count); | |
3732 | 3731 | |
3733 | 3732 | // (p1 * (256 - update_factor) + p2 * update_factor + 128) >> 8 |
3734 | 3733 | *p = p1 + (((p2 - p1) * update_factor + 128) >> 8); |
192 | 192 | mov valb, [srcq+%2-1] |
193 | 193 | %elif (%2-%%off) == 2 |
194 | 194 | mov valw, [srcq+%2-2] |
195 | %elifidn %1, body | |
195 | %else | |
196 | 196 | mov valb, [srcq+%2-1] |
197 | sal vald, 16 | |
197 | ror vald, 16 | |
198 | 198 | mov valw, [srcq+%2-3] |
199 | %elifidn %1, bottom | |
200 | movd mm %+ %%mmx_idx, [srcq+%2-4] | |
201 | %else ; top | |
202 | movd mm %+ %%mmx_idx, [srcq+%2-3] | |
203 | 199 | %endif |
204 | 200 | %endif ; (%2-%%off) >= 1 |
205 | 201 | %endmacro ; READ_NUM_BYTES |
252 | 248 | mov [dstq+%2-1], valb |
253 | 249 | %elif (%2-%%off) == 2 |
254 | 250 | mov [dstq+%2-2], valw |
255 | %elifidn %1, body | |
251 | %else | |
256 | 252 | mov [dstq+%2-3], valw |
257 | sar vald, 16 | |
253 | ror vald, 16 | |
258 | 254 | mov [dstq+%2-1], valb |
259 | %else | |
260 | movd vald, mm %+ %%mmx_idx | |
261 | %ifidn %1, bottom | |
262 | sar vald, 8 | |
263 | %endif | |
264 | mov [dstq+%2-3], valw | |
265 | sar vald, 16 | |
266 | mov [dstq+%2-1], valb | |
255 | %ifnidn %1, body | |
256 | ror vald, 16 | |
257 | %endif | |
267 | 258 | %endif |
268 | 259 | %endif ; (%2-%%off) >= 1 |
269 | 260 | %endmacro ; WRITE_NUM_BYTES |
108 | 108 | if (!pan->args) { |
109 | 109 | av_log(ctx, AV_LOG_ERROR, |
110 | 110 | "pan filter needs a channel layout and a set " |
111 | "of channels definitions as parameter\n"); | |
111 | "of channel definitions as parameter\n"); | |
112 | 112 | return AVERROR(EINVAL); |
113 | 113 | } |
114 | 114 | if (!args) |
273 | 273 | if (link->channels > MAX_CHANNELS || |
274 | 274 | pan->nb_output_channels > MAX_CHANNELS) { |
275 | 275 | av_log(ctx, AV_LOG_ERROR, |
276 | "af_pan support a maximum of %d channels. " | |
276 | "af_pan supports a maximum of %d channels. " | |
277 | 277 | "Feel free to ask for a higher limit.\n", MAX_CHANNELS); |
278 | 278 | return AVERROR_PATCHWELCOME; |
279 | 279 | } |
103 | 103 | #define OFFSET(x) offsetof(BlackFrameContext, x) |
104 | 104 | #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
105 | 105 | static const AVOption blackframe_options[] = { |
106 | { "amount", "Percentage of the pixels that have to be below the threshold " | |
107 | "for the frame to be considered black.", OFFSET(bamount), AV_OPT_TYPE_INT, { .i64 = 98 }, 0, 100, FLAGS }, | |
106 | { "amount", "percentage of the pixels that have to be below the threshold " | |
107 | "for the frame to be considered black", OFFSET(bamount), AV_OPT_TYPE_INT, { .i64 = 98 }, 0, 100, FLAGS }, | |
108 | 108 | { "threshold", "threshold below which a pixel value is considered black", |
109 | 109 | OFFSET(bthresh), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, 255, FLAGS }, |
110 | 110 | { "thresh", "threshold below which a pixel value is considered black", |
1089 | 1089 | goto error; |
1090 | 1090 | |
1091 | 1091 | if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) { |
1092 | if (ast->sub_ctx->nb_streams != 1) | |
1093 | goto error; | |
1092 | 1094 | ff_read_packet(ast->sub_ctx, &ast->sub_pkt); |
1093 | 1095 | *st->codec = *ast->sub_ctx->streams[0]->codec; |
1094 | 1096 | ast->sub_ctx->streams[0]->codec->extradata = NULL; |
1843 | 1845 | continue; |
1844 | 1846 | |
1845 | 1847 | // av_assert1(st2->codec->block_align); |
1846 | av_assert0(fabs(av_q2d(st2->time_base) - ast2->scale / (double)ast2->rate) < av_q2d(st2->time_base) * 0.00000001); | |
1847 | 1848 | index = av_index_search_timestamp(st2, |
1848 | 1849 | av_rescale_q(timestamp, |
1849 | 1850 | st->time_base, |
350 | 350 | } |
351 | 351 | break; |
352 | 352 | case MKBETAG('S', 'T', 'V', 'I'): |
353 | if (f_stvi++) { | |
353 | if (f_stvi++ || codec->codec_type != AVMEDIA_TYPE_VIDEO) { | |
354 | 354 | ret = AVERROR(EINVAL); |
355 | 355 | goto fail; |
356 | 356 | } |
411 | 411 | codec->refs = avio_rb32(pb); |
412 | 412 | break; |
413 | 413 | case MKBETAG('S', 'T', 'A', 'U'): |
414 | if (f_stau++) { | |
414 | if (f_stau++ || codec->codec_type != AVMEDIA_TYPE_AUDIO) { | |
415 | 415 | ret = AVERROR(EINVAL); |
416 | 416 | goto fail; |
417 | 417 | } |
437 | 437 | } |
438 | 438 | break; |
439 | 439 | case MKBETAG('S', '2', 'V', 'I'): |
440 | if (f_stvi++ || !size) { | |
440 | if (f_stvi++ || !size || codec->codec_type != AVMEDIA_TYPE_VIDEO) { | |
441 | 441 | ret = AVERROR(EINVAL); |
442 | 442 | goto fail; |
443 | 443 | } |
452 | 452 | goto fail; |
453 | 453 | break; |
454 | 454 | case MKBETAG('S', '2', 'A', 'U'): |
455 | if (f_stau++ || !size) { | |
455 | if (f_stau++ || !size || codec->codec_type != AVMEDIA_TYPE_AUDIO) { | |
456 | 456 | ret = AVERROR(EINVAL); |
457 | 457 | goto fail; |
458 | 458 | } |
24 | 24 | */ |
25 | 25 | |
26 | 26 | #include "libavutil/intreadwrite.h" |
27 | #include "libavutil/imgutils.h" | |
27 | 28 | #include "avformat.h" |
28 | 29 | #include "internal.h" |
29 | 30 | |
67 | 68 | st->codec->height = avio_rb16(pb); |
68 | 69 | film->leading = avio_rb16(pb); |
69 | 70 | |
70 | if (st->codec->width * 4LL * st->codec->height >= INT_MAX) { | |
71 | av_log(s, AV_LOG_ERROR, "dimensions too large\n"); | |
72 | return AVERROR_PATCHWELCOME; | |
73 | } | |
71 | if (av_image_check_size(st->codec->width, st->codec->height, 0, s) < 0) | |
72 | return AVERROR_INVALIDDATA; | |
74 | 73 | |
75 | 74 | avpriv_set_pts_info(st, 64, 1, avio_rb16(pb)); |
76 | 75 |
82 | 82 | avio_skip(pb, 5); |
83 | 83 | |
84 | 84 | ico->images[i].size = avio_rl32(pb); |
85 | if (ico->images[i].size <= 0) { | |
86 | av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size); | |
87 | return AVERROR_INVALIDDATA; | |
88 | } | |
85 | 89 | ico->images[i].offset = avio_rl32(pb); |
86 | 90 | |
87 | 91 | if (avio_seek(pb, ico->images[i].offset, SEEK_SET) < 0) |
147 | 151 | bytestream_put_le16(&buf, 0); |
148 | 152 | bytestream_put_le32(&buf, 0); |
149 | 153 | |
150 | if ((ret = avio_read(pb, buf, image->size)) < 0) | |
151 | return ret; | |
154 | if ((ret = avio_read(pb, buf, image->size)) != image->size) { | |
155 | av_packet_unref(pkt); | |
156 | return ret < 0 ? ret : AVERROR_INVALIDDATA; | |
157 | } | |
152 | 158 | |
153 | 159 | st->codec->bits_per_coded_sample = AV_RL16(buf + 14); |
154 | 160 |
155 | 155 | return AVERROR(EIO); |
156 | 156 | chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 + |
157 | 157 | codebook_size; |
158 | ||
159 | if (chunk_size > INT_MAX) | |
160 | return AVERROR_INVALIDDATA; | |
158 | 161 | |
159 | 162 | /* rewind */ |
160 | 163 | avio_seek(pb, codebook_offset, SEEK_SET); |
3464 | 3464 | av_log(s, AV_LOG_ERROR, "Failed to read file headers\n"); |
3465 | 3465 | return -1; |
3466 | 3466 | } |
3467 | if (!s->nb_streams) { | |
3468 | matroska_read_close(s); | |
3469 | av_log(s, AV_LOG_ERROR, "No streams found\n"); | |
3470 | return AVERROR_INVALIDDATA; | |
3471 | } | |
3467 | 3472 | |
3468 | 3473 | if (!matroska->is_live) { |
3469 | 3474 | buf = av_asprintf("%g", matroska->duration); |
111 | 111 | : AVPROBE_SCORE_EXTENSION / 2; // 1 more than .mpg |
112 | 112 | if ((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys && |
113 | 113 | !pspack && p->buf_size > 2048 && vid + audio > invalid) /* PES stream */ |
114 | return (audio > 12 || vid > 3 + 2 * invalid) ? AVPROBE_SCORE_EXTENSION + 2 | |
114 | return (audio > 12 || vid > 6 + 2 * invalid) ? AVPROBE_SCORE_EXTENSION + 2 | |
115 | 115 | : AVPROBE_SCORE_EXTENSION / 2; |
116 | 116 | |
117 | 117 | // 02-Penguin.flac has sys:0 priv1:0 pspack:0 vid:0 audio:1 |
2587 | 2587 | packet_count[nb_pcrs] = nb_packets; |
2588 | 2588 | pcrs[nb_pcrs] = pcr_h * 300 + pcr_l; |
2589 | 2589 | nb_pcrs++; |
2590 | if (nb_pcrs >= 2) | |
2591 | break; | |
2590 | if (nb_pcrs >= 2) { | |
2591 | if (pcrs[1] - pcrs[0] > 0) { | |
2592 | /* the difference needs to be positive to make sense for bitrate computation */ | |
2593 | break; | |
2594 | } else { | |
2595 | av_log(ts->stream, AV_LOG_WARNING, "invalid pcr pair %"PRId64" >= %"PRId64"\n", pcrs[0], pcrs[1]); | |
2596 | pcrs[0] = pcrs[1]; | |
2597 | packet_count[0] = packet_count[1]; | |
2598 | nb_pcrs--; | |
2599 | } | |
2600 | } | |
2592 | 2601 | } else { |
2593 | 2602 | finished_reading_packet(s, ts->raw_packet_size); |
2594 | 2603 | } |
381 | 381 | for (i = 0; i < s->nb_streams; i++) { |
382 | 382 | MXFTrack *track = s->streams[i]->priv_data; |
383 | 383 | /* SMPTE 379M 7.3 */ |
384 | if (!memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number))) | |
384 | if (track && !memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number))) | |
385 | 385 | return i; |
386 | 386 | } |
387 | 387 | /* return 0 if only one stream, for OP Atom files with 0 as track number */ |
825 | 825 | int ret; |
826 | 826 | size_t buf_size; |
827 | 827 | |
828 | if (size < 0) | |
828 | if (size < 0 || size > INT_MAX/2) | |
829 | 829 | return AVERROR(EINVAL); |
830 | 830 | |
831 | 831 | buf_size = size + size / 2 + 1; |
2999 | 2999 | if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) { |
3000 | 3000 | pkt->dts = mxf->current_edit_unit + t->first_dts; |
3001 | 3001 | pkt->pts = t->ptses[mxf->current_edit_unit]; |
3002 | } else if (track->intra_only) { | |
3002 | } else if (track && track->intra_only) { | |
3003 | 3003 | /* intra-only -> PTS = EditUnit. |
3004 | 3004 | * let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */ |
3005 | 3005 | pkt->pts = mxf->current_edit_unit; |
73 | 73 | |
74 | 74 | spxp->packet_size = AV_RL32(p + 56); |
75 | 75 | frames_per_packet = AV_RL32(p + 64); |
76 | if (spxp->packet_size < 0 || | |
77 | frames_per_packet < 0 || | |
78 | spxp->packet_size * (int64_t)frames_per_packet > INT32_MAX / 256) { | |
79 | av_log(s, AV_LOG_ERROR, "invalid packet_size, frames_per_packet %d %d\n", spxp->packet_size, frames_per_packet); | |
80 | spxp->packet_size = 0; | |
81 | return AVERROR_INVALIDDATA; | |
82 | } | |
76 | 83 | if (frames_per_packet) |
77 | 84 | spxp->packet_size *= frames_per_packet; |
78 | 85 |
926 | 926 | } |
927 | 927 | } |
928 | 928 | if (s->start_ts == AV_NOPTS_VALUE) |
929 | s->start_ts = s->opt_start_at_first ? s->tseq[0].ts.t : now; | |
929 | s->start_ts = (s->opt_start_at_first && s->tseq) ? s->tseq[0].ts.t : now; | |
930 | 930 | s->end_ts = s->opt_duration ? s->start_ts + s->opt_duration : |
931 | 931 | AV_NOPTS_VALUE; /* may be overridden later by -E option */ |
932 | 932 | cur_ts = now; |
674 | 674 | return ret; |
675 | 675 | for (i = 0; i < s->nb_streams; i++) { |
676 | 676 | st = s->streams[i]; |
677 | if (st->probe_packets) | |
677 | if (st->probe_packets || st->request_probe > 0) | |
678 | 678 | if ((err = probe_codec(s, st, NULL)) < 0) |
679 | 679 | return err; |
680 | 680 | av_assert0(st->request_probe <= 0); |
2362 | 2362 | if (ic->nb_programs) { |
2363 | 2363 | for (i = 0; i < ic->nb_programs; i++) { |
2364 | 2364 | p = ic->programs[i]; |
2365 | if (p->start_time != AV_NOPTS_VALUE && p->end_time > p->start_time) | |
2365 | if (p->start_time != AV_NOPTS_VALUE && | |
2366 | p->end_time > p->start_time && | |
2367 | p->end_time - (uint64_t)p->start_time <= INT64_MAX) | |
2366 | 2368 | duration = FFMAX(duration, p->end_time - p->start_time); |
2367 | 2369 | } |
2368 | } else | |
2370 | } else if (end_time >= start_time && end_time - (uint64_t)start_time <= INT64_MAX) { | |
2369 | 2371 | duration = FFMAX(duration, end_time - start_time); |
2372 | } | |
2370 | 2373 | } |
2371 | 2374 | } |
2372 | 2375 | if (duration != INT64_MIN && duration > 0 && ic->duration == AV_NOPTS_VALUE) { |
84 | 84 | #else // !(__mips == 64) |
85 | 85 | #define LD(psrc) \ |
86 | 86 | ( { \ |
87 | uint8_t *psrc_m = (uint8_t *) (psrc); \ | |
87 | uint8_t *psrc_ld_m = (uint8_t *) (psrc); \ | |
88 | 88 | uint32_t val0_m, val1_m; \ |
89 | 89 | uint64_t val_m = 0; \ |
90 | 90 | \ |
91 | val0_m = LW(psrc_m); \ | |
92 | val1_m = LW(psrc_m + 4); \ | |
91 | val0_m = LW(psrc_ld_m); \ | |
92 | val1_m = LW(psrc_ld_m + 4); \ | |
93 | 93 | \ |
94 | 94 | val_m = (uint64_t) (val1_m); \ |
95 | 95 | val_m = (uint64_t) ((val_m << 32) & 0xFFFFFFFF00000000); \ |
171 | 171 | #else // !(__mips == 64) |
172 | 172 | #define LD(psrc) \ |
173 | 173 | ( { \ |
174 | uint8_t *psrc_m1 = (uint8_t *) (psrc); \ | |
174 | uint8_t *psrc_ld_m = (uint8_t *) (psrc); \ | |
175 | 175 | uint32_t val0_m, val1_m; \ |
176 | 176 | uint64_t val_m = 0; \ |
177 | 177 | \ |
178 | val0_m = LW(psrc_m1); \ | |
179 | val1_m = LW(psrc_m1 + 4); \ | |
178 | val0_m = LW(psrc_ld_m); \ | |
179 | val1_m = LW(psrc_ld_m + 4); \ | |
180 | 180 | \ |
181 | 181 | val_m = (uint64_t) (val1_m); \ |
182 | 182 | val_m = (uint64_t) ((val_m << 32) & 0xFFFFFFFF00000000); \ |
26 | 26 | #include "avassert.h" |
27 | 27 | #include "softfloat_tables.h" |
28 | 28 | |
29 | #define MIN_EXP -126 | |
29 | #define MIN_EXP -149 | |
30 | 30 | #define MAX_EXP 126 |
31 | 31 | #define ONE_BITS 29 |
32 | 32 | |
153 | 153 | */ |
154 | 154 | static inline av_const SoftFloat av_int2sf(int v, int frac_bits){ |
155 | 155 | int exp_offset = 0; |
156 | if(v == INT_MIN){ | |
156 | if(v <= INT_MIN + 1){ | |
157 | 157 | exp_offset = 1; |
158 | 158 | v>>=1; |
159 | 159 | } |
374 | 374 | track->duration - |
375 | 375 | track->offsets[track->chunks - 1].time; |
376 | 376 | } |
377 | // Now try and read the actual durations from the trun sample data. | |
377 | // Now try to read the actual durations from the trun sample data. | |
378 | 378 | for (i = 0; i < track->chunks; i++) { |
379 | 379 | int64_t duration = read_moof_duration(f, track->offsets[i].offset); |
380 | 380 | if (duration > 0 && abs(duration - track->offsets[i].duration) > 3) { |