Compare commits
143 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c63e587566 | |||
| b5c13002d1 | |||
| a5dabd4013 | |||
| 3295d22f3a | |||
| dc1e099bf2 | |||
| 4f7064c9da | |||
| bb504aa5eb | |||
| 4730d0d385 | |||
| be0e26d107 | |||
| e8b94e5ce4 | |||
| c595b1da4f | |||
| f9a96bac28 | |||
| 9797929749 | |||
| dfca37f0e5 | |||
| a71d22d84d | |||
| 44eaff5e6d | |||
| cfbab85809 | |||
| 3e03d12c83 | |||
| 02323b1d02 | |||
| 99c78466ff | |||
| a6639334df | |||
| 72d5addc0b | |||
| a0b7a3c8aa | |||
| c4b36ccd02 | |||
| 198c8924c6 | |||
| 4535861ef8 | |||
| 1a168061da | |||
| 76961f4f42 | |||
| 7dd1cc6076 | |||
| 667c9ed1f1 | |||
| efa164aa68 | |||
| 7c68d5e701 | |||
| 0bcc7ea5dc | |||
| b408dba231 | |||
| c1435f9dfb | |||
| 726faff0aa | |||
| 2e3f0a1c6f | |||
| 1768e02a04 | |||
| e0d1db72da | |||
| a5513ae7bc | |||
| 9c0b2b9d5b | |||
| d111c9ce13 | |||
| 6e1bc747df | |||
| 2c6792b0c6 | |||
| 66bf84e2c4 | |||
| 9f7eb718e9 | |||
| 2d66fbc853 | |||
| 2f26f3de78 | |||
| e9003828dd | |||
| 66e8f87ebc | |||
| 6bee6ef0c2 | |||
| ff01dbb6ec | |||
| 2caee48576 | |||
| 63caf18787 | |||
| 8ad4e1c1cb | |||
| 27fbf8f110 | |||
| 3f9a24f06d | |||
| 083919e9c4 | |||
| bc63205ae2 | |||
| 4251dc6d7e | |||
| 8fd3293fa1 | |||
| 7affe32738 | |||
| 1bc7215e8a | |||
| 51aa6d0987 | |||
| 136fc7084e | |||
| adc86ad32f | |||
| e0dd617ed7 | |||
| 9cab9b878f | |||
| 3549871847 | |||
| 9ec40eacb1 | |||
| 8cca6b06ec | |||
| 642cd5de4d | |||
| d54aa2de17 | |||
| bab7d72d46 | |||
| 9128ef0302 | |||
| 86f5b73429 | |||
| 9375a7d85e | |||
| e8ab2bd2ac | |||
| 45b18fbb9a | |||
| 0496403c08 | |||
| 88bf1d2749 | |||
| dbad792487 | |||
| 5d2f1ffef1 | |||
| 80b85300ae | |||
| 48d24cca13 | |||
| 1c282152c1 | |||
| 4ffd5805af | |||
| 57665e04e2 | |||
| 48496e4d4f | |||
| e93934e100 | |||
| b32c9941a2 | |||
| 69673d0279 | |||
| 3047b0a4a3 | |||
| 27888d13b8 | |||
| 416a8a06b9 | |||
| e14cc2f197 | |||
| 05e6606ba9 | |||
| c3307f7e9e | |||
| 3d82cebdd2 | |||
| 5801482379 | |||
| e6197a6ce9 | |||
| e78d9f3f35 | |||
| ef2d91e9c3 | |||
| dcc8d2418a | |||
| 087b777415 | |||
| aca7f5f060 | |||
| aa32d41527 | |||
| a1e6daeb1e | |||
| 30d542d55d | |||
| 1d439041ec | |||
| 0009cf348a | |||
| 492bbe5890 | |||
| 5771a0c823 | |||
| f309b698e6 | |||
| 0887f1835d | |||
| de42af2bee | |||
| ada229e66f | |||
| 047e0049d1 | |||
| 88f52f2f8f | |||
| 8baf2d8fad | |||
| 17b8e7799f | |||
| 6457346e6a | |||
| 27f1fb1251 | |||
| c993a11e56 | |||
| ef5b120e2d | |||
| b9a1d389b2 | |||
| 8c43f32057 | |||
| 77d5a237ef | |||
| fb7617df4e | |||
| 82b58841c9 | |||
| e5bf7ab3e7 | |||
| 63f951601e | |||
| 7fefa4138d | |||
| a1f77124c8 | |||
| f2f7d49f41 | |||
| 9357aa6757 | |||
| 26a8fc1c00 | |||
| b7b3b0086d | |||
| d669b7f4f6 | |||
| 9259b7f38e | |||
| cb8a29f872 | |||
| 6744d3f6b9 | |||
| 73b644cdee |
@@ -1,6 +1,147 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 3.0.7
|
||||
- avcodec/h264_slice: Clear ref_counts on redundant slices
|
||||
- lavf/mov.c: Avoid heap allocation wrap in mov_read_uuid
|
||||
- lavf/mov.c: Avoid heap allocation wrap in mov_read_hdlr
|
||||
- avcodec/pictordec: Fix logic error
|
||||
- avcodec/movtextdec: Fix decode_styl() cleanup
|
||||
- lavf/matroskadec: fix is_keyframe for early Blocks
|
||||
|
||||
version 3.0.6:
|
||||
- avcodec/pngdec: Check trns more completely
|
||||
- avcodec/interplayvideo: Move parameter change check up
|
||||
- avcodec/mjpegdec: Check for for the bitstream end in mjpeg_decode_scan_progressive_ac()
|
||||
- avformat/flacdec: Check avio_read result when reading flac block header.
|
||||
- avcodec/utils: correct align value for interplay
|
||||
- avcodec/vp56: Check for the bitstream end, pass error codes on
|
||||
- avcodec/mjpegdec: Check remaining bitstream in ljpeg_decode_yuv_scan()
|
||||
- avcodec/pngdec: Fix off by 1 size in decode_zbuf()
|
||||
- avformat/avidec: skip odml master index chunks in avi_sync
|
||||
- avcodec/mjpegdec: Check for rgb before flipping
|
||||
- avutil/random_seed: Reduce the time needed on systems with very low precision clock()
|
||||
- avutil/random_seed: Improve get_generic_seed() with higher precision clock()
|
||||
- avformat/utils: Print verbose error message if stream count exceeds max_streams
|
||||
- avformat/options_table: Set the default maximum number of streams to 1000
|
||||
- pgssubdec: reset rle_data_len/rle_remaining_len on allocation error
|
||||
- avutil: Add av_image_check_size2()
|
||||
- avformat: Add max_streams option
|
||||
- avcodec/ffv1enc: Allocate smaller packet if the worst case size cannot be allocated
|
||||
- avcodec/mpeg4videodec: Fix undefined shifts in mpeg4_decode_sprite_trajectory()
|
||||
- avformat/oggdec: Skip streams in duration correction that did not had their duration set.
|
||||
- avcodec/ffv1enc: Fix size of first slice
|
||||
|
||||
|
||||
version 3.0.5:
|
||||
- configure: check for strtoull on msvc
|
||||
- http: move chunk handling from http_read_stream() to http_buf_read().
|
||||
- http: make length/offset-related variables unsigned.
|
||||
- ffserver: Check chunk size
|
||||
- Avoid using the term "file" and prefer "url" in some docs and comments
|
||||
- avformat/rtmppkt: Check for packet size mismatches
|
||||
- zmqsend: Initialize ret to 0
|
||||
- avcodec/rawdec: check for side data before checking its size
|
||||
- avcodec/flacdec: Fix undefined shift in decode_subframe()
|
||||
- avcodec/get_bits: Fix get_sbits_long(0)
|
||||
- avformat/ffmdec: Check media type for chunks
|
||||
- avcodec/flacdec: Fix signed integer overflow in decode_subframe_fixed()
|
||||
- avcodec/flacdsp_template: Fix undefined shift in flac_decorrelate_indep_c
|
||||
- avformat/oggparsespeex: Check frames_per_packet and packet_size
|
||||
- avformat/utils: Check start/end before computing duration in update_stream_timings()
|
||||
- avcodec/flac_parser: Update nb_headers_buffered
|
||||
- avformat/idroqdec: Check chunk_size for being too large
|
||||
- avformat/mpeg: Adjust vid probe threshold to correct mis-detection
|
||||
- avcodec/rv40: Test remaining space in loop of get_dimension()
|
||||
- avcodec/ituh263dec: Avoid spending a long time in slice sync
|
||||
- avcodec/movtextdec: Add error message for tsmb_size check
|
||||
- avcodec/movtextdec: Fix tsmb_size check==0 check
|
||||
- avcodec/movtextdec: Fix potential integer overflow
|
||||
- avcodec/sunrast: Fix input buffer pointer check
|
||||
- avcodec/tscc: Check side data size before use
|
||||
- avcodec/rawdec: Check side data size before use
|
||||
- avcodec/msvideo1: Check side data size before use
|
||||
- avcodec/qpeg: Check side data size before use
|
||||
- avcodec/qtrle: Check side data size before use
|
||||
- avcodec/msrle: Check side data size before use
|
||||
- avcodec/kmvc: Check side data size before use
|
||||
- avcodec/idcinvideo: Check side data size before use
|
||||
- avcodec/cinepak: Check side data size before use
|
||||
- avcodec/8bps: Check side data size before use
|
||||
- avcodec/dvdsubdec: Fix off by 1 error
|
||||
- avcodec/dvdsubdec: Fix buf_size check
|
||||
- vp9: change order of operations in adapt_prob().
|
||||
- avcodec/interplayvideo: Check side data size before use
|
||||
- avformat/mxfdec: Check size to avoid integer overflow in mxf_read_utf16_string()
|
||||
- avcodec/mpegvideo_enc: Clear mmx state in ff_mpv_reallocate_putbitbuffer()
|
||||
- avcodec/utils: Clear MMX state before returning from avcodec_default_execute*()
|
||||
- avformat/icodec: Fix crash probing fuzzed file
|
||||
- dcstr: fix division by zero
|
||||
- rsd: limit number of channels
|
||||
- mss2: only use error correction for matching block counts
|
||||
- softfloat: decrease MIN_EXP to cover full float range
|
||||
- libopusdec: default to stereo for invalid number of channels
|
||||
- pgssubdec: only set w/h/linesize when allocating data
|
||||
- sbgdec: prevent NULL pointer access
|
||||
- smacker: limit recursion depth of smacker_decode_bigtree
|
||||
- mxfdec: fix NULL pointer dereference in mxf_read_packet_old
|
||||
- libschroedingerdec: fix leaking of framewithpts
|
||||
- libschroedingerdec: don't produce empty frames
|
||||
- softfloat: handle -INT_MAX correctly
|
||||
- filmstripdec: correctly check image dimensions
|
||||
- pnmdec: make sure v is capped by maxval
|
||||
- smvjpegdec: make sure cur_frame is not negative
|
||||
- icodec: correctly check avio_read return value
|
||||
- dvbsubdec: fix division by zero in compute_default_clut
|
||||
- proresdec_lgpl: explicitly check coff[3] against slice_data_size
|
||||
- escape124: reject codebook size 0
|
||||
- icodec: add ico_read_close to fix leaking ico->images
|
||||
- icodec: fix leaking pkt on error
|
||||
- mpegts: prevent division by zero
|
||||
- matroskadec: fix NULL pointer dereference in webm_dash_manifest_read_header
|
||||
- mpegaudio_parser: don't return AVERROR_PATCHWELCOME
|
||||
- mxfdec: fix NULL pointer dereference
|
||||
- lzf: update pointer p after realloc
|
||||
- diracdec: check return code of get_buffer_with_edge
|
||||
- ppc: pixblockdsp: do unaligned block accesses correctly again
|
||||
- interplayacm: increase bitstream buffer size by AV_INPUT_BUFFER_PADDING_SIZE
|
||||
- interplayacm: validate number of channels
|
||||
- interplayacm: check for too large b
|
||||
- mpeg12dec: unref discarded picture from extradata
|
||||
- cavsdec: unref frame before referencing again
|
||||
- avformat: prevent triggering request_probe assert in ff_read_packet
|
||||
- avcodec/avpacket: fix leak on realloc in av_packet_add_side_data()
|
||||
|
||||
|
||||
version 3.0.4:
|
||||
- libopenjpegenc: fix out-of-bounds reads when filling the edges
|
||||
- libopenjpegenc: stop reusing image data buffer for openjpeg 2
|
||||
- configure: fix detection of libopenjpeg
|
||||
- cmdutils: fix typos
|
||||
- lavfi: fix typos
|
||||
- lavc: fix typos
|
||||
- tools: fix grammar error
|
||||
- ffmpeg: remove unused and errorneous AVFrame timestamp check
|
||||
- Support for MIPS cpu P6600
|
||||
- avutil/mips/generic_macros_msa: rename macro variable which causes segfault for mips r
|
||||
- avformat/avidec: Check nb_streams in read_gab2_sub()
|
||||
- avformat/avidec: Remove ancient assert
|
||||
- avformat/avidec: Fix memleak with dv in avi
|
||||
- lavc/movtextdec.c: Avoid infinite loop on invalid data.
|
||||
- avcodec/ansi: Check dimensions
|
||||
- avcodec/cavsdsp: use av_clip_uint8() for idct
|
||||
- avformat/movenc: Check packet in mov_write_single_packet() too
|
||||
- avformat/movenc: Factor check_pkt() out
|
||||
- avformat/utils: fix timebase error in avformat_seek_file()
|
||||
- avcodec/g726: Add missing ADDB output mask
|
||||
- avcodec/avpacket: clear side_data_elems
|
||||
- avformat/movenc: Check first DTS similar to dts difference
|
||||
- avcodec/ccaption_dec: Use simple array instead of AVBuffer
|
||||
- avformat/mov: Fix potential integer overflow in mov_read_keys
|
||||
- swscale/swscale_unscaled: Try to fix Rgb16ToPlanarRgb16Wrapper() with slices
|
||||
- swscale/swscale_unscaled: Fix packed_16bpc_bswap() with slices
|
||||
- lavf/utils: Avoid an overflow for huge negative durations.
|
||||
|
||||
version 3.0.3:
|
||||
- avformat/avidec: Fix infinite loop in avi_read_nikon()
|
||||
- avcodec/aacenc: Tighter input checks
|
||||
|
||||
+2
-2
@@ -2111,7 +2111,7 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
|
||||
if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
printf("Audo-detected sources for %s:\n", fmt->name);
|
||||
printf("Auto-detected sources for %s:\n", fmt->name);
|
||||
if (!fmt->get_device_list) {
|
||||
ret = AVERROR(ENOSYS);
|
||||
printf("Cannot list sources. Not implemented.\n");
|
||||
@@ -2141,7 +2141,7 @@ static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
|
||||
if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
printf("Audo-detected sinks for %s:\n", fmt->name);
|
||||
printf("Auto-detected sinks for %s:\n", fmt->name);
|
||||
if (!fmt->get_device_list) {
|
||||
ret = AVERROR(ENOSYS);
|
||||
printf("Cannot list sinks. Not implemented.\n");
|
||||
|
||||
+2
-2
@@ -450,13 +450,13 @@ int show_devices(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
#if CONFIG_AVDEVICE
|
||||
/**
|
||||
* Print a listing containing audodetected sinks of the output device.
|
||||
* Print a listing containing autodetected sinks of the output device.
|
||||
* Device name with options may be passed as an argument to limit results.
|
||||
*/
|
||||
int show_sinks(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Print a listing containing audodetected sources of the input device.
|
||||
* Print a listing containing autodetected sources of the input device.
|
||||
* Device name with options may be passed as an argument to limit results.
|
||||
*/
|
||||
int show_sources(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
@@ -4189,7 +4189,7 @@ elif enabled mips; then
|
||||
enable mips32r2
|
||||
disable msa
|
||||
;;
|
||||
p5600|i6400)
|
||||
p5600|i6400|p6600)
|
||||
disable mipsdsp
|
||||
disable mipsdspr2
|
||||
;;
|
||||
@@ -4254,6 +4254,10 @@ elif enabled mips; then
|
||||
enable mips64r6
|
||||
check_cflags "-mtune=i6400 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
|
||||
;;
|
||||
p6600)
|
||||
enable mips64r6
|
||||
check_cflags "-mtune=p6600 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# We do not disable anything. Is up to the user to disable the unwanted features.
|
||||
@@ -5481,10 +5485,11 @@ enabled libopencv && { check_header opencv2/core/core_c.h &&
|
||||
require_pkg_config opencv opencv2/core/core_c.h cvCreateImageHeader ||
|
||||
require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader; }
|
||||
enabled libopenh264 && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion
|
||||
enabled libopenjpeg && { check_lib openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
|
||||
check_lib openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
|
||||
check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
|
||||
check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
|
||||
enabled libopenjpeg && { { check_lib2 openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
|
||||
check_lib2 openjpeg-2.1/openjpeg.h opj_version -lopenjp2 ||
|
||||
{ check_lib2 openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
|
||||
{ check_lib2 openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
|
||||
{ check_lib2 openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
|
||||
die "ERROR: libopenjpeg not found"; }
|
||||
enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
|
||||
enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new
|
||||
@@ -5990,6 +5995,7 @@ __declspec($_restrict) void* foo(int);
|
||||
EOF
|
||||
fi
|
||||
check_func strtoll || add_cflags -Dstrtoll=_strtoi64
|
||||
check_func strtoull || add_cflags -Dstrtoull=_strtoui64
|
||||
fi
|
||||
|
||||
for pfx in "" host_; do
|
||||
@@ -6406,7 +6412,7 @@ cat > $TMPH <<EOF
|
||||
#define FFMPEG_CONFIG_H
|
||||
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
|
||||
#define FFMPEG_LICENSE "$(c_escape $license)"
|
||||
#define CONFIG_THIS_YEAR 2016
|
||||
#define CONFIG_THIS_YEAR 2017
|
||||
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
|
||||
#define AVCONV_DATADIR "$(eval c_escape $datadir)"
|
||||
#define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 3.0.3
|
||||
PROJECT_NUMBER = 3.0.7
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
@@ -93,10 +93,9 @@ static int decode_packet(int *got_frame, int cached)
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("video_frame%s n:%d coded_n:%d pts:%s\n",
|
||||
printf("video_frame%s n:%d coded_n:%d\n",
|
||||
cached ? "(cached)" : "",
|
||||
video_frame_count++, frame->coded_picture_number,
|
||||
av_ts2timestr(frame->pts, &video_dec_ctx->time_base));
|
||||
video_frame_count++, frame->coded_picture_number);
|
||||
|
||||
/* copy decoded frame to destination buffer:
|
||||
* this is required since rawvideo expects non aligned data */
|
||||
|
||||
+9
-9
@@ -12,7 +12,7 @@
|
||||
|
||||
@chapter Synopsis
|
||||
|
||||
ffmpeg [@var{global_options}] @{[@var{input_file_options}] -i @file{input_file}@} ... @{[@var{output_file_options}] @file{output_file}@} ...
|
||||
ffmpeg [@var{global_options}] @{[@var{input_file_options}] -i @file{input_url}@} ... @{[@var{output_file_options}] @file{output_url}@} ...
|
||||
|
||||
@chapter Description
|
||||
@c man begin DESCRIPTION
|
||||
@@ -24,10 +24,10 @@ rates and resize video on the fly with a high quality polyphase filter.
|
||||
@command{ffmpeg} reads from an arbitrary number of input "files" (which can be regular
|
||||
files, pipes, network streams, grabbing devices, etc.), specified by the
|
||||
@code{-i} option, and writes to an arbitrary number of output "files", which are
|
||||
specified by a plain output filename. Anything found on the command line which
|
||||
cannot be interpreted as an option is considered to be an output filename.
|
||||
specified by a plain output url. Anything found on the command line which
|
||||
cannot be interpreted as an option is considered to be an output url.
|
||||
|
||||
Each input or output file can, in principle, contain any number of streams of
|
||||
Each input or output url can, in principle, contain any number of streams of
|
||||
different types (video/audio/subtitle/attachment/data). The allowed number and/or
|
||||
types of streams may be limited by the container format. Selecting which
|
||||
streams from which inputs will go into which output is either done automatically
|
||||
@@ -243,8 +243,8 @@ Force input or output file format. The format is normally auto detected for inpu
|
||||
files and guessed from the file extension for output files, so this option is not
|
||||
needed in most cases.
|
||||
|
||||
@item -i @var{filename} (@emph{input})
|
||||
input file name
|
||||
@item -i @var{url} (@emph{input})
|
||||
input file url
|
||||
|
||||
@item -y (@emph{global})
|
||||
Overwrite output files without asking.
|
||||
@@ -281,7 +281,7 @@ libx264, and the 138th audio, which will be encoded with libvorbis.
|
||||
When used as an input option (before @code{-i}), limit the @var{duration} of
|
||||
data read from the input file.
|
||||
|
||||
When used as an output option (before an output filename), stop writing the
|
||||
When used as an output option (before an output url), stop writing the
|
||||
output after its duration reaches @var{duration}.
|
||||
|
||||
@var{duration} must be a time duration specification,
|
||||
@@ -310,7 +310,7 @@ extra segment between the seek point and @var{position} will be decoded and
|
||||
discarded. When doing stream copy or when @option{-noaccurate_seek} is used, it
|
||||
will be preserved.
|
||||
|
||||
When used as an output option (before an output filename), decodes but discards
|
||||
When used as an output option (before an output url), decodes but discards
|
||||
input until the timestamps reach @var{position}.
|
||||
|
||||
@var{position} must be a time duration specification,
|
||||
@@ -1129,7 +1129,7 @@ may be reassigned to a different value.
|
||||
For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
|
||||
an output mpegts file:
|
||||
@example
|
||||
ffmpeg -i infile -streamid 0:33 -streamid 1:36 out.ts
|
||||
ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
|
||||
@end example
|
||||
|
||||
@item -bsf[:@var{stream_specifier}] @var{bitstream_filters} (@emph{output,per-stream})
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@
|
||||
|
||||
@chapter Synopsis
|
||||
|
||||
ffplay [@var{options}] [@file{input_file}]
|
||||
ffplay [@var{options}] [@file{input_url}]
|
||||
|
||||
@chapter Description
|
||||
@c man begin DESCRIPTION
|
||||
@@ -106,8 +106,8 @@ the input audio.
|
||||
Use the option "-filters" to show all the available filters (including
|
||||
sources and sinks).
|
||||
|
||||
@item -i @var{input_file}
|
||||
Read @var{input_file}.
|
||||
@item -i @var{input_url}
|
||||
Read @var{input_url}.
|
||||
@end table
|
||||
|
||||
@section Advanced options
|
||||
|
||||
+5
-5
@@ -12,7 +12,7 @@
|
||||
|
||||
@chapter Synopsis
|
||||
|
||||
ffprobe [@var{options}] [@file{input_file}]
|
||||
ffprobe [@var{options}] [@file{input_url}]
|
||||
|
||||
@chapter Description
|
||||
@c man begin DESCRIPTION
|
||||
@@ -24,8 +24,8 @@ For example it can be used to check the format of the container used
|
||||
by a multimedia stream and the format and type of each media stream
|
||||
contained in it.
|
||||
|
||||
If a filename is specified in input, ffprobe will try to open and
|
||||
probe the file content. If the file cannot be opened or recognized as
|
||||
If a url is specified in input, ffprobe will try to open and
|
||||
probe the url content. If the url cannot be opened or recognized as
|
||||
a multimedia file, a positive exit code is returned.
|
||||
|
||||
ffprobe may be employed both as a standalone application or in
|
||||
@@ -332,8 +332,8 @@ with name "PIXEL_FORMAT".
|
||||
Force bitexact output, useful to produce output which is not dependent
|
||||
on the specific build.
|
||||
|
||||
@item -i @var{input_file}
|
||||
Read @var{input_file}.
|
||||
@item -i @var{input_url}
|
||||
Read @var{input_url}.
|
||||
|
||||
@end table
|
||||
@c man end
|
||||
|
||||
@@ -205,6 +205,10 @@ For example to separate the fields with newlines and indention:
|
||||
ffprobe -dump_separator "
|
||||
" -i ~/videos/matrixbench_mpeg2.mpg
|
||||
@end example
|
||||
|
||||
@item max_streams @var{integer} (@emph{input})
|
||||
Specifies the maximum number of streams. This can be used to reject files that
|
||||
would require too many resources due to a large number of streams.
|
||||
@end table
|
||||
|
||||
@c man end FORMAT OPTIONS
|
||||
|
||||
@@ -2014,12 +2014,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
|
||||
}
|
||||
}
|
||||
|
||||
/* if the decoder provides a pts, use it instead of the last packet pts.
|
||||
the decoder could be delaying output by a packet or more. */
|
||||
if (decoded_frame->pts != AV_NOPTS_VALUE) {
|
||||
ist->dts = ist->next_dts = ist->pts = ist->next_pts = av_rescale_q(decoded_frame->pts, avctx->time_base, AV_TIME_BASE_Q);
|
||||
decoded_frame_tb = avctx->time_base;
|
||||
} else if (decoded_frame->pkt_pts != AV_NOPTS_VALUE) {
|
||||
if (decoded_frame->pkt_pts != AV_NOPTS_VALUE) {
|
||||
decoded_frame->pts = decoded_frame->pkt_pts;
|
||||
decoded_frame_tb = ist->st->time_base;
|
||||
} else if (pkt->pts != AV_NOPTS_VALUE) {
|
||||
|
||||
+2
-2
@@ -2989,8 +2989,8 @@ enum OptGroup {
|
||||
};
|
||||
|
||||
static const OptionGroupDef groups[] = {
|
||||
[GROUP_OUTFILE] = { "output file", NULL, OPT_OUTPUT },
|
||||
[GROUP_INFILE] = { "input file", "i", OPT_INPUT },
|
||||
[GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
|
||||
[GROUP_INFILE] = { "input url", "i", OPT_INPUT },
|
||||
};
|
||||
|
||||
static int open_files(OptionGroupList *l, const char *inout,
|
||||
|
||||
+4
-1
@@ -2701,8 +2701,10 @@ static int http_receive_data(HTTPContext *c)
|
||||
} else if (c->buffer_ptr - c->buffer >= 2 &&
|
||||
!memcmp(c->buffer_ptr - 1, "\r\n", 2)) {
|
||||
c->chunk_size = strtol(c->buffer, 0, 16);
|
||||
if (c->chunk_size == 0) // end of stream
|
||||
if (c->chunk_size <= 0) { // end of stream or invalid chunk size
|
||||
c->chunk_size = 0;
|
||||
goto fail;
|
||||
}
|
||||
c->buffer_ptr = c->buffer;
|
||||
break;
|
||||
} else if (++loop_run > 10)
|
||||
@@ -2724,6 +2726,7 @@ static int http_receive_data(HTTPContext *c)
|
||||
/* end of connection : close it */
|
||||
goto fail;
|
||||
else {
|
||||
av_assert0(len <= c->chunk_size);
|
||||
c->chunk_size -= len;
|
||||
c->buffer_ptr += len;
|
||||
c->data_count += len;
|
||||
|
||||
+5
-2
@@ -120,12 +120,15 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
|
||||
if (avctx->bits_per_coded_sample <= 8) {
|
||||
int size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt,
|
||||
AV_PKT_DATA_PALETTE,
|
||||
NULL);
|
||||
if (pal) {
|
||||
&size);
|
||||
if (pal && size == AVPALETTE_SIZE) {
|
||||
frame->palette_has_changed = 1;
|
||||
memcpy(c->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
|
||||
}
|
||||
|
||||
memcpy (frame->data[1], c->pal, AVPALETTE_SIZE);
|
||||
|
||||
@@ -94,6 +94,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
int ret = ff_set_dimensions(avctx, 80 << 3, 25 << 4);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else if (avctx->width % FONT_WIDTH || avctx->height % s->font_height) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid dimensions %d %d\n", avctx->width, avctx->height);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ static inline void asv2_put_level(ASV1Context *a, PutBitContext *pb, int level)
|
||||
} else {
|
||||
put_bits(pb, ff_asv2_level_tab[31][1], ff_asv2_level_tab[31][0]);
|
||||
if (level < -128 || level > 127) {
|
||||
av_log(a->avctx, AV_LOG_WARNING, "Cliping level %d, increase qscale\n", level);
|
||||
av_log(a->avctx, AV_LOG_WARNING, "Clipping level %d, increase qscale\n", level);
|
||||
level = av_clip_int8(level);
|
||||
}
|
||||
asv2_put_bits(pb, 8, level & 0xFF);
|
||||
|
||||
@@ -184,6 +184,7 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
|
||||
{
|
||||
pkt->data = NULL;
|
||||
pkt->side_data = NULL;
|
||||
pkt->side_data_elems = 0;
|
||||
if (pkt->buf) {
|
||||
AVBufferRef *ref = av_buffer_ref(src->buf);
|
||||
if (!ref)
|
||||
@@ -193,9 +194,11 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
|
||||
} else {
|
||||
DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
|
||||
}
|
||||
if (pkt->side_data_elems && dup)
|
||||
if (src->side_data_elems && dup) {
|
||||
pkt->side_data = src->side_data;
|
||||
if (pkt->side_data_elems && !dup) {
|
||||
pkt->side_data_elems = src->side_data_elems;
|
||||
}
|
||||
if (src->side_data_elems && !dup) {
|
||||
return av_copy_packet_side_data(pkt, src);
|
||||
}
|
||||
return 0;
|
||||
@@ -277,16 +280,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
uint8_t *data, size_t size)
|
||||
{
|
||||
AVPacketSideData *tmp;
|
||||
int elems = pkt->side_data_elems;
|
||||
|
||||
if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
|
||||
return AVERROR(ERANGE);
|
||||
|
||||
pkt->side_data = av_realloc(pkt->side_data,
|
||||
(elems + 1) * sizeof(*pkt->side_data));
|
||||
if (!pkt->side_data)
|
||||
tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
|
||||
if (!tmp)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
pkt->side_data = tmp;
|
||||
pkt->side_data[elems].data = data;
|
||||
pkt->side_data[elems].size = size;
|
||||
pkt->side_data[elems].type = type;
|
||||
|
||||
@@ -1217,6 +1217,8 @@ static int cavs_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
h->got_keyframe = 1;
|
||||
}
|
||||
case PIC_PB_START_CODE:
|
||||
if (*got_frame)
|
||||
av_frame_unref(data);
|
||||
*got_frame = 0;
|
||||
if (!h->got_keyframe)
|
||||
break;
|
||||
|
||||
@@ -188,7 +188,6 @@ static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc
|
||||
static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) {
|
||||
int i;
|
||||
int16_t (*src)[8] = (int16_t(*)[8])block;
|
||||
const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
|
||||
|
||||
src[0][0] += 8;
|
||||
|
||||
@@ -243,14 +242,14 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) {
|
||||
const int b2 = a5 - a7;
|
||||
const int b3 = a4 - a6;
|
||||
|
||||
dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4) >> 7)];
|
||||
dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5) >> 7)];
|
||||
dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6) >> 7)];
|
||||
dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7) >> 7)];
|
||||
dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7) >> 7)];
|
||||
dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6) >> 7)];
|
||||
dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5) >> 7)];
|
||||
dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4) >> 7)];
|
||||
dst[i + 0*stride] = av_clip_uint8( dst[i + 0*stride] + ((b0 + b4) >> 7));
|
||||
dst[i + 1*stride] = av_clip_uint8( dst[i + 1*stride] + ((b1 + b5) >> 7));
|
||||
dst[i + 2*stride] = av_clip_uint8( dst[i + 2*stride] + ((b2 + b6) >> 7));
|
||||
dst[i + 3*stride] = av_clip_uint8( dst[i + 3*stride] + ((b3 + b7) >> 7));
|
||||
dst[i + 4*stride] = av_clip_uint8( dst[i + 4*stride] + ((b3 - b7) >> 7));
|
||||
dst[i + 5*stride] = av_clip_uint8( dst[i + 5*stride] + ((b2 - b6) >> 7));
|
||||
dst[i + 6*stride] = av_clip_uint8( dst[i + 6*stride] + ((b1 - b5) >> 7));
|
||||
dst[i + 7*stride] = av_clip_uint8( dst[i + 7*stride] + ((b0 - b4) >> 7));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-16
@@ -135,7 +135,8 @@ typedef struct CCaptionSubContext {
|
||||
int64_t last_real_time;
|
||||
char prev_cmd[2];
|
||||
/* buffer to store pkt data */
|
||||
AVBufferRef *pktbuf;
|
||||
uint8_t *pktbuf;
|
||||
int pktbuf_size;
|
||||
} CCaptionSubContext;
|
||||
|
||||
|
||||
@@ -160,11 +161,7 @@ static av_cold int init_decoder(AVCodecContext *avctx)
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
/* allocate pkt buffer */
|
||||
ctx->pktbuf = av_buffer_alloc(128);
|
||||
if (!ctx->pktbuf) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -172,7 +169,8 @@ static av_cold int close_decoder(AVCodecContext *avctx)
|
||||
{
|
||||
CCaptionSubContext *ctx = avctx->priv_data;
|
||||
av_bprint_finalize(&ctx->buffer, NULL);
|
||||
av_buffer_unref(&ctx->pktbuf);
|
||||
av_freep(&ctx->pktbuf);
|
||||
ctx->pktbuf_size = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -578,16 +576,13 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
if (ctx->pktbuf->size < len) {
|
||||
ret = av_buffer_realloc(&ctx->pktbuf, len);
|
||||
if (ret < 0) {
|
||||
av_log(ctx, AV_LOG_WARNING, "Insufficient Memory of %d truncated to %d\n", len, ctx->pktbuf->size);
|
||||
len = ctx->pktbuf->size;
|
||||
ret = 0;
|
||||
}
|
||||
av_fast_padded_malloc(&ctx->pktbuf, &ctx->pktbuf_size, len);
|
||||
if (!ctx->pktbuf) {
|
||||
av_log(ctx, AV_LOG_WARNING, "Insufficient Memory of %d truncated to %d\n", len, ctx->pktbuf_size);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
memcpy(ctx->pktbuf->data, avpkt->data, len);
|
||||
bptr = ctx->pktbuf->data;
|
||||
memcpy(ctx->pktbuf, avpkt->data, len);
|
||||
bptr = ctx->pktbuf;
|
||||
|
||||
for (i = 0; i < len; i += 3) {
|
||||
uint8_t cc_type = *(bptr + i) & 3;
|
||||
|
||||
@@ -443,10 +443,13 @@ static int cinepak_decode_frame(AVCodecContext *avctx,
|
||||
return ret;
|
||||
|
||||
if (s->palette_video) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
if (pal) {
|
||||
int size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
|
||||
if (pal && size == AVPALETTE_SIZE) {
|
||||
s->frame->palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1900,7 +1900,9 @@ static int dirac_decode_picture_header(DiracContext *s)
|
||||
for (j = 0; j < MAX_FRAMES; j++)
|
||||
if (!s->all_frames[j].avframe->data[0]) {
|
||||
s->ref_pics[i] = &s->all_frames[j];
|
||||
get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
|
||||
ret = get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -810,7 +810,7 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h)
|
||||
list_inv[ i ] = bestv;
|
||||
}
|
||||
|
||||
count = i - 1;
|
||||
count = FFMAX(i - 1, 1);
|
||||
for (i--; i>=0; i--) {
|
||||
int v = i*255/count;
|
||||
AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));
|
||||
|
||||
@@ -185,7 +185,7 @@ static void guess_palette(DVDSubContext* ctx,
|
||||
for(i = 0; i < 4; i++) {
|
||||
if (alpha[i] != 0) {
|
||||
if (!color_used[colormap[i]]) {
|
||||
level = level_map[nb_opaque_colors][j];
|
||||
level = level_map[nb_opaque_colors - 1][j];
|
||||
r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
|
||||
g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
|
||||
b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
|
||||
@@ -548,7 +548,8 @@ static int append_to_cached_buf(AVCodecContext *avctx,
|
||||
{
|
||||
DVDSubContext *ctx = avctx->priv_data;
|
||||
|
||||
if (ctx->buf_size >= sizeof(ctx->buf) - buf_size) {
|
||||
av_assert0(buf_size >= 0 && ctx->buf_size <= sizeof(ctx->buf));
|
||||
if (buf_size >= sizeof(ctx->buf) - ctx->buf_size) {
|
||||
av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "
|
||||
"too large SPU packets aborted.\n");
|
||||
ctx->buf_size = 0;
|
||||
|
||||
@@ -250,6 +250,10 @@ static int escape124_decode_frame(AVCodecContext *avctx,
|
||||
// This codebook can be cut off at places other than
|
||||
// powers of 2, leaving some of the entries undefined.
|
||||
cb_size = get_bits_long(&gb, 20);
|
||||
if (!cb_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid codebook size 0.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
cb_depth = av_log2(cb_size - 1) + 1;
|
||||
} else {
|
||||
cb_depth = get_bits(&gb, 4);
|
||||
|
||||
+14
-4
@@ -1222,7 +1222,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
FFV1Context *f = avctx->priv_data;
|
||||
RangeCoder *const c = &f->slice_context[0]->c;
|
||||
AVFrame *const p = f->picture.f;
|
||||
int used_count = 0;
|
||||
uint8_t keystate = 128;
|
||||
uint8_t *buf_p;
|
||||
int i, ret;
|
||||
@@ -1278,6 +1277,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
if (f->version > 3)
|
||||
maxsize = AV_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*3LL*4;
|
||||
|
||||
if (maxsize > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 32) {
|
||||
av_log(avctx, AV_LOG_WARNING, "Cannot allocate worst case packet size, the encoding could fail\n");
|
||||
maxsize = INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 32;
|
||||
}
|
||||
|
||||
if ((ret = ff_alloc_packet2(avctx, pkt, maxsize, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
@@ -1307,11 +1311,17 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i < f->slice_count; i++) {
|
||||
for (i = 0; i < f->slice_count; i++) {
|
||||
FFV1Context *fs = f->slice_context[i];
|
||||
uint8_t *start = pkt->data + (pkt->size - used_count) * (int64_t)i / f->slice_count;
|
||||
uint8_t *start = pkt->data + pkt->size * (int64_t)i / f->slice_count;
|
||||
int len = pkt->size / f->slice_count;
|
||||
ff_init_range_encoder(&fs->c, start, len);
|
||||
if (i) {
|
||||
ff_init_range_encoder(&fs->c, start, len);
|
||||
} else {
|
||||
av_assert0(fs->c.bytestream_end >= fs->c.bytestream_start + len);
|
||||
av_assert0(fs->c.bytestream < fs->c.bytestream_start + len);
|
||||
fs->c.bytestream_end = fs->c.bytestream_start + len;
|
||||
}
|
||||
}
|
||||
avctx->execute(avctx, encode_slice, &f->slice_context[0], NULL,
|
||||
f->slice_count, sizeof(void *));
|
||||
|
||||
@@ -586,10 +586,12 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
||||
temp = curr->next;
|
||||
av_freep(&curr->link_penalty);
|
||||
av_free(curr);
|
||||
fpc->nb_headers_buffered--;
|
||||
}
|
||||
fpc->headers = fpc->best_header->next;
|
||||
av_freep(&fpc->best_header->link_penalty);
|
||||
av_freep(&fpc->best_header);
|
||||
fpc->nb_headers_buffered--;
|
||||
}
|
||||
|
||||
/* Find and score new headers. */
|
||||
|
||||
@@ -268,7 +268,8 @@ static int decode_subframe_fixed(FLACContext *s, int32_t *decoded,
|
||||
int pred_order, int bps)
|
||||
{
|
||||
const int blocksize = s->blocksize;
|
||||
int av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d), i;
|
||||
unsigned av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d);
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
/* warm up samples */
|
||||
@@ -447,7 +448,7 @@ static inline int decode_subframe(FLACContext *s, int channel)
|
||||
if (wasted) {
|
||||
int i;
|
||||
for (i = 0; i < s->blocksize; i++)
|
||||
decoded[i] <<= wasted;
|
||||
decoded[i] = (unsigned)decoded[i] << wasted;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -56,7 +56,7 @@ static void FUNC(flac_decorrelate_indep_c)(uint8_t **out, int32_t **in,
|
||||
|
||||
for (j = 0; j < len; j++)
|
||||
for (i = 0; i < channels; i++)
|
||||
S(samples, i, j) = in[i][j] << shift;
|
||||
S(samples, i, j) = (int)((unsigned)in[i][j] << shift);
|
||||
}
|
||||
|
||||
static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in,
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ static int16_t g726_decode(G726Context* c, int I)
|
||||
|
||||
if (I_sig) /* get the sign */
|
||||
dq = -dq;
|
||||
re_signal = c->se + dq;
|
||||
re_signal = (int16_t)(c->se + dq);
|
||||
|
||||
/* Update second order predictor coefficient A2 and A1 */
|
||||
pk0 = (c->sez + dq) ? sgn(c->sez + dq) : 0;
|
||||
|
||||
@@ -382,6 +382,10 @@ static inline uint64_t get_bits64(GetBitContext *s, int n)
|
||||
*/
|
||||
static inline int get_sbits_long(GetBitContext *s, int n)
|
||||
{
|
||||
// sign_extend(x, 0) is undefined
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
return sign_extend(get_bits_long(s, n), n);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -1591,7 +1591,9 @@ again:
|
||||
#endif
|
||||
} else
|
||||
context_count++;
|
||||
}
|
||||
} else
|
||||
sl->ref_count[0] = sl->ref_count[1] = 0;
|
||||
break;
|
||||
break;
|
||||
case NAL_DPA:
|
||||
case NAL_DPB:
|
||||
|
||||
@@ -214,7 +214,8 @@ static int idcin_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
IdcinContext *s = avctx->priv_data;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
int pal_size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
|
||||
AVFrame *frame = data;
|
||||
int ret;
|
||||
|
||||
@@ -227,9 +228,11 @@ static int idcin_decode_frame(AVCodecContext *avctx,
|
||||
if (idcin_decode_vlcs(s, frame))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (pal) {
|
||||
if (pal && pal_size == AVPALETTE_SIZE) {
|
||||
frame->palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
|
||||
}
|
||||
/* make the palette available on the way out */
|
||||
memcpy(frame->data[1], s->pal, AVPALETTE_SIZE);
|
||||
|
||||
@@ -61,6 +61,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
if (avctx->extradata_size < 14)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (avctx->channels <= 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels: %d\n", avctx->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
s->level = AV_RL16(avctx->extradata + 12) & 0xf;
|
||||
s->rows = AV_RL16(avctx->extradata + 12) >> 4;
|
||||
s->cols = 1 << s->level;
|
||||
@@ -71,7 +76,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
s->block = av_calloc(s->block_len, sizeof(int));
|
||||
s->wrapbuf = av_calloc(s->wrapbuf_len, sizeof(int));
|
||||
s->ampbuf = av_calloc(0x10000, sizeof(int));
|
||||
s->bitstream = av_calloc(s->max_framesize, sizeof(*s->bitstream));
|
||||
s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*s->bitstream) + 1, sizeof(*s->bitstream));
|
||||
if (!s->block || !s->wrapbuf || !s->ampbuf || !s->bitstream)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -325,6 +330,10 @@ static int t15(InterplayACMContext *s, unsigned ind, unsigned col)
|
||||
for (i = 0; i < s->rows; i++) {
|
||||
/* b = (x1) + (x2 * 3) + (x3 * 9) */
|
||||
b = get_bits(gb, 5);
|
||||
if (b > 26) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Too large b = %d > 26\n", b);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
n1 = (mul_3x3[b] & 0x0F) - 1;
|
||||
n2 = ((mul_3x3[b] >> 4) & 0x0F) - 1;
|
||||
@@ -350,6 +359,10 @@ static int t27(InterplayACMContext *s, unsigned ind, unsigned col)
|
||||
for (i = 0; i < s->rows; i++) {
|
||||
/* b = (x1) + (x2 * 5) + (x3 * 25) */
|
||||
b = get_bits(gb, 7);
|
||||
if (b > 124) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Too large b = %d > 124\n", b);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
n1 = (mul_3x5[b] & 0x0F) - 2;
|
||||
n2 = ((mul_3x5[b] >> 4) & 0x0F) - 2;
|
||||
@@ -374,6 +387,10 @@ static int t37(InterplayACMContext *s, unsigned ind, unsigned col)
|
||||
for (i = 0; i < s->rows; i++) {
|
||||
/* b = (x1) + (x2 * 11) */
|
||||
b = get_bits(gb, 7);
|
||||
if (b > 120) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Too large b = %d > 120\n", b);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
n1 = (mul_2x11[b] & 0x0F) - 5;
|
||||
n2 = ((mul_2x11[b] >> 4) & 0x0F) - 5;
|
||||
|
||||
@@ -988,6 +988,11 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
|
||||
AVFrame *frame = data;
|
||||
int ret;
|
||||
|
||||
if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) {
|
||||
av_frame_unref(s->last_frame);
|
||||
av_frame_unref(s->second_last_frame);
|
||||
}
|
||||
|
||||
if (buf_size < 2)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
@@ -999,10 +1004,6 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
|
||||
if (buf_size < s->decoding_map_size + 2)
|
||||
return buf_size;
|
||||
|
||||
if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) {
|
||||
av_frame_unref(s->last_frame);
|
||||
av_frame_unref(s->second_last_frame);
|
||||
}
|
||||
|
||||
s->decoding_map = buf + 2;
|
||||
bytestream2_init(&s->stream_ptr, buf + 2 + s->decoding_map_size,
|
||||
@@ -1012,10 +1013,13 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
|
||||
return ret;
|
||||
|
||||
if (!s->is_16bpp) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
if (pal) {
|
||||
int size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
|
||||
if (pal && size == AVPALETTE_SIZE) {
|
||||
frame->palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ static int h263_decode_gob_header(MpegEncContext *s)
|
||||
/* We have a GBSC probably with GSTUFF */
|
||||
skip_bits(&s->gb, 16); /* Drop the zeros */
|
||||
left= get_bits_left(&s->gb);
|
||||
left = FFMIN(left, 32);
|
||||
//MN: we must check the bits left or we might end in a infinite loop (or segfault)
|
||||
for(;left>13; left--){
|
||||
if(get_bits1(&s->gb)) break; /* Seek the '1' bit */
|
||||
|
||||
+5
-2
@@ -268,7 +268,8 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
|
||||
int i, ret;
|
||||
int header;
|
||||
int blocksize;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
int pal_size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
|
||||
|
||||
bytestream2_init(&ctx->g, avpkt->data, avpkt->size);
|
||||
|
||||
@@ -303,9 +304,11 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
|
||||
}
|
||||
}
|
||||
|
||||
if (pal) {
|
||||
if (pal && pal_size == AVPALETTE_SIZE) {
|
||||
frame->palette_has_changed = 1;
|
||||
memcpy(ctx->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
|
||||
}
|
||||
|
||||
if (ctx->setpal) {
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
* JPEG 2000 decoder using libopenjpeg
|
||||
*/
|
||||
|
||||
#define OPJ_STATIC
|
||||
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
|
||||
+38
-21
@@ -24,8 +24,6 @@
|
||||
* JPEG 2000 encoder using libopenjpeg
|
||||
*/
|
||||
|
||||
#define OPJ_STATIC
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
@@ -54,7 +52,9 @@
|
||||
|
||||
typedef struct LibOpenJPEGContext {
|
||||
AVClass *avclass;
|
||||
#if OPENJPEG_MAJOR_VERSION == 1
|
||||
opj_image_t *image;
|
||||
#endif // OPENJPEG_MAJOR_VERSION == 1
|
||||
opj_cparameters_t enc_params;
|
||||
#if OPENJPEG_MAJOR_VERSION == 1
|
||||
opj_event_mgr_t event_mgr;
|
||||
@@ -371,18 +371,22 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
|
||||
cinema_parameters(&ctx->enc_params);
|
||||
}
|
||||
|
||||
#if OPENJPEG_MAJOR_VERSION == 1
|
||||
ctx->image = mj2_create_image(avctx, &ctx->enc_params);
|
||||
if (!ctx->image) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error creating the mj2 image\n");
|
||||
err = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
#endif // OPENJPEG_MAJOR_VERSION == 1
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
#if OPENJPEG_MAJOR_VERSION == 1
|
||||
opj_image_destroy(ctx->image);
|
||||
ctx->image = NULL;
|
||||
#endif // OPENJPEG_MAJOR_VERSION == 1
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -417,7 +421,7 @@ static int libopenjpeg_copy_packed8(AVCodecContext *avctx, const AVFrame *frame,
|
||||
for (; y < image->comps[compno].h; ++y) {
|
||||
image_line = image->comps[compno].data + y * image->comps[compno].w;
|
||||
for (x = 0; x < image->comps[compno].w; ++x) {
|
||||
image_line[x] = image_line[x - image->comps[compno].w];
|
||||
image_line[x] = image_line[x - (int)image->comps[compno].w];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -457,7 +461,7 @@ static int libopenjpeg_copy_packed12(AVCodecContext *avctx, const AVFrame *frame
|
||||
for (; y < image->comps[compno].h; ++y) {
|
||||
image_line = image->comps[compno].data + y * image->comps[compno].w;
|
||||
for (x = 0; x < image->comps[compno].w; ++x) {
|
||||
image_line[x] = image_line[x - image->comps[compno].w];
|
||||
image_line[x] = image_line[x - (int)image->comps[compno].w];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -497,7 +501,7 @@ static int libopenjpeg_copy_packed16(AVCodecContext *avctx, const AVFrame *frame
|
||||
for (; y < image->comps[compno].h; ++y) {
|
||||
image_line = image->comps[compno].data + y * image->comps[compno].w;
|
||||
for (x = 0; x < image->comps[compno].w; ++x) {
|
||||
image_line[x] = image_line[x - image->comps[compno].w];
|
||||
image_line[x] = image_line[x - (int)image->comps[compno].w];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -524,8 +528,8 @@ static int libopenjpeg_copy_unpacked8(AVCodecContext *avctx, const AVFrame *fram
|
||||
}
|
||||
|
||||
for (compno = 0; compno < numcomps; ++compno) {
|
||||
width = avctx->width / image->comps[compno].dx;
|
||||
height = avctx->height / image->comps[compno].dy;
|
||||
width = (avctx->width + image->comps[compno].dx - 1) / image->comps[compno].dx;
|
||||
height = (avctx->height + image->comps[compno].dy - 1) / image->comps[compno].dy;
|
||||
for (y = 0; y < height; ++y) {
|
||||
image_line = image->comps[compno].data + y * image->comps[compno].w;
|
||||
frame_index = y * frame->linesize[compno];
|
||||
@@ -538,7 +542,7 @@ static int libopenjpeg_copy_unpacked8(AVCodecContext *avctx, const AVFrame *fram
|
||||
for (; y < image->comps[compno].h; ++y) {
|
||||
image_line = image->comps[compno].data + y * image->comps[compno].w;
|
||||
for (x = 0; x < image->comps[compno].w; ++x) {
|
||||
image_line[x] = image_line[x - image->comps[compno].w];
|
||||
image_line[x] = image_line[x - (int)image->comps[compno].w];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -566,8 +570,8 @@ static int libopenjpeg_copy_unpacked16(AVCodecContext *avctx, const AVFrame *fra
|
||||
}
|
||||
|
||||
for (compno = 0; compno < numcomps; ++compno) {
|
||||
width = avctx->width / image->comps[compno].dx;
|
||||
height = avctx->height / image->comps[compno].dy;
|
||||
width = (avctx->width + image->comps[compno].dx - 1) / image->comps[compno].dx;
|
||||
height = (avctx->height + image->comps[compno].dy - 1) / image->comps[compno].dy;
|
||||
frame_ptr = (uint16_t *)frame->data[compno];
|
||||
for (y = 0; y < height; ++y) {
|
||||
image_line = image->comps[compno].data + y * image->comps[compno].w;
|
||||
@@ -581,7 +585,7 @@ static int libopenjpeg_copy_unpacked16(AVCodecContext *avctx, const AVFrame *fra
|
||||
for (; y < image->comps[compno].h; ++y) {
|
||||
image_line = image->comps[compno].data + y * image->comps[compno].w;
|
||||
for (x = 0; x < image->comps[compno].w; ++x) {
|
||||
image_line[x] = image_line[x - image->comps[compno].w];
|
||||
image_line[x] = image_line[x - (int)image->comps[compno].w];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -593,18 +597,24 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
const AVFrame *frame, int *got_packet)
|
||||
{
|
||||
LibOpenJPEGContext *ctx = avctx->priv_data;
|
||||
opj_image_t *image = ctx->image;
|
||||
int ret;
|
||||
AVFrame *gbrframe;
|
||||
int cpyresult = 0;
|
||||
#if OPENJPEG_MAJOR_VERSION == 1
|
||||
opj_image_t *image = ctx->image;
|
||||
opj_cinfo_t *compress = NULL;
|
||||
opj_cio_t *stream = NULL;
|
||||
int len;
|
||||
#else // OPENJPEG_MAJOR_VERSION == 2
|
||||
opj_codec_t *compress = NULL;
|
||||
opj_stream_t *stream = NULL;
|
||||
opj_image_t *image = mj2_create_image(avctx, &ctx->enc_params);
|
||||
if (!image) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error creating the mj2 image\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
goto done;
|
||||
}
|
||||
#endif // OPENJPEG_MAJOR_VERSION == 1
|
||||
int cpyresult = 0;
|
||||
int ret;
|
||||
AVFrame *gbrframe;
|
||||
|
||||
switch (avctx->pix_fmt) {
|
||||
case AV_PIX_FMT_RGB24:
|
||||
@@ -627,8 +637,10 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
case AV_PIX_FMT_GBRP14:
|
||||
case AV_PIX_FMT_GBRP16:
|
||||
gbrframe = av_frame_clone(frame);
|
||||
if (!gbrframe)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!gbrframe) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto done;
|
||||
}
|
||||
gbrframe->data[0] = frame->data[2]; // swap to be rgb
|
||||
gbrframe->data[1] = frame->data[0];
|
||||
gbrframe->data[2] = frame->data[1];
|
||||
@@ -685,19 +697,21 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"The frame's pixel format '%s' is not supported\n",
|
||||
av_get_pix_fmt_name(avctx->pix_fmt));
|
||||
return AVERROR(EINVAL);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!cpyresult) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Could not copy the frame data to the internal image buffer\n");
|
||||
return -1;
|
||||
ret = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
#if OPENJPEG_MAJOR_VERSION == 2
|
||||
if ((ret = ff_alloc_packet2(avctx, pkt, 1024, 0)) < 0) {
|
||||
return ret;
|
||||
goto done;
|
||||
}
|
||||
#endif // OPENJPEG_MAJOR_VERSION == 2
|
||||
|
||||
@@ -764,7 +778,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
#error Missing call to opj_stream_set_user_data
|
||||
#endif
|
||||
|
||||
if (!opj_start_compress(compress, ctx->image, stream) ||
|
||||
if (!opj_start_compress(compress, image, stream) ||
|
||||
!opj_encode(compress, stream) ||
|
||||
!opj_end_compress(compress, stream)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error during the opj encode\n");
|
||||
@@ -783,6 +797,7 @@ done:
|
||||
#if OPENJPEG_MAJOR_VERSION == 2
|
||||
opj_stream_destroy(stream);
|
||||
opj_destroy_codec(compress);
|
||||
opj_image_destroy(image);
|
||||
#else
|
||||
opj_cio_close(stream);
|
||||
opj_destroy_compress(compress);
|
||||
@@ -792,10 +807,12 @@ done:
|
||||
|
||||
static av_cold int libopenjpeg_encode_close(AVCodecContext *avctx)
|
||||
{
|
||||
#if OPENJPEG_MAJOR_VERSION == 1
|
||||
LibOpenJPEGContext *ctx = avctx->priv_data;
|
||||
|
||||
opj_image_destroy(ctx->image);
|
||||
ctx->image = NULL;
|
||||
#endif // OPENJPEG_MAJOR_VERSION == 1
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,13 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
|
||||
int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled;
|
||||
uint8_t mapping_arr[8] = { 0, 1 }, *mapping;
|
||||
|
||||
avc->channels = avc->extradata_size >= 10 ? avc->extradata[9] : (avc->channels == 1) ? 1 : 2;
|
||||
if (avc->channels <= 0) {
|
||||
av_log(avc, AV_LOG_WARNING,
|
||||
"Invalid number of channels %d, defaulting to stereo\n", avc->channels);
|
||||
avc->channels = 2;
|
||||
}
|
||||
|
||||
avc->sample_rate = 48000;
|
||||
avc->sample_fmt = avc->request_sample_fmt == AV_SAMPLE_FMT_FLT ?
|
||||
AV_SAMPLE_FMT_FLT : AV_SAMPLE_FMT_S16;
|
||||
|
||||
@@ -218,6 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx,
|
||||
int outer = 1;
|
||||
SchroParseUnitContext parse_ctx;
|
||||
LibSchroFrameContext *framewithpts = NULL;
|
||||
int ret;
|
||||
|
||||
*got_frame = 0;
|
||||
|
||||
@@ -307,11 +308,10 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx,
|
||||
/* Grab next frame to be returned from the top of the queue. */
|
||||
framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue);
|
||||
|
||||
if (framewithpts && framewithpts->frame) {
|
||||
int ret;
|
||||
if (framewithpts && framewithpts->frame && framewithpts->frame->components[0].stride) {
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
memcpy(avframe->data[0],
|
||||
framewithpts->frame->components[0].data,
|
||||
@@ -332,15 +332,17 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx,
|
||||
avframe->linesize[2] = framewithpts->frame->components[2].stride;
|
||||
|
||||
*got_frame = 1;
|
||||
|
||||
/* Now free the frame resources. */
|
||||
libschroedinger_decode_frame_free(framewithpts->frame);
|
||||
av_free(framewithpts);
|
||||
} else {
|
||||
data = NULL;
|
||||
*got_frame = 0;
|
||||
}
|
||||
return buf_size;
|
||||
ret = buf_size;
|
||||
end:
|
||||
/* Now free the frame resources. */
|
||||
if (framewithpts && framewithpts->frame)
|
||||
libschroedinger_decode_frame_free(framewithpts->frame);
|
||||
av_freep(&framewithpts);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
|
||||
ret = av_reallocp(buf, *size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
p = *buf + len;
|
||||
}
|
||||
|
||||
bytestream2_get_buffer(gb, p, s);
|
||||
@@ -75,6 +76,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
|
||||
ret = av_reallocp(buf, *size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
p = *buf + len;
|
||||
}
|
||||
|
||||
av_memcpy_backptr(p, off, l);
|
||||
|
||||
@@ -1076,6 +1076,10 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
|
||||
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
||||
if (get_bits_left(&s->gb) < 1) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "bitstream end in yuv_scan\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (s->restart_interval && !s->restart_count){
|
||||
s->restart_count = s->restart_interval;
|
||||
resync_mb_x = mb_x;
|
||||
@@ -1387,6 +1391,10 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
|
||||
int block_idx = mb_y * s->block_stride[c];
|
||||
int16_t (*block)[64] = &s->blocks[c][block_idx];
|
||||
uint8_t *last_nnz = &s->last_nnz[c][block_idx];
|
||||
if (get_bits_left(&s->gb) <= 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "bitstream truncated in mjpeg_decode_scan_progressive_ac\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) {
|
||||
int ret;
|
||||
if (s->restart_interval && !s->restart_count)
|
||||
@@ -2366,7 +2374,7 @@ the_end:
|
||||
}
|
||||
}
|
||||
}
|
||||
if (s->flipped) {
|
||||
if (s->flipped && !s->rgb) {
|
||||
int j;
|
||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
|
||||
for (index=0; index<4; index++) {
|
||||
|
||||
+12
-3
@@ -115,6 +115,8 @@ static void mov_text_cleanup(MovTextContext *m)
|
||||
av_freep(&m->s[i]);
|
||||
}
|
||||
av_freep(&m->s);
|
||||
m->count_s = 0;
|
||||
m->style_entries = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,12 +280,14 @@ static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
|
||||
static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
|
||||
{
|
||||
int i;
|
||||
m->style_entries = AV_RB16(tsmb);
|
||||
int style_entries = AV_RB16(tsmb);
|
||||
tsmb += 2;
|
||||
// A single style record is of length 12 bytes.
|
||||
if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size)
|
||||
if (m->tracksize + m->size_var + 2 + style_entries * 12 > avpkt->size)
|
||||
return -1;
|
||||
|
||||
m->style_entries = style_entries;
|
||||
|
||||
m->box_flags |= STYL_BOX;
|
||||
for(i = 0; i < m->style_entries; i++) {
|
||||
m->s_temp = av_malloc(sizeof(*m->s_temp));
|
||||
@@ -487,7 +491,12 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
|
||||
m->size_var = 8;
|
||||
//size_var is equal to 8 or 16 depending on the size of box
|
||||
|
||||
if (m->tracksize + tsmb_size > avpkt->size)
|
||||
if (tsmb_size == 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "tsmb_size is 0\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (tsmb_size > avpkt->size - m->tracksize)
|
||||
break;
|
||||
|
||||
for (size_t i = 0; i < box_count; i++) {
|
||||
|
||||
@@ -2432,7 +2432,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
s->closed_gop = get_bits1(&s->gb);
|
||||
/* broken_link indicate that after editing the
|
||||
/* broken_link indicates that after editing the
|
||||
* reference frames of the first B-Frames after GOP I-Frame
|
||||
* are missing (open gop) */
|
||||
broken_link = get_bits1(&s->gb);
|
||||
@@ -2827,6 +2827,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data,
|
||||
avctx->extradata, avctx->extradata_size);
|
||||
if (*got_output) {
|
||||
av_log(avctx, AV_LOG_ERROR, "picture in extradata\n");
|
||||
av_frame_unref(picture);
|
||||
*got_output = 0;
|
||||
}
|
||||
s->extradata_decoded = 1;
|
||||
|
||||
@@ -315,13 +315,13 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
|
||||
min_ab = FFMIN(alpha, beta);
|
||||
w3 = w2 >> min_ab;
|
||||
h3 = h2 >> min_ab;
|
||||
s->sprite_offset[0][0] = (sprite_ref[0][0] << (alpha + beta + rho - min_ab)) +
|
||||
s->sprite_offset[0][0] = (sprite_ref[0][0] * (1<<(alpha + beta + rho - min_ab))) +
|
||||
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
|
||||
h3 * (-vop_ref[0][0]) +
|
||||
(-r * sprite_ref[0][0] + virtual_ref[1][0]) *
|
||||
w3 * (-vop_ref[0][1]) +
|
||||
(1 << (alpha + beta + rho - min_ab - 1));
|
||||
s->sprite_offset[0][1] = (sprite_ref[0][1] << (alpha + beta + rho - min_ab)) +
|
||||
s->sprite_offset[0][1] = (sprite_ref[0][1] * (1 << (alpha + beta + rho - min_ab))) +
|
||||
(-r * sprite_ref[0][1] + virtual_ref[0][1]) *
|
||||
h3 * (-vop_ref[0][0]) +
|
||||
(-r * sprite_ref[0][1] + virtual_ref[1][1]) *
|
||||
@@ -368,10 +368,10 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
|
||||
int shift_y = 16 - ctx->sprite_shift[0];
|
||||
int shift_c = 16 - ctx->sprite_shift[1];
|
||||
for (i = 0; i < 2; i++) {
|
||||
s->sprite_offset[0][i] <<= shift_y;
|
||||
s->sprite_offset[1][i] <<= shift_c;
|
||||
s->sprite_delta[0][i] <<= shift_y;
|
||||
s->sprite_delta[1][i] <<= shift_y;
|
||||
s->sprite_offset[0][i] *= 1 << shift_y;
|
||||
s->sprite_offset[1][i] *= 1 << shift_c;
|
||||
s->sprite_delta[0][i] *= 1 << shift_y;
|
||||
s->sprite_delta[1][i] *= 1 << shift_y;
|
||||
ctx->sprite_shift[i] = 16;
|
||||
}
|
||||
s->real_sprite_warping_points = ctx->num_sprite_warping_points;
|
||||
|
||||
@@ -98,7 +98,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
|
||||
} else if (codec_id == AV_CODEC_ID_MP3ADU) {
|
||||
avpriv_report_missing_feature(avctx,
|
||||
"MP3ADU full parser");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
return 0; /* parsers must not return error codes */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -2912,6 +2912,8 @@ int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t s
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
emms_c();
|
||||
|
||||
av_fast_padded_malloc(&new_buffer, &new_buffer_size,
|
||||
s->avctx->internal->byte_buffer_size + size_increase);
|
||||
if (!new_buffer)
|
||||
|
||||
+5
-2
@@ -99,11 +99,14 @@ static int msrle_decode_frame(AVCodecContext *avctx,
|
||||
return ret;
|
||||
|
||||
if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
int size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
|
||||
|
||||
if (pal) {
|
||||
if (pal && size == AVPALETTE_SIZE) {
|
||||
s->frame->palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
|
||||
}
|
||||
/* make the palette available */
|
||||
memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);
|
||||
|
||||
+7
-1
@@ -422,7 +422,13 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size,
|
||||
|
||||
ff_vc1_decode_blocks(v);
|
||||
|
||||
ff_er_frame_end(&s->er);
|
||||
if (v->end_mb_x == s->mb_width && s->end_mb_y == s->mb_height) {
|
||||
ff_er_frame_end(&s->er);
|
||||
} else {
|
||||
av_log(v->s.avctx, AV_LOG_WARNING,
|
||||
"disabling error correction due to block count mismatch %dx%d != %dx%d\n",
|
||||
v->end_mb_x, s->end_mb_y, s->mb_width, s->mb_height);
|
||||
}
|
||||
|
||||
ff_mpv_frame_end(s);
|
||||
|
||||
|
||||
@@ -306,11 +306,14 @@ static int msvideo1_decode_frame(AVCodecContext *avctx,
|
||||
return ret;
|
||||
|
||||
if (s->mode_8bit) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
int size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
|
||||
|
||||
if (pal) {
|
||||
if (pal && size == AVPALETTE_SIZE) {
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
s->frame->palette_has_changed = 1;
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -300,8 +300,11 @@ static int parse_object_segment(AVCodecContext *avctx,
|
||||
|
||||
av_fast_padded_malloc(&object->rle, &object->rle_buffer_size, rle_bitmap_len);
|
||||
|
||||
if (!object->rle)
|
||||
if (!object->rle) {
|
||||
object->rle_data_len = 0;
|
||||
object->rle_remaining_len = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
memcpy(object->rle, buf, buf_size);
|
||||
object->rle_data_len = buf_size;
|
||||
@@ -558,12 +561,13 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
|
||||
|
||||
sub->rects[i]->x = ctx->presentation.objects[i].x;
|
||||
sub->rects[i]->y = ctx->presentation.objects[i].y;
|
||||
sub->rects[i]->w = object->w;
|
||||
sub->rects[i]->h = object->h;
|
||||
|
||||
sub->rects[i]->linesize[0] = object->w;
|
||||
|
||||
if (object->rle) {
|
||||
sub->rects[i]->w = object->w;
|
||||
sub->rects[i]->h = object->h;
|
||||
|
||||
sub->rects[i]->linesize[0] = object->w;
|
||||
|
||||
if (object->rle_remaining_len) {
|
||||
av_log(avctx, AV_LOG_ERROR, "RLE data length %u is %u bytes shorter than expected\n",
|
||||
object->rle_data_len, object->rle_remaining_len);
|
||||
|
||||
@@ -142,7 +142,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
|
||||
if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
|
||||
return -1;
|
||||
if (s->width != avctx->width && s->height != avctx->height) {
|
||||
if (s->width != avctx->width || s->height != avctx->height) {
|
||||
ret = ff_set_dimensions(avctx, s->width, s->height);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
+17
-4
@@ -437,13 +437,13 @@ static int decode_zbuf(AVBPrint *bp, const uint8_t *data,
|
||||
av_bprint_init(bp, 0, -1);
|
||||
|
||||
while (zstream.avail_in > 0) {
|
||||
av_bprint_get_buffer(bp, 1, &buf, &buf_size);
|
||||
if (!buf_size) {
|
||||
av_bprint_get_buffer(bp, 2, &buf, &buf_size);
|
||||
if (buf_size < 2) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
zstream.next_out = buf;
|
||||
zstream.avail_out = buf_size;
|
||||
zstream.avail_out = buf_size - 1;
|
||||
ret = inflate(&zstream, Z_PARTIAL_FLUSH);
|
||||
if (ret != Z_OK && ret != Z_STREAM_END) {
|
||||
ret = AVERROR_EXTERNAL;
|
||||
@@ -772,6 +772,16 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
{
|
||||
int v, i;
|
||||
|
||||
if (!(s->state & PNG_IHDR)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "trns before IHDR\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->state & PNG_IDAT) {
|
||||
av_log(avctx, AV_LOG_ERROR, "trns after IDAT\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
if (length > 256 || !(s->state & PNG_PLTE))
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -782,7 +792,8 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
}
|
||||
} else if (s->color_type == PNG_COLOR_TYPE_GRAY || s->color_type == PNG_COLOR_TYPE_RGB) {
|
||||
if ((s->color_type == PNG_COLOR_TYPE_GRAY && length != 2) ||
|
||||
(s->color_type == PNG_COLOR_TYPE_RGB && length != 6))
|
||||
(s->color_type == PNG_COLOR_TYPE_RGB && length != 6) ||
|
||||
s->bit_depth == 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for (i = 0; i < length / 2; i++) {
|
||||
@@ -1241,6 +1252,8 @@ exit_loop:
|
||||
size_t raw_bpp = s->bpp - byte_depth;
|
||||
unsigned x, y;
|
||||
|
||||
av_assert0(s->bit_depth > 1);
|
||||
|
||||
for (y = 0; y < s->height; ++y) {
|
||||
uint8_t *row = &s->image_buf[s->image_linesize * y];
|
||||
|
||||
|
||||
+7
-3
@@ -43,7 +43,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int buf_size = avpkt->size;
|
||||
PNMContext * const s = avctx->priv_data;
|
||||
AVFrame * const p = data;
|
||||
int i, j, n, linesize, h, upgrade = 0, is_mono = 0;
|
||||
int i, j, k, n, linesize, h, upgrade = 0, is_mono = 0;
|
||||
unsigned char *ptr;
|
||||
int components, sample_len, ret;
|
||||
|
||||
@@ -143,10 +143,14 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
v = (*s->bytestream++)&1;
|
||||
} else {
|
||||
/* read a sequence of digits */
|
||||
do {
|
||||
for (k = 0; k < 5 && c <= 9; k += 1) {
|
||||
v = 10*v + c;
|
||||
c = (*s->bytestream++) - '0';
|
||||
} while (c <= 9);
|
||||
}
|
||||
if (v > s->maxval) {
|
||||
av_log(avctx, AV_LOG_ERROR, "value %d larger than maxval %d\n", v, s->maxval);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
if (sample_len == 16) {
|
||||
((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval;
|
||||
|
||||
@@ -67,10 +67,10 @@ static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels,
|
||||
ptrdiff_t line_size)
|
||||
{
|
||||
int i;
|
||||
vec_u8 perm = vec_lvsl(0, pixels);
|
||||
const vec_u8 zero = (const vec_u8)vec_splat_u8(0);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
vec_u8 perm = vec_lvsl(0, pixels);
|
||||
/* Read potentially unaligned pixels.
|
||||
* We're reading 16 pixels, and actually only want 8,
|
||||
* but we simply ignore the extras. */
|
||||
@@ -157,8 +157,7 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
|
||||
const uint8_t *s2, int stride)
|
||||
{
|
||||
int i;
|
||||
vec_u8 perm1 = vec_lvsl(0, s1);
|
||||
vec_u8 perm2 = vec_lvsl(0, s2);
|
||||
vec_u8 perm;
|
||||
const vec_u8 zero = (const vec_u8)vec_splat_u8(0);
|
||||
vec_s16 shorts1, shorts2;
|
||||
|
||||
@@ -166,17 +165,19 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
|
||||
/* Read potentially unaligned pixels.
|
||||
* We're reading 16 pixels, and actually only want 8,
|
||||
* but we simply ignore the extras. */
|
||||
perm = vec_lvsl(0, s1);
|
||||
vec_u8 pixl = vec_ld(0, s1);
|
||||
vec_u8 pixr = vec_ld(15, s1);
|
||||
vec_u8 bytes = vec_perm(pixl, pixr, perm1);
|
||||
vec_u8 bytes = vec_perm(pixl, pixr, perm);
|
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts1 = (vec_s16)vec_mergeh(zero, bytes);
|
||||
|
||||
// Do the same for the second block of pixels.
|
||||
perm = vec_lvsl(0, s2);
|
||||
pixl = vec_ld(0, s2);
|
||||
pixr = vec_ld(15, s2);
|
||||
bytes = vec_perm(pixl, pixr, perm2);
|
||||
bytes = vec_perm(pixl, pixr, perm);
|
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts2 = (vec_s16)vec_mergeh(zero, bytes);
|
||||
@@ -197,17 +198,19 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
|
||||
/* Read potentially unaligned pixels.
|
||||
* We're reading 16 pixels, and actually only want 8,
|
||||
* but we simply ignore the extras. */
|
||||
perm = vec_lvsl(0, s1);
|
||||
pixl = vec_ld(0, s1);
|
||||
pixr = vec_ld(15, s1);
|
||||
bytes = vec_perm(pixl, pixr, perm1);
|
||||
bytes = vec_perm(pixl, pixr, perm);
|
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts1 = (vec_s16)vec_mergeh(zero, bytes);
|
||||
|
||||
// Do the same for the second block of pixels.
|
||||
perm = vec_lvsl(0, s2);
|
||||
pixl = vec_ld(0, s2);
|
||||
pixr = vec_ld(15, s2);
|
||||
bytes = vec_perm(pixl, pixr, perm2);
|
||||
bytes = vec_perm(pixl, pixr, perm);
|
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts2 = (vec_s16)vec_mergeh(zero, bytes);
|
||||
|
||||
@@ -625,7 +625,7 @@ static int decode_slice(AVCodecContext *avctx, void *tdata)
|
||||
|
||||
/* if V or alpha component size is negative that means that previous
|
||||
component sizes are too large */
|
||||
if (v_data_size < 0 || a_data_size < 0 || hdr_size < 6) {
|
||||
if (v_data_size < 0 || a_data_size < 0 || hdr_size < 6 || coff[3] > slice_data_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid data size\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
+5
-2
@@ -260,7 +260,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
AVFrame * const ref = a->ref;
|
||||
uint8_t* outdata;
|
||||
int delta, ret;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
int pal_size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
|
||||
|
||||
if (avpkt->size < 0x86) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
|
||||
@@ -287,9 +288,11 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
/* make the palette available on the way out */
|
||||
if (pal) {
|
||||
if (pal && pal_size == AVPALETTE_SIZE) {
|
||||
p->palette_has_changed = 1;
|
||||
memcpy(a->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
|
||||
}
|
||||
memcpy(p->data[1], a->pal, AVPALETTE_SIZE);
|
||||
|
||||
|
||||
+5
-2
@@ -506,11 +506,14 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
if(has_palette) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
int size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
|
||||
|
||||
if (pal) {
|
||||
if (pal && size == AVPALETTE_SIZE) {
|
||||
s->frame->palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
|
||||
}
|
||||
|
||||
/* make the palette available on the way out */
|
||||
|
||||
+6
-1
@@ -383,8 +383,13 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
}
|
||||
|
||||
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
|
||||
int pal_size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
|
||||
NULL);
|
||||
&pal_size);
|
||||
if (pal && pal_size != AVPALETTE_SIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
|
||||
pal = NULL;
|
||||
}
|
||||
|
||||
if (pal) {
|
||||
av_buffer_unref(&context->palette);
|
||||
|
||||
@@ -109,6 +109,8 @@ static int get_dimension(GetBitContext *gb, const int *dim)
|
||||
val = dim[get_bits1(gb) - val];
|
||||
if(!val){
|
||||
do{
|
||||
if (get_bits_left(gb) < 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
t = get_bits(gb, 8);
|
||||
val += t << 2;
|
||||
}while(t == 0xFF);
|
||||
|
||||
@@ -131,8 +131,12 @@ static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t pref
|
||||
/**
|
||||
* Decode header tree
|
||||
*/
|
||||
static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)
|
||||
static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx, int length)
|
||||
{
|
||||
if(length > 500) { // Larger length can cause segmentation faults due to too deep recursion.
|
||||
av_log(NULL, AV_LOG_ERROR, "length too long\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (hc->current + 1 >= hc->length) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -161,12 +165,12 @@ static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx
|
||||
int r = 0, r_new, t;
|
||||
|
||||
t = hc->current++;
|
||||
r = smacker_decode_bigtree(gb, hc, ctx);
|
||||
r = smacker_decode_bigtree(gb, hc, ctx, length + 1);
|
||||
if(r < 0)
|
||||
return r;
|
||||
hc->values[t] = SMK_NODE | r;
|
||||
r++;
|
||||
r_new = smacker_decode_bigtree(gb, hc, ctx);
|
||||
r_new = smacker_decode_bigtree(gb, hc, ctx, length + 1);
|
||||
if (r_new < 0)
|
||||
return r_new;
|
||||
return r + r_new;
|
||||
@@ -277,7 +281,7 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (smacker_decode_bigtree(gb, &huff, &ctx) < 0)
|
||||
if (smacker_decode_bigtree(gb, &huff, &ctx, 0) < 0)
|
||||
err = -1;
|
||||
skip_bits1(gb);
|
||||
if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
|
||||
|
||||
@@ -152,6 +152,10 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
|
||||
|
||||
cur_frame = avpkt->pts % s->frames_per_jpeg;
|
||||
|
||||
/* cur_frame is later used to calculate the buffer offset, so it mustn't be negative */
|
||||
if (cur_frame < 0)
|
||||
cur_frame += s->frames_per_jpeg;
|
||||
|
||||
/* Are we at the start of a block? */
|
||||
if (!cur_frame) {
|
||||
av_frame_unref(mjpeg_data);
|
||||
|
||||
@@ -168,7 +168,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
} else {
|
||||
for (y = 0; y < h; y++) {
|
||||
if (buf_end - buf < len)
|
||||
if (buf_end - buf < alen)
|
||||
break;
|
||||
memcpy(ptr, buf, len);
|
||||
ptr += stride;
|
||||
|
||||
+5
-2
@@ -99,11 +99,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
|
||||
/* make the palette available on the way out */
|
||||
if (c->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
int size;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
|
||||
|
||||
if (pal) {
|
||||
if (pal && size == AVPALETTE_SIZE) {
|
||||
frame->palette_has_changed = 1;
|
||||
memcpy(c->pal, pal, AVPALETTE_SIZE);
|
||||
} else if (pal) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
|
||||
}
|
||||
memcpy(frame->data[1], c->pal, AVPALETTE_SIZE);
|
||||
}
|
||||
|
||||
+8
-1
@@ -373,6 +373,10 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
w_align = 4;
|
||||
h_align = 4;
|
||||
}
|
||||
if (s->codec_id == AV_CODEC_ID_INTERPLAY_VIDEO) {
|
||||
w_align = 8;
|
||||
h_align = 8;
|
||||
}
|
||||
break;
|
||||
case AV_PIX_FMT_PAL8:
|
||||
case AV_PIX_FMT_BGR8:
|
||||
@@ -382,7 +386,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
w_align = 4;
|
||||
h_align = 4;
|
||||
}
|
||||
if (s->codec_id == AV_CODEC_ID_JV) {
|
||||
if (s->codec_id == AV_CODEC_ID_JV ||
|
||||
s->codec_id == AV_CODEC_ID_INTERPLAY_VIDEO) {
|
||||
w_align = 8;
|
||||
h_align = 8;
|
||||
}
|
||||
@@ -957,6 +962,7 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v
|
||||
if (ret)
|
||||
ret[i] = r;
|
||||
}
|
||||
emms_c();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -969,6 +975,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
|
||||
if (ret)
|
||||
ret[i] = r;
|
||||
}
|
||||
emms_c();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -171,7 +171,7 @@ static int vp5_parse_coeff_models(VP56Context *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vp5_parse_coeff(VP56Context *s)
|
||||
static int vp5_parse_coeff(VP56Context *s)
|
||||
{
|
||||
VP56RangeCoder *c = &s->c;
|
||||
VP56Model *model = s->modelp;
|
||||
@@ -181,6 +181,11 @@ static void vp5_parse_coeff(VP56Context *s)
|
||||
int b, i, cg, idx, ctx, ctx_last;
|
||||
int pt = 0; /* plane type (0 for Y, 1 for U or V) */
|
||||
|
||||
if (c->end >= c->buffer && c->bits >= 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "End of AC stream reached in vp5_parse_coeff\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (b=0; b<6; b++) {
|
||||
int ct = 1; /* code type */
|
||||
|
||||
@@ -246,6 +251,7 @@ static void vp5_parse_coeff(VP56Context *s)
|
||||
s->coeff_ctx[ff_vp56_b6to4[b]][i] = 5;
|
||||
s->above_blocks[s->above_block_idx[b]].not_null_dc = s->coeff_ctx[ff_vp56_b6to4[b]][0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vp5_default_models_init(VP56Context *s)
|
||||
|
||||
+10
-4
@@ -381,12 +381,13 @@ static void vp56_mc(VP56Context *s, int b, int plane, uint8_t *src,
|
||||
}
|
||||
}
|
||||
|
||||
static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
|
||||
static int vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
|
||||
{
|
||||
AVFrame *frame_current, *frame_ref;
|
||||
VP56mb mb_type;
|
||||
VP56Frame ref_frame;
|
||||
int b, ab, b_max, plane, off;
|
||||
int ret;
|
||||
|
||||
if (s->frames[VP56_FRAME_CURRENT]->key_frame)
|
||||
mb_type = VP56_MB_INTRA;
|
||||
@@ -394,14 +395,16 @@ static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
|
||||
mb_type = vp56_decode_mv(s, row, col);
|
||||
ref_frame = ff_vp56_reference_frame[mb_type];
|
||||
|
||||
s->parse_coeff(s);
|
||||
ret = s->parse_coeff(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
vp56_add_predictors_dc(s, ref_frame);
|
||||
|
||||
frame_current = s->frames[VP56_FRAME_CURRENT];
|
||||
frame_ref = s->frames[ref_frame];
|
||||
if (mb_type != VP56_MB_INTRA && !frame_ref->data[0])
|
||||
return;
|
||||
return 0;
|
||||
|
||||
ab = 6*is_alpha;
|
||||
b_max = 6 - 2*is_alpha;
|
||||
@@ -451,6 +454,7 @@ static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
|
||||
s->block_coeff[4][0] = 0;
|
||||
s->block_coeff[5][0] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vp56_size_changed(VP56Context *s)
|
||||
@@ -653,7 +657,9 @@ static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data,
|
||||
s->block_offset[5] = s->block_offset[4];
|
||||
|
||||
for (mb_col=0; mb_col<s->mb_width; mb_col++) {
|
||||
vp56_decode_mb(s, mb_row, mb_col, is_alpha);
|
||||
int ret = vp56_decode_mb(s, mb_row, mb_col, is_alpha);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
for (y=0; y<4; y++) {
|
||||
s->above_block_idx[y] += 2;
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ typedef void (*VP56ParseVectorAdjustment)(VP56Context *s,
|
||||
typedef void (*VP56Filter)(VP56Context *s, uint8_t *dst, uint8_t *src,
|
||||
int offset1, int offset2, int stride,
|
||||
VP56mv mv, int mask, int select, int luma);
|
||||
typedef void (*VP56ParseCoeff)(VP56Context *s);
|
||||
typedef int (*VP56ParseCoeff)(VP56Context *s);
|
||||
typedef void (*VP56DefaultModelsInit)(VP56Context *s);
|
||||
typedef void (*VP56ParseVectorModels)(VP56Context *s);
|
||||
typedef int (*VP56ParseCoeffModels)(VP56Context *s);
|
||||
|
||||
+12
-5
@@ -40,8 +40,8 @@
|
||||
|
||||
#define VP6_MAX_HUFF_SIZE 12
|
||||
|
||||
static void vp6_parse_coeff(VP56Context *s);
|
||||
static void vp6_parse_coeff_huffman(VP56Context *s);
|
||||
static int vp6_parse_coeff(VP56Context *s);
|
||||
static int vp6_parse_coeff_huffman(VP56Context *s);
|
||||
|
||||
static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size)
|
||||
{
|
||||
@@ -380,7 +380,7 @@ static unsigned vp6_get_nb_null(VP56Context *s)
|
||||
return val;
|
||||
}
|
||||
|
||||
static void vp6_parse_coeff_huffman(VP56Context *s)
|
||||
static int vp6_parse_coeff_huffman(VP56Context *s)
|
||||
{
|
||||
VP56Model *model = s->modelp;
|
||||
uint8_t *permute = s->idct_scantable;
|
||||
@@ -402,7 +402,7 @@ static void vp6_parse_coeff_huffman(VP56Context *s)
|
||||
break;
|
||||
} else {
|
||||
if (get_bits_left(&s->gb) <= 0)
|
||||
return;
|
||||
return AVERROR_INVALIDDATA;
|
||||
coeff = get_vlc2(&s->gb, vlc_coeff->table, FF_HUFFMAN_BITS, 3);
|
||||
if (coeff == 0) {
|
||||
if (coeff_idx) {
|
||||
@@ -437,9 +437,10 @@ static void vp6_parse_coeff_huffman(VP56Context *s)
|
||||
vlc_coeff = &s->ract_vlc[pt][ct][cg];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vp6_parse_coeff(VP56Context *s)
|
||||
static int vp6_parse_coeff(VP56Context *s)
|
||||
{
|
||||
VP56RangeCoder *c = s->ccp;
|
||||
VP56Model *model = s->modelp;
|
||||
@@ -449,6 +450,11 @@ static void vp6_parse_coeff(VP56Context *s)
|
||||
int b, i, cg, idx, ctx;
|
||||
int pt = 0; /* plane type (0 for Y, 1 for U or V) */
|
||||
|
||||
if (c->end >= c->buffer && c->bits >= 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "End of AC stream reached in vp6_parse_coeff\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (b=0; b<6; b++) {
|
||||
int ct = 1; /* code type */
|
||||
int run = 1;
|
||||
@@ -512,6 +518,7 @@ static void vp6_parse_coeff(VP56Context *s)
|
||||
s->left_block[ff_vp56_b6to4[b]].not_null_dc =
|
||||
s->above_blocks[s->above_block_idx[b]].not_null_dc = !!s->block_coeff[b][0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vp6_block_variance(uint8_t *src, int stride)
|
||||
|
||||
+2
-3
@@ -3703,11 +3703,10 @@ static av_always_inline void adapt_prob(uint8_t *p, unsigned ct0, unsigned ct1,
|
||||
if (!ct)
|
||||
return;
|
||||
|
||||
update_factor = FASTDIV(update_factor * FFMIN(ct, max_count), max_count);
|
||||
p1 = *p;
|
||||
p2 = ((ct0 << 8) + (ct >> 1)) / ct;
|
||||
p2 = ((((int64_t) ct0) << 8) + (ct >> 1)) / ct;
|
||||
p2 = av_clip(p2, 1, 255);
|
||||
ct = FFMIN(ct, max_count);
|
||||
update_factor = FASTDIV(update_factor * ct, max_count);
|
||||
|
||||
// (p1 * (256 - update_factor) + p2 * update_factor + 128) >> 8
|
||||
*p = p1 + (((p2 - p1) * update_factor + 128) >> 8);
|
||||
|
||||
@@ -109,7 +109,7 @@ static av_cold int init(AVFilterContext *ctx)
|
||||
if (!pan->args) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"pan filter needs a channel layout and a set "
|
||||
"of channels definitions as parameter\n");
|
||||
"of channel definitions as parameter\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (!args)
|
||||
@@ -276,7 +276,7 @@ static int config_props(AVFilterLink *link)
|
||||
if (link->channels > MAX_CHANNELS ||
|
||||
pan->nb_output_channels > MAX_CHANNELS) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"af_pan support a maximum of %d channels. "
|
||||
"af_pan supports a maximum of %d channels. "
|
||||
"Feel free to ask for a higher limit.\n", MAX_CHANNELS);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
||||
#define OFFSET(x) offsetof(BlackFrameContext, x)
|
||||
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
||||
static const AVOption blackframe_options[] = {
|
||||
{ "amount", "Percentage of the pixels that have to be below the threshold "
|
||||
"for the frame to be considered black.", OFFSET(bamount), AV_OPT_TYPE_INT, { .i64 = 98 }, 0, 100, FLAGS },
|
||||
{ "amount", "percentage of the pixels that have to be below the threshold "
|
||||
"for the frame to be considered black", OFFSET(bamount), AV_OPT_TYPE_INT, { .i64 = 98 }, 0, 100, FLAGS },
|
||||
{ "threshold", "threshold below which a pixel value is considered black",
|
||||
OFFSET(bthresh), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, 255, FLAGS },
|
||||
{ "thresh", "threshold below which a pixel value is considered black",
|
||||
|
||||
@@ -1866,6 +1866,13 @@ typedef struct AVFormatContext {
|
||||
* A callback for closing the streams opened with AVFormatContext.io_open().
|
||||
*/
|
||||
void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
|
||||
|
||||
/**
|
||||
* The maximum number of streams.
|
||||
* - encoding: unused
|
||||
* - decoding: set by user through AVOptions (NO direct access)
|
||||
*/
|
||||
int max_streams;
|
||||
} AVFormatContext;
|
||||
|
||||
int av_format_get_probe_score(const AVFormatContext *s);
|
||||
|
||||
@@ -608,6 +608,7 @@ static int avi_read_header(AVFormatContext *s)
|
||||
if (s->streams[0]->info)
|
||||
av_freep(&s->streams[0]->info->duration_error);
|
||||
av_freep(&s->streams[0]->info);
|
||||
av_freep(&s->streams[0]->internal);
|
||||
av_freep(&s->streams[0]);
|
||||
s->nb_streams = 0;
|
||||
if (CONFIG_DV_DEMUXER) {
|
||||
@@ -1093,6 +1094,8 @@ static int read_gab2_sub(AVFormatContext *s, AVStream *st, AVPacket *pkt)
|
||||
goto error;
|
||||
|
||||
if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {
|
||||
if (ast->sub_ctx->nb_streams != 1)
|
||||
goto error;
|
||||
ff_read_packet(ast->sub_ctx, &ast->sub_pkt);
|
||||
*st->codec = *ast->sub_ctx->streams[0]->codec;
|
||||
ast->sub_ctx->streams[0]->codec->extradata = NULL;
|
||||
@@ -1188,7 +1191,8 @@ start_sync:
|
||||
if ((d[0] == 'i' && d[1] == 'x' && n < s->nb_streams) ||
|
||||
// parse JUNK
|
||||
(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K') ||
|
||||
(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')) {
|
||||
(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1') ||
|
||||
(d[0] == 'i' && d[1] == 'n' && d[2] == 'd' && d[3] == 'x')) {
|
||||
avio_skip(pb, size);
|
||||
goto start_sync;
|
||||
}
|
||||
@@ -1845,7 +1849,6 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
|
||||
continue;
|
||||
|
||||
// av_assert1(st2->codec->block_align);
|
||||
av_assert0(fabs(av_q2d(st2->time_base) - ast2->scale / (double)ast2->rate) < av_q2d(st2->time_base) * 0.00000001);
|
||||
index = av_index_search_timestamp(st2,
|
||||
av_rescale_q(timestamp,
|
||||
st->time_base,
|
||||
|
||||
+7
-1
@@ -33,6 +33,7 @@ static int dcstr_probe(AVProbeData *p)
|
||||
static int dcstr_read_header(AVFormatContext *s)
|
||||
{
|
||||
unsigned codec, align;
|
||||
int mult;
|
||||
AVStream *st;
|
||||
|
||||
st = avformat_new_stream(s, NULL);
|
||||
@@ -46,7 +47,12 @@ static int dcstr_read_header(AVFormatContext *s)
|
||||
align = avio_rl32(s->pb);
|
||||
avio_skip(s->pb, 4);
|
||||
st->duration = avio_rl32(s->pb);
|
||||
st->codec->channels *= avio_rl32(s->pb);
|
||||
mult = avio_rl32(s->pb);
|
||||
if (st->codec->channels <= 0 || mult <= 0 || mult > INT_MAX / st->codec->channels) {
|
||||
av_log(s, AV_LOG_ERROR, "invalid number of channels %d x %d\n", st->codec->channels, mult);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
st->codec->channels *= mult;
|
||||
if (!align || align > INT_MAX / st->codec->channels)
|
||||
return AVERROR_INVALIDDATA;
|
||||
st->codec->block_align = align * st->codec->channels;
|
||||
|
||||
@@ -362,7 +362,7 @@ static int ffm2_read_header(AVFormatContext *s)
|
||||
}
|
||||
break;
|
||||
case MKBETAG('S', 'T', 'V', 'I'):
|
||||
if (f_stvi++) {
|
||||
if (f_stvi++ || codec->codec_type != AVMEDIA_TYPE_VIDEO) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ static int ffm2_read_header(AVFormatContext *s)
|
||||
codec->refs = avio_rb32(pb);
|
||||
break;
|
||||
case MKBETAG('S', 'T', 'A', 'U'):
|
||||
if (f_stau++) {
|
||||
if (f_stau++ || codec->codec_type != AVMEDIA_TYPE_AUDIO) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
@@ -449,7 +449,7 @@ static int ffm2_read_header(AVFormatContext *s)
|
||||
}
|
||||
break;
|
||||
case MKBETAG('S', '2', 'V', 'I'):
|
||||
if (f_stvi++ || !size) {
|
||||
if (f_stvi++ || !size || codec->codec_type != AVMEDIA_TYPE_VIDEO) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
@@ -464,7 +464,7 @@ static int ffm2_read_header(AVFormatContext *s)
|
||||
goto fail;
|
||||
break;
|
||||
case MKBETAG('S', '2', 'A', 'U'):
|
||||
if (f_stau++ || !size) {
|
||||
if (f_stau++ || !size || codec->codec_type != AVMEDIA_TYPE_AUDIO) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "avformat.h"
|
||||
#include "internal.h"
|
||||
|
||||
@@ -68,10 +69,8 @@ static int read_header(AVFormatContext *s)
|
||||
st->codec->height = avio_rb16(pb);
|
||||
film->leading = avio_rb16(pb);
|
||||
|
||||
if (st->codec->width * 4LL * st->codec->height >= INT_MAX) {
|
||||
av_log(s, AV_LOG_ERROR, "dimensions too large\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (av_image_check_size(st->codec->width, st->codec->height, 0, s) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
avpriv_set_pts_info(st, 64, 1, avio_rb16(pb));
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ static int flac_read_header(AVFormatContext *s)
|
||||
|
||||
/* process metadata blocks */
|
||||
while (!avio_feof(s->pb) && !metadata_last) {
|
||||
avio_read(s->pb, header, 4);
|
||||
if (avio_read(s->pb, header, 4) != 4)
|
||||
return AVERROR(AVERROR_INVALIDDATA);
|
||||
flac_parse_block_header(header, &metadata_last, &metadata_type,
|
||||
&metadata_size);
|
||||
switch (metadata_type) {
|
||||
|
||||
+60
-49
@@ -62,8 +62,8 @@ typedef struct HTTPContext {
|
||||
int line_count;
|
||||
int http_code;
|
||||
/* Used if "Transfer-Encoding: chunked" otherwise -1. */
|
||||
int64_t chunksize;
|
||||
int64_t off, end_off, filesize;
|
||||
uint64_t chunksize;
|
||||
uint64_t off, end_off, filesize;
|
||||
char *location;
|
||||
HTTPAuthState auth_state;
|
||||
HTTPAuthState proxy_auth_state;
|
||||
@@ -92,9 +92,9 @@ typedef struct HTTPContext {
|
||||
AVDictionary *cookie_dict;
|
||||
int icy;
|
||||
/* how much data was read since the last ICY metadata packet */
|
||||
int icy_data_read;
|
||||
uint64_t icy_data_read;
|
||||
/* after how many bytes of read data a new metadata packet will be found */
|
||||
int icy_metaint;
|
||||
uint64_t icy_metaint;
|
||||
char *icy_metadata_headers;
|
||||
char *icy_metadata_packet;
|
||||
AVDictionary *metadata;
|
||||
@@ -480,7 +480,7 @@ static int http_open(URLContext *h, const char *uri, int flags,
|
||||
else
|
||||
h->is_streamed = 1;
|
||||
|
||||
s->filesize = -1;
|
||||
s->filesize = UINT64_MAX;
|
||||
s->location = av_strdup(uri);
|
||||
if (!s->location)
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -607,9 +607,9 @@ static void parse_content_range(URLContext *h, const char *p)
|
||||
|
||||
if (!strncmp(p, "bytes ", 6)) {
|
||||
p += 6;
|
||||
s->off = strtoll(p, NULL, 10);
|
||||
s->off = strtoull(p, NULL, 10);
|
||||
if ((slash = strchr(p, '/')) && strlen(slash) > 0)
|
||||
s->filesize = strtoll(slash + 1, NULL, 10);
|
||||
s->filesize = strtoull(slash + 1, NULL, 10);
|
||||
}
|
||||
if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647))
|
||||
h->is_streamed = 0; /* we _can_ in fact seek */
|
||||
@@ -799,8 +799,9 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
if ((ret = parse_location(s, p)) < 0)
|
||||
return ret;
|
||||
*new_location = 1;
|
||||
} else if (!av_strcasecmp(tag, "Content-Length") && s->filesize == -1) {
|
||||
s->filesize = strtoll(p, NULL, 10);
|
||||
} else if (!av_strcasecmp(tag, "Content-Length") &&
|
||||
s->filesize == UINT64_MAX) {
|
||||
s->filesize = strtoull(p, NULL, 10);
|
||||
} else if (!av_strcasecmp(tag, "Content-Range")) {
|
||||
parse_content_range(h, p);
|
||||
} else if (!av_strcasecmp(tag, "Accept-Ranges") &&
|
||||
@@ -809,7 +810,7 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
h->is_streamed = 0;
|
||||
} else if (!av_strcasecmp(tag, "Transfer-Encoding") &&
|
||||
!av_strncasecmp(p, "chunked", 7)) {
|
||||
s->filesize = -1;
|
||||
s->filesize = UINT64_MAX;
|
||||
s->chunksize = 0;
|
||||
} else if (!av_strcasecmp(tag, "WWW-Authenticate")) {
|
||||
ff_http_auth_handle_header(&s->auth_state, tag, p);
|
||||
@@ -833,7 +834,7 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
if (parse_cookie(s, p, &s->cookie_dict))
|
||||
av_log(h, AV_LOG_WARNING, "Unable to parse '%s'\n", p);
|
||||
} else if (!av_strcasecmp(tag, "Icy-MetaInt")) {
|
||||
s->icy_metaint = strtoll(p, NULL, 10);
|
||||
s->icy_metaint = strtoull(p, NULL, 10);
|
||||
} else if (!av_strncasecmp(tag, "Icy-", 4)) {
|
||||
if ((ret = parse_icy(s, tag, p)) < 0)
|
||||
return ret;
|
||||
@@ -963,7 +964,7 @@ static int http_read_header(URLContext *h, int *new_location)
|
||||
char line[MAX_URL_SIZE];
|
||||
int err = 0;
|
||||
|
||||
s->chunksize = -1;
|
||||
s->chunksize = UINT64_MAX;
|
||||
|
||||
for (;;) {
|
||||
if ((err = http_get_line(s, line, sizeof(line))) < 0)
|
||||
@@ -997,7 +998,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
int post, err;
|
||||
char headers[HTTP_HEADERS_SIZE] = "";
|
||||
char *authstr = NULL, *proxyauthstr = NULL;
|
||||
int64_t off = s->off;
|
||||
uint64_t off = s->off;
|
||||
int len = 0;
|
||||
const char *method;
|
||||
int send_expect_100 = 0;
|
||||
@@ -1045,7 +1046,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
// server supports seeking by analysing the reply headers.
|
||||
if (!has_header(s->headers, "\r\nRange: ") && !post && (s->off > 0 || s->end_off || s->seekable == -1)) {
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"Range: bytes=%"PRId64"-", s->off);
|
||||
"Range: bytes=%"PRIu64"-", s->off);
|
||||
if (s->end_off)
|
||||
len += av_strlcatf(headers + len, sizeof(headers) - len,
|
||||
"%"PRId64, s->end_off - 1);
|
||||
@@ -1120,7 +1121,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
|
||||
s->line_count = 0;
|
||||
s->off = 0;
|
||||
s->icy_data_read = 0;
|
||||
s->filesize = -1;
|
||||
s->filesize = UINT64_MAX;
|
||||
s->willclose = 0;
|
||||
s->end_chunked_post = 0;
|
||||
s->end_header = 0;
|
||||
@@ -1152,6 +1153,34 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
int len;
|
||||
|
||||
if (s->chunksize != UINT64_MAX) {
|
||||
if (!s->chunksize) {
|
||||
char line[32];
|
||||
int err;
|
||||
|
||||
do {
|
||||
if ((err = http_get_line(s, line, sizeof(line))) < 0)
|
||||
return err;
|
||||
} while (!*line); /* skip CR LF from last chunk */
|
||||
|
||||
s->chunksize = strtoull(line, NULL, 16);
|
||||
|
||||
av_log(h, AV_LOG_TRACE,
|
||||
"Chunked encoding data size: %"PRIu64"'\n",
|
||||
s->chunksize);
|
||||
|
||||
if (!s->chunksize)
|
||||
return 0;
|
||||
else if (s->chunksize == UINT64_MAX) {
|
||||
av_log(h, AV_LOG_ERROR, "Invalid chunk size %"PRIu64"\n",
|
||||
s->chunksize);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
size = FFMIN(size, s->chunksize);
|
||||
}
|
||||
|
||||
/* read bytes from input buffer first */
|
||||
len = s->buf_end - s->buf_ptr;
|
||||
if (len > 0) {
|
||||
@@ -1160,15 +1189,13 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size)
|
||||
memcpy(buf, s->buf_ptr, len);
|
||||
s->buf_ptr += len;
|
||||
} else {
|
||||
int64_t target_end = s->end_off ? s->end_off : s->filesize;
|
||||
if ((!s->willclose || s->chunksize < 0) &&
|
||||
target_end >= 0 && s->off >= target_end)
|
||||
uint64_t target_end = s->end_off ? s->end_off : s->filesize;
|
||||
if ((!s->willclose || s->chunksize == UINT64_MAX) && s->off >= target_end)
|
||||
return AVERROR_EOF;
|
||||
len = ffurl_read(s->hd, buf, size);
|
||||
if (!len && (!s->willclose || s->chunksize < 0) &&
|
||||
target_end >= 0 && s->off < target_end) {
|
||||
if (!len && (!s->willclose || s->chunksize == UINT64_MAX) && s->off < target_end) {
|
||||
av_log(h, AV_LOG_ERROR,
|
||||
"Stream ends prematurely at %"PRId64", should be %"PRId64"\n",
|
||||
"Stream ends prematurely at %"PRIu64", should be %"PRIu64"\n",
|
||||
s->off, target_end
|
||||
);
|
||||
return AVERROR(EIO);
|
||||
@@ -1176,8 +1203,10 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size)
|
||||
}
|
||||
if (len > 0) {
|
||||
s->off += len;
|
||||
if (s->chunksize > 0)
|
||||
if (s->chunksize > 0) {
|
||||
av_assert0(s->chunksize >= len);
|
||||
s->chunksize -= len;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@@ -1231,25 +1260,6 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (s->chunksize >= 0) {
|
||||
if (!s->chunksize) {
|
||||
char line[32];
|
||||
|
||||
do {
|
||||
if ((err = http_get_line(s, line, sizeof(line))) < 0)
|
||||
return err;
|
||||
} while (!*line); /* skip CR LF from last chunk */
|
||||
|
||||
s->chunksize = strtoll(line, NULL, 16);
|
||||
|
||||
av_log(NULL, AV_LOG_TRACE, "Chunked encoding data size: %"PRId64"'\n",
|
||||
s->chunksize);
|
||||
|
||||
if (!s->chunksize)
|
||||
return 0;
|
||||
}
|
||||
size = FFMIN(size, s->chunksize);
|
||||
}
|
||||
#if CONFIG_ZLIB
|
||||
if (s->compressed)
|
||||
return http_buf_read_compressed(h, buf, size);
|
||||
@@ -1257,17 +1267,17 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size)
|
||||
read_ret = http_buf_read(h, buf, size);
|
||||
if ( (read_ret < 0 && s->reconnect && (!h->is_streamed || s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize)
|
||||
|| (read_ret == 0 && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) {
|
||||
int64_t target = h->is_streamed ? 0 : s->off;
|
||||
uint64_t target = h->is_streamed ? 0 : s->off;
|
||||
|
||||
if (s->reconnect_delay > s->reconnect_delay_max)
|
||||
return AVERROR(EIO);
|
||||
|
||||
av_log(h, AV_LOG_INFO, "Will reconnect at %"PRId64" error=%s.\n", s->off, av_err2str(read_ret));
|
||||
av_log(h, AV_LOG_INFO, "Will reconnect at %"PRIu64" error=%s.\n", s->off, av_err2str(read_ret));
|
||||
av_usleep(1000U*1000*s->reconnect_delay);
|
||||
s->reconnect_delay = 1 + 2*s->reconnect_delay;
|
||||
seek_ret = http_seek_internal(h, target, SEEK_SET, 1);
|
||||
if (seek_ret != target) {
|
||||
av_log(h, AV_LOG_ERROR, "Failed to reconnect at %"PRId64".\n", target);
|
||||
av_log(h, AV_LOG_ERROR, "Failed to reconnect at %"PRIu64".\n", target);
|
||||
return read_ret;
|
||||
}
|
||||
|
||||
@@ -1322,10 +1332,11 @@ static int store_icy(URLContext *h, int size)
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
/* until next metadata packet */
|
||||
int remaining = s->icy_metaint - s->icy_data_read;
|
||||
uint64_t remaining;
|
||||
|
||||
if (remaining < 0)
|
||||
if (s->icy_metaint < s->icy_data_read)
|
||||
return AVERROR_INVALIDDATA;
|
||||
remaining = s->icy_metaint - s->icy_data_read;
|
||||
|
||||
if (!remaining) {
|
||||
/* The metadata packet is variable sized. It has a 1 byte header
|
||||
@@ -1439,7 +1450,7 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
|
||||
{
|
||||
HTTPContext *s = h->priv_data;
|
||||
URLContext *old_hd = s->hd;
|
||||
int64_t old_off = s->off;
|
||||
uint64_t old_off = s->off;
|
||||
uint8_t old_buf[BUFFER_SIZE];
|
||||
int old_buf_size, ret;
|
||||
AVDictionary *options = NULL;
|
||||
@@ -1450,7 +1461,7 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
|
||||
((whence == SEEK_CUR && off == 0) ||
|
||||
(whence == SEEK_SET && off == s->off)))
|
||||
return s->off;
|
||||
else if ((s->filesize == -1 && whence == SEEK_END))
|
||||
else if ((s->filesize == UINT64_MAX && whence == SEEK_END))
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
if (whence == SEEK_CUR)
|
||||
@@ -1605,7 +1616,7 @@ redo:
|
||||
s->buf_ptr = s->buffer;
|
||||
s->buf_end = s->buffer;
|
||||
s->line_count = 0;
|
||||
s->filesize = -1;
|
||||
s->filesize = UINT64_MAX;
|
||||
cur_auth_type = s->proxy_auth_state.auth_type;
|
||||
|
||||
/* Note: This uses buffering, potentially reading more than the
|
||||
|
||||
+17
-3
@@ -60,7 +60,7 @@ static int probe(AVProbeData *p)
|
||||
offset = AV_RL32(p->buf + 18 + i * 16);
|
||||
if (offset < 22)
|
||||
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
|
||||
if (offset + 8 > p->buf_size)
|
||||
if (offset > p->buf_size - 8)
|
||||
return AVPROBE_SCORE_MAX / 4 + FFMIN(i, 1);
|
||||
if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG)
|
||||
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
|
||||
@@ -105,6 +105,10 @@ static int read_header(AVFormatContext *s)
|
||||
avio_skip(pb, 5);
|
||||
|
||||
ico->images[i].size = avio_rl32(pb);
|
||||
if (ico->images[i].size <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
ico->images[i].offset = avio_rl32(pb);
|
||||
|
||||
if (avio_seek(pb, ico->images[i].offset, SEEK_SET) < 0)
|
||||
@@ -170,8 +174,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
bytestream_put_le16(&buf, 0);
|
||||
bytestream_put_le32(&buf, 0);
|
||||
|
||||
if ((ret = avio_read(pb, buf, image->size)) < 0)
|
||||
return ret;
|
||||
if ((ret = avio_read(pb, buf, image->size)) != image->size) {
|
||||
av_packet_unref(pkt);
|
||||
return ret < 0 ? ret : AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
st->codec->bits_per_coded_sample = AV_RL16(buf + 14);
|
||||
|
||||
@@ -193,6 +199,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ico_read_close(AVFormatContext * s)
|
||||
{
|
||||
IcoDemuxContext *ico = s->priv_data;
|
||||
av_freep(&ico->images);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVInputFormat ff_ico_demuxer = {
|
||||
.name = "ico",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Microsoft Windows ICO"),
|
||||
@@ -200,5 +213,6 @@ AVInputFormat ff_ico_demuxer = {
|
||||
.read_probe = probe,
|
||||
.read_header = read_header,
|
||||
.read_packet = read_packet,
|
||||
.read_close = ico_read_close,
|
||||
.flags = AVFMT_NOTIMESTAMPS,
|
||||
};
|
||||
|
||||
@@ -157,6 +157,9 @@ static int roq_read_packet(AVFormatContext *s,
|
||||
chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
|
||||
codebook_size;
|
||||
|
||||
if (chunk_size > INT_MAX)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* rewind */
|
||||
avio_seek(pb, codebook_offset, SEEK_SET);
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ typedef const struct EbmlSyntax {
|
||||
int list_elem_size;
|
||||
int data_offset;
|
||||
union {
|
||||
int64_t i;
|
||||
uint64_t u;
|
||||
double f;
|
||||
const char *s;
|
||||
@@ -606,7 +607,7 @@ static const EbmlSyntax matroska_blockgroup[] = {
|
||||
{ MATROSKA_ID_SIMPLEBLOCK, EBML_BIN, 0, offsetof(MatroskaBlock, bin) },
|
||||
{ MATROSKA_ID_BLOCKDURATION, EBML_UINT, 0, offsetof(MatroskaBlock, duration) },
|
||||
{ MATROSKA_ID_DISCARDPADDING, EBML_SINT, 0, offsetof(MatroskaBlock, discard_padding) },
|
||||
{ MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 0, offsetof(MatroskaBlock, reference) },
|
||||
{ MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 0, offsetof(MatroskaBlock, reference), { .i = INT64_MIN } },
|
||||
{ MATROSKA_ID_CODECSTATE, EBML_NONE },
|
||||
{ 1, EBML_UINT, 0, offsetof(MatroskaBlock, non_simple), { .u = 1 } },
|
||||
{ 0 }
|
||||
@@ -977,6 +978,9 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
|
||||
|
||||
for (i = 0; syntax[i].id; i++)
|
||||
switch (syntax[i].type) {
|
||||
case EBML_SINT:
|
||||
*(int64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.i;
|
||||
break;
|
||||
case EBML_UINT:
|
||||
*(uint64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.u;
|
||||
break;
|
||||
@@ -3097,7 +3101,7 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska)
|
||||
matroska->current_cluster_num_blocks = blocks_list->nb_elem;
|
||||
i = blocks_list->nb_elem - 1;
|
||||
if (blocks[i].bin.size > 0 && blocks[i].bin.data) {
|
||||
int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1;
|
||||
int is_keyframe = blocks[i].non_simple ? blocks[i].reference == INT64_MIN : -1;
|
||||
uint8_t* additional = blocks[i].additional.size > 0 ?
|
||||
blocks[i].additional.data : NULL;
|
||||
if (!blocks[i].non_simple)
|
||||
@@ -3135,7 +3139,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
|
||||
blocks = blocks_list->elem;
|
||||
for (i = 0; i < blocks_list->nb_elem; i++)
|
||||
if (blocks[i].bin.size > 0 && blocks[i].bin.data) {
|
||||
int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1;
|
||||
int is_keyframe = blocks[i].non_simple ? blocks[i].reference == INT64_MIN : -1;
|
||||
res = matroska_parse_block(matroska, blocks[i].bin.data,
|
||||
blocks[i].bin.size, blocks[i].bin.pos,
|
||||
cluster.timecode, blocks[i].duration,
|
||||
@@ -3579,6 +3583,11 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_ERROR, "Failed to read file headers\n");
|
||||
return -1;
|
||||
}
|
||||
if (!s->nb_streams) {
|
||||
matroska_read_close(s);
|
||||
av_log(s, AV_LOG_ERROR, "No streams found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (!matroska->is_live) {
|
||||
buf = av_asprintf("%g", matroska->duration);
|
||||
|
||||
+8
-6
@@ -380,11 +380,11 @@ retry:
|
||||
return ret;
|
||||
} else if (!key && c->found_hdlr_mdta && c->meta_keys) {
|
||||
uint32_t index = AV_RB32(&atom.type);
|
||||
if (index < c->meta_keys_count) {
|
||||
if (index < c->meta_keys_count && index > 0) {
|
||||
key = c->meta_keys[index];
|
||||
} else {
|
||||
av_log(c->fc, AV_LOG_WARNING,
|
||||
"The index of 'data' is out of range: %d >= %d.\n",
|
||||
"The index of 'data' is out of range: %d < 1 or >= %d.\n",
|
||||
index, c->meta_keys_count);
|
||||
}
|
||||
}
|
||||
@@ -674,6 +674,8 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
title_size = atom.size - 24;
|
||||
if (title_size > 0) {
|
||||
if (title_size > FFMIN(INT_MAX, SIZE_MAX-1))
|
||||
return AVERROR_INVALIDDATA;
|
||||
title_str = av_malloc(title_size + 1); /* Add null terminator */
|
||||
if (!title_str)
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -3149,7 +3151,7 @@ static int mov_read_keys(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
avio_skip(pb, 4);
|
||||
count = avio_rb32(pb);
|
||||
if (count > UINT_MAX / sizeof(*c->meta_keys)) {
|
||||
if (count > UINT_MAX / sizeof(*c->meta_keys) - 1) {
|
||||
av_log(c->fc, AV_LOG_ERROR,
|
||||
"The 'keys' atom with the invalid key count: %d\n", count);
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -3899,7 +3901,7 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
|
||||
};
|
||||
|
||||
if (atom.size < sizeof(uuid) || atom.size == INT64_MAX)
|
||||
if (atom.size < sizeof(uuid) || atom.size >= FFMIN(INT_MAX, SIZE_MAX))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
ret = avio_read(pb, uuid, sizeof(uuid));
|
||||
@@ -4062,8 +4064,8 @@ static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
avio_rb32(pb); /* entries */
|
||||
|
||||
if (atom.size < 8) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "senc atom size %"PRId64" too small\n", atom.size);
|
||||
if (atom.size < 8 || atom.size > FFMIN(INT_MAX, SIZE_MAX)) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "senc atom size %"PRId64" invalid\n", atom.size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
||||
+29
-6
@@ -4342,15 +4342,10 @@ static int mov_auto_flush_fragment(AVFormatContext *s, int force)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
static int check_pkt(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
MOVMuxContext *mov = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
MOVTrack *trk = &mov->tracks[pkt->stream_index];
|
||||
AVCodecContext *enc = trk->enc;
|
||||
unsigned int samples_in_chunk = 0;
|
||||
int size = pkt->size, ret = 0;
|
||||
uint8_t *reformatted_data = NULL;
|
||||
|
||||
if (trk->entry) {
|
||||
int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts;
|
||||
@@ -4362,11 +4357,35 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
pkt->dts = trk->cluster[trk->entry - 1].dts + 1;
|
||||
pkt->pts = AV_NOPTS_VALUE;
|
||||
}
|
||||
} else if (pkt->dts <= INT_MIN || pkt->dts >= INT_MAX) {
|
||||
av_log(s, AV_LOG_ERROR, "Application provided initial timestamp: %"PRId64" is out of range for mov/mp4 format\n",
|
||||
pkt->dts
|
||||
);
|
||||
|
||||
pkt->dts = 0;
|
||||
pkt->pts = AV_NOPTS_VALUE;
|
||||
}
|
||||
if (pkt->duration < 0 || pkt->duration > INT_MAX) {
|
||||
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
MOVMuxContext *mov = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
MOVTrack *trk = &mov->tracks[pkt->stream_index];
|
||||
AVCodecContext *enc = trk->enc;
|
||||
unsigned int samples_in_chunk = 0;
|
||||
int size = pkt->size, ret = 0;
|
||||
uint8_t *reformatted_data = NULL;
|
||||
|
||||
ret = check_pkt(s, pkt);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
|
||||
int ret;
|
||||
if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
|
||||
@@ -4631,6 +4650,10 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
int64_t frag_duration = 0;
|
||||
int size = pkt->size;
|
||||
|
||||
int ret = check_pkt(s, pkt);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
|
||||
int i;
|
||||
for (i = 0; i < s->nb_streams; i++)
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ static int mpegps_probe(AVProbeData *p)
|
||||
: AVPROBE_SCORE_EXTENSION / 2; // 1 more than .mpg
|
||||
if ((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys &&
|
||||
!pspack && p->buf_size > 2048 && vid + audio > invalid) /* PES stream */
|
||||
return (audio > 12 || vid > 3 + 2 * invalid) ? AVPROBE_SCORE_EXTENSION + 2
|
||||
return (audio > 12 || vid > 6 + 2 * invalid) ? AVPROBE_SCORE_EXTENSION + 2
|
||||
: AVPROBE_SCORE_EXTENSION / 2;
|
||||
|
||||
// 02-Penguin.flac has sys:0 priv1:0 pspack:0 vid:0 audio:1
|
||||
|
||||
+11
-2
@@ -2585,8 +2585,17 @@ static int mpegts_read_header(AVFormatContext *s)
|
||||
packet_count[nb_pcrs] = nb_packets;
|
||||
pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
|
||||
nb_pcrs++;
|
||||
if (nb_pcrs >= 2)
|
||||
break;
|
||||
if (nb_pcrs >= 2) {
|
||||
if (pcrs[1] - pcrs[0] > 0) {
|
||||
/* the difference needs to be positive to make sense for bitrate computation */
|
||||
break;
|
||||
} else {
|
||||
av_log(ts->stream, AV_LOG_WARNING, "invalid pcr pair %"PRId64" >= %"PRId64"\n", pcrs[0], pcrs[1]);
|
||||
pcrs[0] = pcrs[1];
|
||||
packet_count[0] = packet_count[1];
|
||||
nb_pcrs--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
finished_reading_packet(s, ts->raw_packet_size);
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
MXFTrack *track = s->streams[i]->priv_data;
|
||||
/* SMPTE 379M 7.3 */
|
||||
if (!memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number)))
|
||||
if (track && !memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number)))
|
||||
return i;
|
||||
}
|
||||
/* return 0 if only one stream, for OP Atom files with 0 as track number */
|
||||
@@ -826,7 +826,7 @@ static inline int mxf_read_utf16_string(AVIOContext *pb, int size, char** str, i
|
||||
int ret;
|
||||
size_t buf_size;
|
||||
|
||||
if (size < 0)
|
||||
if (size < 0 || size > INT_MAX/2)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
buf_size = size + size / 2 + 1;
|
||||
@@ -3012,7 +3012,7 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
|
||||
if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) {
|
||||
pkt->dts = mxf->current_edit_unit + t->first_dts;
|
||||
pkt->pts = t->ptses[mxf->current_edit_unit];
|
||||
} else if (track->intra_only) {
|
||||
} else if (track && track->intra_only) {
|
||||
/* intra-only -> PTS = EditUnit.
|
||||
* let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */
|
||||
pkt->pts = mxf->current_edit_unit;
|
||||
|
||||
@@ -643,6 +643,8 @@ static int ogg_get_length(AVFormatContext *s)
|
||||
int64_t pts;
|
||||
if (i < 0) continue;
|
||||
pts = ogg_calc_pts(s, i, NULL);
|
||||
if (s->streams[i]->duration == AV_NOPTS_VALUE)
|
||||
continue;
|
||||
if (pts != AV_NOPTS_VALUE && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start) {
|
||||
s->streams[i]->duration -= pts;
|
||||
ogg->streams[i].got_start= 1;
|
||||
|
||||
@@ -76,6 +76,13 @@ static int speex_header(AVFormatContext *s, int idx) {
|
||||
|
||||
spxp->packet_size = AV_RL32(p + 56);
|
||||
frames_per_packet = AV_RL32(p + 64);
|
||||
if (spxp->packet_size < 0 ||
|
||||
frames_per_packet < 0 ||
|
||||
spxp->packet_size * (int64_t)frames_per_packet > INT32_MAX / 256) {
|
||||
av_log(s, AV_LOG_ERROR, "invalid packet_size, frames_per_packet %d %d\n", spxp->packet_size, frames_per_packet);
|
||||
spxp->packet_size = 0;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (frames_per_packet)
|
||||
spxp->packet_size *= frames_per_packet;
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ static const AVOption avformat_options[] = {
|
||||
{"codec_whitelist", "List of decoders that are allowed to be used", OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D },
|
||||
{"format_whitelist", "List of demuxers that are allowed to be used", OFFSET(format_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D },
|
||||
{"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D },
|
||||
{"max_streams", "maximum number of streams", OFFSET(max_streams), AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D },
|
||||
{NULL},
|
||||
};
|
||||
|
||||
|
||||
+3
-1
@@ -84,8 +84,10 @@ static int rsd_read_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
codec->channels = avio_rl32(pb);
|
||||
if (!codec->channels)
|
||||
if (codec->channels <= 0 || codec->channels > INT_MAX / 36) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid number of channels: %d\n", codec->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
avio_skip(pb, 4); // Bit depth
|
||||
codec->sample_rate = avio_rl32(pb);
|
||||
|
||||
@@ -235,6 +235,14 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
|
||||
if (hdr != RTMP_PS_TWELVEBYTES)
|
||||
timestamp += prev_pkt[channel_id].timestamp;
|
||||
|
||||
if (prev_pkt[channel_id].read && size != prev_pkt[channel_id].size) {
|
||||
av_log(NULL, AV_LOG_ERROR, "RTMP packet size mismatch %d != %d\n",
|
||||
size,
|
||||
prev_pkt[channel_id].size);
|
||||
ff_rtmp_packet_destroy(&prev_pkt[channel_id]);
|
||||
prev_pkt[channel_id].read = 0;
|
||||
}
|
||||
|
||||
if (!prev_pkt[channel_id].read) {
|
||||
if ((ret = ff_rtmp_packet_create(p, channel_id, type, timestamp,
|
||||
size)) < 0)
|
||||
|
||||
@@ -927,7 +927,7 @@ static void expand_timestamps(void *log, struct sbg_script *s)
|
||||
}
|
||||
}
|
||||
if (s->start_ts == AV_NOPTS_VALUE)
|
||||
s->start_ts = s->opt_start_at_first ? s->tseq[0].ts.t : now;
|
||||
s->start_ts = (s->opt_start_at_first && s->tseq) ? s->tseq[0].ts.t : now;
|
||||
s->end_ts = s->opt_duration ? s->start_ts + s->opt_duration :
|
||||
AV_NOPTS_VALUE; /* may be overridden later by -E option */
|
||||
cur_ts = now;
|
||||
|
||||
+12
-5
@@ -708,7 +708,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
return ret;
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
st = s->streams[i];
|
||||
if (st->probe_packets)
|
||||
if (st->probe_packets || st->request_probe > 0)
|
||||
if ((err = probe_codec(s, st, NULL)) < 0)
|
||||
return err;
|
||||
av_assert0(st->request_probe <= 0);
|
||||
@@ -2284,6 +2284,7 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
|
||||
max_ts = av_rescale_rnd(max_ts, time_base.den,
|
||||
time_base.num * (int64_t)AV_TIME_BASE,
|
||||
AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
|
||||
stream_index = 0;
|
||||
}
|
||||
|
||||
ret = s->iformat->read_seek2(s, stream_index, min_ts,
|
||||
@@ -2373,7 +2374,7 @@ static void update_stream_timings(AVFormatContext *ic)
|
||||
end_time1 = av_rescale_q_rnd(st->duration, st->time_base,
|
||||
AV_TIME_BASE_Q,
|
||||
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
if (end_time1 != AV_NOPTS_VALUE && start_time1 <= INT64_MAX - end_time1) {
|
||||
if (end_time1 != AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
|
||||
end_time1 += start_time1;
|
||||
end_time = FFMAX(end_time, end_time1);
|
||||
}
|
||||
@@ -2401,11 +2402,14 @@ static void update_stream_timings(AVFormatContext *ic)
|
||||
if (ic->nb_programs) {
|
||||
for (i = 0; i < ic->nb_programs; i++) {
|
||||
p = ic->programs[i];
|
||||
if (p->start_time != AV_NOPTS_VALUE && p->end_time > p->start_time)
|
||||
if (p->start_time != AV_NOPTS_VALUE &&
|
||||
p->end_time > p->start_time &&
|
||||
p->end_time - (uint64_t)p->start_time <= INT64_MAX)
|
||||
duration = FFMAX(duration, p->end_time - p->start_time);
|
||||
}
|
||||
} else
|
||||
} else if (end_time >= start_time && end_time - (uint64_t)start_time <= INT64_MAX) {
|
||||
duration = FFMAX(duration, end_time - start_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (duration != INT64_MIN && duration > 0 && ic->duration == AV_NOPTS_VALUE) {
|
||||
@@ -3815,8 +3819,11 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
|
||||
int i;
|
||||
AVStream **streams;
|
||||
|
||||
if (s->nb_streams >= INT_MAX/sizeof(*streams))
|
||||
if (s->nb_streams >= FFMIN(s->max_streams, INT_MAX/sizeof(*streams))) {
|
||||
if (s->max_streams < INT_MAX/sizeof(*streams))
|
||||
av_log(s, AV_LOG_ERROR, "Number of streams exceeds max_streams parameter (%d), see the documentation if you wish to increase it\n", s->max_streams);
|
||||
return NULL;
|
||||
}
|
||||
streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams));
|
||||
if (!streams)
|
||||
return NULL;
|
||||
|
||||
+24
-5
@@ -248,19 +248,38 @@ static const AVClass imgutils_class = {
|
||||
.parent_log_context_offset = offsetof(ImgUtils, log_ctx),
|
||||
};
|
||||
|
||||
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
|
||||
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
|
||||
{
|
||||
ImgUtils imgutils = {
|
||||
.class = &imgutils_class,
|
||||
.log_offset = log_offset,
|
||||
.log_ctx = log_ctx,
|
||||
};
|
||||
int64_t stride = av_image_get_linesize(pix_fmt, w, 0);
|
||||
if (stride <= 0)
|
||||
stride = 8LL*w;
|
||||
stride += 128*8;
|
||||
|
||||
if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
|
||||
return 0;
|
||||
if ((int)w<=0 || (int)h<=0 || stride >= INT_MAX || stride*(uint64_t)(h+128) >= INT_MAX) {
|
||||
av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
|
||||
return AVERROR(EINVAL);
|
||||
if (max_pixels < INT64_MAX) {
|
||||
if (w*(int64_t)h > max_pixels) {
|
||||
av_log(&imgutils, AV_LOG_ERROR,
|
||||
"Picture size %ux%u exceeds specified max pixel count %"PRId64", see the documentation if you wish to increase it\n",
|
||||
w, h, max_pixels);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
|
||||
{
|
||||
return av_image_check_size2(w, h, INT64_MAX, AV_PIX_FMT_NONE, log_offset, log_ctx);
|
||||
}
|
||||
|
||||
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
|
||||
|
||||
@@ -191,6 +191,20 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
|
||||
*/
|
||||
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Check if the given dimension of an image is valid, meaning that all
|
||||
* bytes of the image can be addressed with a signed int.
|
||||
*
|
||||
* @param w the width of the picture
|
||||
* @param h the height of the picture
|
||||
* @param max_pixels the maximum number of pixels the user wants to accept
|
||||
* @param pix_fmt the pixel format, can be AV_PIX_FMT_NONE if unknown.
|
||||
* @param log_offset the offset to sum to the log level for logging with log_ctx
|
||||
* @param log_ctx the parent logging context, it may be NULL
|
||||
* @return >= 0 if valid, a negative error code otherwise
|
||||
*/
|
||||
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Check if the given sample aspect ratio of an image is valid.
|
||||
*
|
||||
|
||||
@@ -85,12 +85,12 @@
|
||||
#else // !(__mips == 64)
|
||||
#define LD(psrc) \
|
||||
( { \
|
||||
uint8_t *psrc_m = (uint8_t *) (psrc); \
|
||||
uint8_t *psrc_ld_m = (uint8_t *) (psrc); \
|
||||
uint32_t val0_m, val1_m; \
|
||||
uint64_t val_m = 0; \
|
||||
\
|
||||
val0_m = LW(psrc_m); \
|
||||
val1_m = LW(psrc_m + 4); \
|
||||
val0_m = LW(psrc_ld_m); \
|
||||
val1_m = LW(psrc_ld_m + 4); \
|
||||
\
|
||||
val_m = (uint64_t) (val1_m); \
|
||||
val_m = (uint64_t) ((val_m << 32) & 0xFFFFFFFF00000000); \
|
||||
@@ -172,12 +172,12 @@
|
||||
#else // !(__mips == 64)
|
||||
#define LD(psrc) \
|
||||
( { \
|
||||
uint8_t *psrc_m1 = (uint8_t *) (psrc); \
|
||||
uint8_t *psrc_ld_m = (uint8_t *) (psrc); \
|
||||
uint32_t val0_m, val1_m; \
|
||||
uint64_t val_m = 0; \
|
||||
\
|
||||
val0_m = LW(psrc_m1); \
|
||||
val1_m = LW(psrc_m1 + 4); \
|
||||
val0_m = LW(psrc_ld_m); \
|
||||
val1_m = LW(psrc_ld_m + 4); \
|
||||
\
|
||||
val_m = (uint64_t) (val1_m); \
|
||||
val_m = (uint64_t) ((val_m << 32) & 0xFFFFFFFF00000000); \
|
||||
|
||||
@@ -67,6 +67,7 @@ static uint32_t get_generic_seed(void)
|
||||
uint8_t tmp[120];
|
||||
struct AVSHA *sha = (void*)tmp;
|
||||
clock_t last_t = 0;
|
||||
clock_t last_td = 0;
|
||||
static uint64_t i = 0;
|
||||
static uint32_t buffer[512] = { 0 };
|
||||
unsigned char digest[20];
|
||||
@@ -86,11 +87,12 @@ static uint32_t get_generic_seed(void)
|
||||
|
||||
for (;;) {
|
||||
clock_t t = clock();
|
||||
|
||||
if (last_t == t) {
|
||||
buffer[i & 511]++;
|
||||
if (last_t + 2*last_td + (CLOCKS_PER_SEC > 1000) >= t) {
|
||||
last_td = t - last_t;
|
||||
buffer[i & 511] = 1664525*buffer[i & 511] + 1013904223 + (last_td % 3294638521U);
|
||||
} else {
|
||||
buffer[++i & 511] += (t - last_t) % 3294638521U;
|
||||
last_td = t - last_t;
|
||||
buffer[++i & 511] += last_td % 3294638521U;
|
||||
if (last_i && i - last_i > 4 || i - last_i > 64 || TEST && i - last_i > 8)
|
||||
break;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user