Compare commits
146 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71fb613263 | |||
| c3ad886251 | |||
| 6f1b402e31 | |||
| 268c460c97 | |||
| e5a261e93d | |||
| 00c2073071 | |||
| 4d82b7bac4 | |||
| c513bd4803 | |||
| a56d3a1ef1 | |||
| 4bcb493a0e | |||
| 3392936e82 | |||
| ea238698bc | |||
| ad28b01a14 | |||
| fa20129765 | |||
| 0f6580b169 | |||
| 4c34976fea | |||
| 8b84cffb30 | |||
| bc9e149c2a | |||
| 0c5f3c230a | |||
| 545cfeeebd | |||
| 3eaf65305e | |||
| 73eb9578c1 | |||
| f97265961e | |||
| 773d1b857b | |||
| 261ff2e208 | |||
| 8478879af6 | |||
| e243076b32 | |||
| e5a88d62b6 | |||
| 2ae1a70cd5 | |||
| 68da8e9703 | |||
| 2a47fecb09 | |||
| 9f828f147b | |||
| fdff97fe47 | |||
| 79afac279b | |||
| 04b48cefac | |||
| 7436138621 | |||
| b314170e2b | |||
| 3f4ec2d6af | |||
| 0891a36dd8 | |||
| 383a51855a | |||
| 37aaa56842 | |||
| a73cd6aebf | |||
| 2177cc8eb8 | |||
| a16aaae628 | |||
| 3f28c576e0 | |||
| d585a0a1cc | |||
| b48951bd29 | |||
| a54187b7d9 | |||
| a1f13b592b | |||
| 4bc4cafaef | |||
| c152b69715 | |||
| a8f16d4eb4 | |||
| 78062c6d71 | |||
| ec47a3b95f | |||
| e5ed035350 | |||
| 8ff4a080bf | |||
| 98ba25bd11 | |||
| 9dfac9e9e9 | |||
| 2c737a2cb0 | |||
| 1d9553542b | |||
| 7a42dcf088 | |||
| ecbdaa9b4c | |||
| 25178bcd73 | |||
| d15dfed7ac | |||
| e7d1caf41f | |||
| c44ce5d804 | |||
| 5ee0beb799 | |||
| b9b148ef87 | |||
| cc5c5beb98 | |||
| df30441b16 | |||
| 21b786d628 | |||
| 0191e5f13e | |||
| c2c9dac463 | |||
| 5f0afb748e | |||
| ed496ac4f5 | |||
| bd7c92f484 | |||
| 446de009f9 | |||
| 9a814adf89 | |||
| f4a792fbb9 | |||
| 12043b8a6b | |||
| 16ab46b4fc | |||
| c7f723ddb6 | |||
| 85f5aaa15f | |||
| 3ce3d5ea9c | |||
| b21ebecec1 | |||
| 399670d668 | |||
| 7e2559982f | |||
| 7c00e515a0 | |||
| df0d34caaf | |||
| eb252776d8 | |||
| 5b9b498e1b | |||
| 8b644b85f4 | |||
| fe87396f35 | |||
| 0035e034c0 | |||
| 9363a18e49 | |||
| 1882734fe1 | |||
| cd76f3ed59 | |||
| ff6d408ac0 | |||
| 815efd3f68 | |||
| 46f74da439 | |||
| 3ab3a39ec6 | |||
| f18d625883 | |||
| 52accf7310 | |||
| d46f1d89f1 | |||
| 48957599a5 | |||
| 3092b4d271 | |||
| b1deea36aa | |||
| d3e208f5f5 | |||
| 93f5b347e6 | |||
| 6bc0cf403e | |||
| 0b4c403f2a | |||
| 23fb7097ee | |||
| 7fe75d51fe | |||
| 8063b5e289 | |||
| 8f9b6ac0e8 | |||
| 572568cff4 | |||
| d1fa43d5b9 | |||
| a9f13f883d | |||
| e5c8b53c68 | |||
| 4ecf6ca450 | |||
| 40065896ec | |||
| 732d39e353 | |||
| 0f5afdda0a | |||
| f368a6cf68 | |||
| 35ccd5a569 | |||
| 58e57ef180 | |||
| a71c87e4b5 | |||
| e3a733ba8e | |||
| 2ccfbc888c | |||
| 8ea01dca10 | |||
| a6df0d5140 | |||
| ff9dbf3b18 | |||
| b409640d3c | |||
| f24ca075ff | |||
| 1ea783dea6 | |||
| 519904111b | |||
| d1620856da | |||
| 388ed57114 | |||
| dd27929fdc | |||
| 768d4c2e2a | |||
| e24d23accc | |||
| aa28df74ab | |||
| 944ee75106 | |||
| d4b7b3c03e | |||
| 7ffb7d4b04 | |||
| 8e98dfc57f |
@@ -1,6 +1,6 @@
|
||||
See the Git history of the project (git://source.ffmpeg.org/ffmpeg) to
|
||||
See the Git history of the project (https://git.ffmpeg.org/ffmpeg) to
|
||||
get the names of people who have contributed to FFmpeg.
|
||||
|
||||
To check the log, you can type the command "git log" in the FFmpeg
|
||||
source directory, or browse the online repository at
|
||||
http://source.ffmpeg.org.
|
||||
https://git.ffmpeg.org/ffmpeg
|
||||
|
||||
@@ -1,6 +1,152 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 4.4.4:
|
||||
- avcodec/tests/snowenc: Fix 2nd test
|
||||
- avcodec/tests/snowenc: return a failure if DWT/IDWT mismatches
|
||||
- avcodec/snowenc: Fix visual weight calculation
|
||||
- avcodec/tests/snowenc: unbreak DWT tests
|
||||
- avcodec/vp3: Add missing check for av_malloc
|
||||
- avformat/nutdec: Add check for avformat_new_stream
|
||||
- avcodec/mpeg12dec: Check input size
|
||||
- avcodec/escape124: Fix some return codes
|
||||
- avcodec/escape124: fix signdness of end of input check
|
||||
- Use https for repository links
|
||||
- avcodec/rpzaenc: stop accessing out of bounds frame
|
||||
- avcodec/motionpixels: Mask pixels to valid values
|
||||
- avcodec/xpmdec: Check size before allocation to avoid truncation
|
||||
- avcodec/bink: Avoid undefined out of array end pointers in binkb_decode_plane()
|
||||
- avcodec/bink: Fix off by 1 error in ref end
|
||||
- avcodec/utils: Ensure linesize for SVQ3
|
||||
- avcodec/utils: allocate a line more for VC1 and WMV3
|
||||
- avcodec/videodsp_template: Adjust pointers to avoid undefined pointer things
|
||||
- avcodec/pngdec: Check deloco index more exactly
|
||||
- avcodec/ffv1dec: Check that num h/v slices is supported
|
||||
- avformat/mov: Check samplesize and offset to avoid integer overflow
|
||||
- avcodec/pictordec: Remove mid exit branch
|
||||
- avcodec/eac3dec: avoid float noise in fixed mode addition to overflow
|
||||
- avcodec/utils: use 32pixel alignment for bink
|
||||
- avcodec/scpr3: Check bx
|
||||
- avcodec/012v: Order operations for odd size handling
|
||||
- avcodec/eatgq: : Check index increments in tgq_decode_block()
|
||||
- avcodec/scpr: Test bx before use
|
||||
- avformat/mxfdec: Use 64bit in remainder
|
||||
- avcodec/sunrast: Fix maplength check
|
||||
- avcodec/wavpack: Avoid undefined shift in get_tail()
|
||||
- avcodec/wavpack: Check for end of input in wv_unpack_dsd_high()
|
||||
- avformat/id3v2: Check taglen in read_uslt()
|
||||
- avcodec/tiff: Ignore tile_count
|
||||
- avcodec/ffv1dec: restructure slice coordinate reading a bit
|
||||
- avcodec/mlpdec: Check max matrix instead of max channel in noise check
|
||||
- swscale/input: Use more unsigned intermediates
|
||||
- avcodec/alsdec: The minimal block is at least 7 bits
|
||||
- avformat/replaygain: avoid undefined / negative abs
|
||||
- swscale/output: Bias 16bps output calculations to improve non overflowing range
|
||||
- avcodec/speedhq: Check buf_size to be big enough for DC
|
||||
- avcodec/ffv1dec: Fail earlier if prior context is corrupted
|
||||
- avcodec/nvenc: fix b-frame DTS behavior with fractional framerates
|
||||
- avfilter/vf_untile: swap the chroma shift values used for plane offsets
|
||||
- avcodec/nvenc: fix vbv buffer size in cq mode
|
||||
- avcodec/mjpegenc: take into account component count when writing the SOF header size
|
||||
- swscale: aarch64: Fix yuv2rgb with negative stride
|
||||
|
||||
version 4.4.3:
|
||||
- avformat/vividas: Check packet size
|
||||
- configure: link to libatomic when it's present
|
||||
- avcodec/dstdec: Check for overflow in build_filter()
|
||||
- avformat/spdifdec: Use 64bit to compute bit rate
|
||||
- avformat/rpl: Use 64bit for duration computation
|
||||
- avformat/xwma: Use av_rescale() for duration computation
|
||||
- avformat/sdsdec: Use av_rescale() to avoid intermediate overflow in duration calculation
|
||||
- avformat/sbgdec: Check ts_int in genrate_intervals
|
||||
- avformat/rmdec: check tag_size
|
||||
- avformat/nutdec: Check fields
|
||||
- avformat/flvdec: Use 64bit for sum_flv_tag_size
|
||||
- avformat/jacosubdec: Fix overflow in get_shift()
|
||||
- avformat/dxa: avoid bpc overflows
|
||||
- avformat/cafdec: Check that nb_frasmes fits within 64bit
|
||||
- avformat/asfdec_o: Limit packet offset
|
||||
- avformat/ape: Check frames size
|
||||
- avformat/icodec: Check nb_pal
|
||||
- avformat/aiffdec: Use 64bit for block_duration use
|
||||
- avformat/aiffdec: Check block_duration
|
||||
- avformat/mxfdec: only probe max run in
|
||||
- avformat/mxfdec: Check run_in is within 65536
|
||||
- avcodec/mjpegdec: Check for unsupported bayer case
|
||||
- avcodec/apedec: Fix integer overflow in filter_3800()
|
||||
- avcodec/tta: Check 24bit scaling for overflow
|
||||
- avcodec/mobiclip: Check quantizer for overflow
|
||||
- avcodec/exr: Check preview psize
|
||||
- avcodec/tiff: Fix loop detection
|
||||
- libavformat/hls: Free keys
|
||||
- avcodec/fmvc: Move frame allocation to a later stage
|
||||
- avfilter/vf_showinfo: remove backspaces
|
||||
- avcodec/speedhq: Check width
|
||||
- avcodec/bink: disallow odd positioned scaled blocks
|
||||
- avformat/asfdec_o: limit recursion depth in asf_read_unknown()
|
||||
- doc/git-howto.texi: Document commit signing
|
||||
- libavcodec/8bps: Check that line lengths fit within the buffer
|
||||
- avcodec/midivid: Perform lzss_uncompress() before ff_reget_buffer()
|
||||
- libavformat/iff: Check for overflow in body_end calculation
|
||||
- avformat/avidec: Prevent entity expansion attacks
|
||||
- avcodec/h263dec: Sanity check against minimal I/P frame size
|
||||
- avcodec/hevcdec: Check s->ref in the md5 path similar to hwaccel
|
||||
- avcodec/mpegaudiodec_template: use unsigned shift in handle_crc()
|
||||
- avformat/subviewerdec: Make read_ts() more flexible
|
||||
- avcodec/mjpegdec: bayer and rct are incompatible
|
||||
- MAINTAINERS: Add ED25519 key for signing my commits in the future
|
||||
- avcodec/hevc_filter: copy_CTB() only within width&height
|
||||
- avcodec/tiff: Check tile_length and tile_width
|
||||
- avcodec/mss4: Check image size with av_image_check_size2()
|
||||
- avformat/flvdec: Check for EOF in index reading
|
||||
- avformat/nutdec: Check get_packetheader() in mainheader
|
||||
- avformat/asfdec_f: Use 64bit for packet start time
|
||||
- avcodec/exr: Check x/ysize
|
||||
- tools/target_dec_fuzzer: Adjust threshold for MMVIDEO
|
||||
- avcodec/lagarith: Check dst/src in zero run code
|
||||
- avcodec/h264dec: Skip late SEI
|
||||
- avcodec/sbrdsp_fixed: Fix integer overflows in sbr_qmf_deint_neg_c()
|
||||
- avfilter/vf_signature: Fix integer overflow in filter_frame()
|
||||
- avformat/rtsp: break on unknown protocols
|
||||
- avcodec/hevcdsp_template: stay within tables in sao_band_filter()
|
||||
- avcodec/tiff: Check pixel format types for dng
|
||||
- avcodec/qpeldsp: copy less for the mc0x cases
|
||||
- avformat/aaxdec: Check for empty segments
|
||||
- avcodec/ffv1dec: Limit golomb rice coded slices to width 8M
|
||||
- avformat/iff: simplify duration calculation
|
||||
- avcodec/wnv1: Check for width =1
|
||||
- avcodec/ffv1dec_template: fix indention
|
||||
- avformat/sctp: close socket on errors
|
||||
- avcodec/aasc: Fix indention
|
||||
- avcodec/qdrw: adjust max colors to array size
|
||||
- avcodec/alacdsp: Make intermediates unsigned
|
||||
- avformat/aiffdec: cleanup size handling for extreem cases
|
||||
- avformat/matroskadec: avoid integer overflows in SAR computation
|
||||
- avcodec/jpeglsdec: fix end check for xfrm
|
||||
- avcodec/cdgraphics: limit scrolling to the line
|
||||
- avformat/hls: Limit start_seq_no to one bit less
|
||||
- avformat/aiffdec: avoid integer overflow in get_meta()
|
||||
- avformat/ape: more bits in size for less overflows
|
||||
- avformat/aviobuf: Check buf_size in ffio_ensure_seekback()
|
||||
- avformat/bfi: Check offsets better
|
||||
- avformat/asfdec_f: Check packet_frag_timestamp
|
||||
- avcodec/texturedspenc: Fix indexing in color distribution determination
|
||||
- avformat/act: Check ff_get_wav_header() for failure
|
||||
- avcodec/libxavs2: Improve r redundancy in occured
|
||||
- avformat/libzmq: Improve r redundancy in occured
|
||||
- avfilter/vsrc_mandelbrot: Check for malloc failure
|
||||
- avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements
|
||||
- avfilter/video: Add ff_default_get_video_buffer2() to set specific alignment
|
||||
- avformat/genh: Check sample rate
|
||||
- configure: bump year
|
||||
- lavc/videotoolbox: do not pass AVCodecContext to decoder output callback
|
||||
- lavc/pthread_frame: always transfer stashed hwaccel state
|
||||
- avcodec/arm/sbcenc: avoid callee preserved vfp registers
|
||||
- avfilter/vf_scale: overwrite the width and height expressions with the original values
|
||||
- lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads
|
||||
- configure: extend SDL check to accept all 2.x versions
|
||||
- lavf/tls_mbedtls: add support for mbedtls version 3
|
||||
|
||||
version 4.4.2:
|
||||
- fate: update reference files after the recent dash manifest muxer changes
|
||||
- avformat/webmdashenc: fix on-demand profile string
|
||||
|
||||
@@ -615,6 +615,7 @@ Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
|
||||
Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
|
||||
Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464
|
||||
Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
|
||||
DD1E C9E8 DE08 5C62 9B3E 1846 B18E 8928 B394 8D64
|
||||
Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
|
||||
Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1
|
||||
Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029
|
||||
|
||||
@@ -3706,23 +3706,23 @@ cws2fws_extralibs="zlib_extralibs"
|
||||
|
||||
# libraries, in any order
|
||||
avcodec_deps="avutil"
|
||||
avcodec_suggest="libm"
|
||||
avcodec_suggest="libm stdatomic"
|
||||
avcodec_select="null_bsf"
|
||||
avdevice_deps="avformat avcodec avutil"
|
||||
avdevice_suggest="libm"
|
||||
avdevice_suggest="libm stdatomic"
|
||||
avfilter_deps="avutil"
|
||||
avfilter_suggest="libm"
|
||||
avfilter_suggest="libm stdatomic"
|
||||
avformat_deps="avcodec avutil"
|
||||
avformat_suggest="libm network zlib"
|
||||
avformat_suggest="libm network zlib stdatomic"
|
||||
avresample_deps="avutil"
|
||||
avresample_suggest="libm"
|
||||
avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt"
|
||||
avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
|
||||
postproc_deps="avutil gpl"
|
||||
postproc_suggest="libm"
|
||||
postproc_suggest="libm stdatomic"
|
||||
swresample_deps="avutil"
|
||||
swresample_suggest="libm libsoxr"
|
||||
swresample_suggest="libm libsoxr stdatomic"
|
||||
swscale_deps="avutil"
|
||||
swscale_suggest="libm"
|
||||
swscale_suggest="libm stdatomic"
|
||||
|
||||
avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs"
|
||||
avfilter_extralibs="pthreads_extralibs"
|
||||
@@ -6186,7 +6186,14 @@ check_headers asm/types.h
|
||||
# it seems there are versions of clang in some distros that try to use the
|
||||
# gcc headers, which explodes for stdatomic
|
||||
# so we also check that atomics actually work here
|
||||
check_builtin stdatomic stdatomic.h "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar"
|
||||
#
|
||||
# some configurations also require linking to libatomic, so try
|
||||
# both with -latomic and without
|
||||
for LATOMIC in "-latomic" ""; do
|
||||
check_builtin stdatomic stdatomic.h \
|
||||
"atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar" \
|
||||
$LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
|
||||
done
|
||||
|
||||
check_lib advapi32 "windows.h" RegCloseKey -ladvapi32
|
||||
check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt &&
|
||||
@@ -6555,7 +6562,7 @@ fi
|
||||
|
||||
if enabled sdl2; then
|
||||
SDL2_CONFIG="${cross_prefix}sdl2-config"
|
||||
test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 2.1.0" SDL_events.h SDL_PollEvent
|
||||
test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 3.0.0" SDL_events.h SDL_PollEvent
|
||||
if disabled sdl2 && "${SDL2_CONFIG}" --version > /dev/null 2>&1; then
|
||||
sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
|
||||
sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
|
||||
@@ -7584,7 +7591,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 2021
|
||||
#define CONFIG_THIS_YEAR 2023
|
||||
#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
@@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 4.4.2
|
||||
PROJECT_NUMBER = 4.4.4
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@
|
||||
The FFmpeg developers.
|
||||
|
||||
For details about the authorship, see the Git history of the project
|
||||
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
(https://git.ffmpeg.org/ffmpeg), e.g. by typing the command
|
||||
@command{git log} in the FFmpeg source directory, or browsing the
|
||||
online repository at @url{http://source.ffmpeg.org}.
|
||||
online repository at @url{https://git.ffmpeg.org/ffmpeg}.
|
||||
|
||||
Maintainers for the specific components are listed in the file
|
||||
@file{MAINTAINERS} in the source code tree.
|
||||
|
||||
+22
-2
@@ -53,7 +53,7 @@ Most distribution and operating system provide a package for it.
|
||||
@section Cloning the source tree
|
||||
|
||||
@example
|
||||
git clone git://source.ffmpeg.org/ffmpeg <target>
|
||||
git clone https://git.ffmpeg.org/ffmpeg.git <target>
|
||||
@end example
|
||||
|
||||
This will put the FFmpeg sources into the directory @var{<target>}.
|
||||
@@ -187,11 +187,18 @@ to make sure you don't have untracked files or deletions.
|
||||
git add [-i|-p|-A] <filenames/dirnames>
|
||||
@end example
|
||||
|
||||
Make sure you have told Git your name and email address
|
||||
Make sure you have told Git your name, email address and GPG key
|
||||
|
||||
@example
|
||||
git config --global user.name "My Name"
|
||||
git config --global user.email my@@email.invalid
|
||||
git config --global user.signingkey ABCDEF0123245
|
||||
@end example
|
||||
|
||||
Enable signing all commits or use -S
|
||||
|
||||
@example
|
||||
git config --global commit.gpgsign true
|
||||
@end example
|
||||
|
||||
Use @option{--global} to set the global configuration for all your Git checkouts.
|
||||
@@ -393,6 +400,19 @@ git checkout -b svn_23456 $SHA1
|
||||
where @var{$SHA1} is the commit hash from the @command{git log} output.
|
||||
|
||||
|
||||
@chapter gpg key generation
|
||||
|
||||
If you have no gpg key yet, we recommend that you create a ed25519 based key as it
|
||||
is small, fast and secure. Especially it results in small signatures in git.
|
||||
|
||||
@example
|
||||
gpg --default-new-key-algo "ed25519/cert,sign+cv25519/encr" --quick-generate-key "human@@server.com"
|
||||
@end example
|
||||
|
||||
When generating a key, make sure the email specified matches the email used in git as some sites like
|
||||
github consider mismatches a reason to declare such commits unverified. After generating a key you
|
||||
can add it to the MAINTAINER file and upload it to a keyserver.
|
||||
|
||||
@chapter Pre-push checklist
|
||||
|
||||
Once you have a set of commits that you feel are ready for pushing,
|
||||
|
||||
+2
-2
@@ -131,8 +131,8 @@ static int zero12v_decode_frame(AVCodecContext *avctx, void *data,
|
||||
u = x/2 + (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
|
||||
v = x/2 + (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
|
||||
memcpy(y, y_temp, sizeof(*y) * (width - x));
|
||||
memcpy(u, u_temp, sizeof(*u) * (width - x + 1) / 2);
|
||||
memcpy(v, v_temp, sizeof(*v) * (width - x + 1) / 2);
|
||||
memcpy(u, u_temp, sizeof(*u) * ((width - x + 1) / 2));
|
||||
memcpy(v, v_temp, sizeof(*v) * ((width - x + 1) / 2));
|
||||
}
|
||||
|
||||
line_end += stride;
|
||||
|
||||
@@ -70,6 +70,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
unsigned char *planemap = c->planemap;
|
||||
int ret;
|
||||
|
||||
if (buf_size < planes * height *2)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
+17
-17
@@ -104,26 +104,26 @@ static int aasc_decode_frame(AVCodecContext *avctx,
|
||||
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
|
||||
break;
|
||||
case MKTAG('A', 'A', 'S', 'C'):
|
||||
switch (compr) {
|
||||
case 0:
|
||||
stride = (avctx->width * psize + psize) & ~psize;
|
||||
if (buf_size < stride * avctx->height)
|
||||
switch (compr) {
|
||||
case 0:
|
||||
stride = (avctx->width * psize + psize) & ~psize;
|
||||
if (buf_size < stride * avctx->height)
|
||||
return AVERROR_INVALIDDATA;
|
||||
for (i = avctx->height - 1; i >= 0; i--) {
|
||||
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * psize);
|
||||
buf += stride;
|
||||
buf_size -= stride;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
bytestream2_init(&s->gb, buf, buf_size);
|
||||
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
|
||||
return AVERROR_INVALIDDATA;
|
||||
for (i = avctx->height - 1; i >= 0; i--) {
|
||||
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * psize);
|
||||
buf += stride;
|
||||
buf_size -= stride;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
bytestream2_init(&s->gb, buf, buf_size);
|
||||
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag);
|
||||
return -1;
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
#define AC3_DYNAMIC_RANGE1 0
|
||||
|
||||
typedef int INTFLOAT;
|
||||
typedef unsigned int UINTFLOAT;
|
||||
typedef int16_t SHORTFLOAT;
|
||||
|
||||
#else /* USE_FIXED */
|
||||
@@ -93,6 +94,7 @@ typedef int16_t SHORTFLOAT;
|
||||
#define AC3_DYNAMIC_RANGE1 1.0f
|
||||
|
||||
typedef float INTFLOAT;
|
||||
typedef float UINTFLOAT;
|
||||
typedef float SHORTFLOAT;
|
||||
|
||||
#endif /* USE_FIXED */
|
||||
|
||||
@@ -29,12 +29,12 @@ static void decorrelate_stereo(int32_t *buffer[2], int nb_samples,
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nb_samples; i++) {
|
||||
int32_t a, b;
|
||||
uint32_t a, b;
|
||||
|
||||
a = buffer[0][i];
|
||||
b = buffer[1][i];
|
||||
|
||||
a -= (int)(b * (unsigned)decorr_left_weight) >> decorr_shift;
|
||||
a -= (int)(b * decorr_left_weight) >> decorr_shift;
|
||||
b += a;
|
||||
|
||||
buffer[0][i] = b;
|
||||
|
||||
+1
-1
@@ -1017,7 +1017,7 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
|
||||
*bd->shift_lsbs = 0;
|
||||
|
||||
if (get_bits_left(gb) < 1)
|
||||
if (get_bits_left(gb) < 7)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
// read block type flag and read the samples accordingly
|
||||
|
||||
+1
-1
@@ -930,7 +930,7 @@ static av_always_inline int filter_3800(APEPredictor *p,
|
||||
p->coeffsB[filter][0] += (((d3 >> 29) & 4) - 2) * sign;
|
||||
p->coeffsB[filter][1] -= (((d4 >> 30) & 2) - 1) * sign;
|
||||
|
||||
p->filterB[filter] = p->lastA[filter] + (predictionB >> shift);
|
||||
p->filterB[filter] = p->lastA[filter] + (unsigned)(predictionB >> shift);
|
||||
p->filterA[filter] = p->filterB[filter] + (unsigned)((int)(p->filterA[filter] * 31U) >> 5);
|
||||
|
||||
return p->filterA[filter];
|
||||
|
||||
@@ -38,49 +38,49 @@ function ff_sbc_analyze_4_neon, export=1
|
||||
/* TODO: merge even and odd cases (or even merge all four calls to this
|
||||
* function) in order to have only aligned reads from 'in' array
|
||||
* and reduce number of load instructions */
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmull.s16 q0, d4, d8
|
||||
vld1.16 {d6, d7}, [r0, :64]!
|
||||
vmull.s16 q1, d5, d9
|
||||
vld1.16 {d10, d11}, [r2, :128]!
|
||||
vmull.s16 q0, d16, d20
|
||||
vld1.16 {d18, d19}, [r0, :64]!
|
||||
vmull.s16 q1, d17, d21
|
||||
vld1.16 {d22, d23}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q0, d6, d10
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vmlal.s16 q1, d7, d11
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vmlal.s16 q0, d18, d22
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vmlal.s16 q1, d19, d23
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q0, d4, d8
|
||||
vld1.16 {d6, d7}, [r0, :64]!
|
||||
vmlal.s16 q1, d5, d9
|
||||
vld1.16 {d10, d11}, [r2, :128]!
|
||||
vmlal.s16 q0, d16, d20
|
||||
vld1.16 {d18, d19}, [r0, :64]!
|
||||
vmlal.s16 q1, d17, d21
|
||||
vld1.16 {d22, d23}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q0, d6, d10
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vmlal.s16 q1, d7, d11
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vmlal.s16 q0, d18, d22
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vmlal.s16 q1, d19, d23
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q0, d4, d8
|
||||
vmlal.s16 q1, d5, d9
|
||||
vmlal.s16 q0, d16, d20
|
||||
vmlal.s16 q1, d17, d21
|
||||
|
||||
vpadd.s32 d0, d0, d1
|
||||
vpadd.s32 d1, d2, d3
|
||||
|
||||
vrshrn.s32 d0, q0, SBC_PROTO_FIXED_SCALE
|
||||
|
||||
vld1.16 {d2, d3, d4, d5}, [r2, :128]!
|
||||
vld1.16 {d16, d17, d18, d19}, [r2, :128]!
|
||||
|
||||
vdup.i32 d1, d0[1] /* TODO: can be eliminated */
|
||||
vdup.i32 d0, d0[0] /* TODO: can be eliminated */
|
||||
|
||||
vmull.s16 q3, d2, d0
|
||||
vmull.s16 q4, d3, d0
|
||||
vmlal.s16 q3, d4, d1
|
||||
vmlal.s16 q4, d5, d1
|
||||
vmull.s16 q10, d16, d0
|
||||
vmull.s16 q11, d17, d0
|
||||
vmlal.s16 q10, d18, d1
|
||||
vmlal.s16 q11, d19, d1
|
||||
|
||||
vpadd.s32 d0, d6, d7 /* TODO: can be eliminated */
|
||||
vpadd.s32 d1, d8, d9 /* TODO: can be eliminated */
|
||||
vpadd.s32 d0, d20, d21 /* TODO: can be eliminated */
|
||||
vpadd.s32 d1, d22, d23 /* TODO: can be eliminated */
|
||||
|
||||
vst1.32 {d0, d1}, [r1, :128]
|
||||
|
||||
@@ -91,57 +91,57 @@ function ff_sbc_analyze_8_neon, export=1
|
||||
/* TODO: merge even and odd cases (or even merge all four calls to this
|
||||
* function) in order to have only aligned reads from 'in' array
|
||||
* and reduce number of load instructions */
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmull.s16 q6, d4, d8
|
||||
vld1.16 {d6, d7}, [r0, :64]!
|
||||
vmull.s16 q7, d5, d9
|
||||
vld1.16 {d10, d11}, [r2, :128]!
|
||||
vmull.s16 q8, d6, d10
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vmull.s16 q9, d7, d11
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vmull.s16 q12, d16, d20
|
||||
vld1.16 {d18, d19}, [r0, :64]!
|
||||
vmull.s16 q13, d17, d21
|
||||
vld1.16 {d22, d23}, [r2, :128]!
|
||||
vmull.s16 q14, d18, d22
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vmull.s16 q15, d19, d23
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q6, d4, d8
|
||||
vld1.16 {d6, d7}, [r0, :64]!
|
||||
vmlal.s16 q7, d5, d9
|
||||
vld1.16 {d10, d11}, [r2, :128]!
|
||||
vmlal.s16 q8, d6, d10
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vmlal.s16 q9, d7, d11
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vmlal.s16 q12, d16, d20
|
||||
vld1.16 {d18, d19}, [r0, :64]!
|
||||
vmlal.s16 q13, d17, d21
|
||||
vld1.16 {d22, d23}, [r2, :128]!
|
||||
vmlal.s16 q14, d18, d22
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vmlal.s16 q15, d19, d23
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q6, d4, d8
|
||||
vld1.16 {d6, d7}, [r0, :64]!
|
||||
vmlal.s16 q7, d5, d9
|
||||
vld1.16 {d10, d11}, [r2, :128]!
|
||||
vmlal.s16 q8, d6, d10
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vmlal.s16 q9, d7, d11
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vmlal.s16 q12, d16, d20
|
||||
vld1.16 {d18, d19}, [r0, :64]!
|
||||
vmlal.s16 q13, d17, d21
|
||||
vld1.16 {d22, d23}, [r2, :128]!
|
||||
vmlal.s16 q14, d18, d22
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vmlal.s16 q15, d19, d23
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q6, d4, d8
|
||||
vld1.16 {d6, d7}, [r0, :64]!
|
||||
vmlal.s16 q7, d5, d9
|
||||
vld1.16 {d10, d11}, [r2, :128]!
|
||||
vmlal.s16 q8, d6, d10
|
||||
vld1.16 {d4, d5}, [r0, :64]!
|
||||
vmlal.s16 q9, d7, d11
|
||||
vld1.16 {d8, d9}, [r2, :128]!
|
||||
vmlal.s16 q12, d16, d20
|
||||
vld1.16 {d18, d19}, [r0, :64]!
|
||||
vmlal.s16 q13, d17, d21
|
||||
vld1.16 {d22, d23}, [r2, :128]!
|
||||
vmlal.s16 q14, d18, d22
|
||||
vld1.16 {d16, d17}, [r0, :64]!
|
||||
vmlal.s16 q15, d19, d23
|
||||
vld1.16 {d20, d21}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q6, d4, d8
|
||||
vld1.16 {d6, d7}, [r0, :64]!
|
||||
vmlal.s16 q7, d5, d9
|
||||
vld1.16 {d10, d11}, [r2, :128]!
|
||||
vmlal.s16 q12, d16, d20
|
||||
vld1.16 {d18, d19}, [r0, :64]!
|
||||
vmlal.s16 q13, d17, d21
|
||||
vld1.16 {d22, d23}, [r2, :128]!
|
||||
|
||||
vmlal.s16 q8, d6, d10
|
||||
vmlal.s16 q9, d7, d11
|
||||
vmlal.s16 q14, d18, d22
|
||||
vmlal.s16 q15, d19, d23
|
||||
|
||||
vpadd.s32 d0, d12, d13
|
||||
vpadd.s32 d1, d14, d15
|
||||
vpadd.s32 d2, d16, d17
|
||||
vpadd.s32 d3, d18, d19
|
||||
vpadd.s32 d0, d24, d25
|
||||
vpadd.s32 d1, d26, d27
|
||||
vpadd.s32 d2, d28, d29
|
||||
vpadd.s32 d3, d30, d31
|
||||
|
||||
vrshr.s32 q0, q0, SBC_PROTO_FIXED_SCALE
|
||||
vrshr.s32 q1, q1, SBC_PROTO_FIXED_SCALE
|
||||
@@ -153,38 +153,38 @@ function ff_sbc_analyze_8_neon, export=1
|
||||
vdup.i32 d1, d0[1] /* TODO: can be eliminated */
|
||||
vdup.i32 d0, d0[0] /* TODO: can be eliminated */
|
||||
|
||||
vld1.16 {d4, d5}, [r2, :128]!
|
||||
vmull.s16 q6, d4, d0
|
||||
vld1.16 {d6, d7}, [r2, :128]!
|
||||
vmull.s16 q7, d5, d0
|
||||
vmull.s16 q8, d6, d0
|
||||
vmull.s16 q9, d7, d0
|
||||
vld1.16 {d16, d17}, [r2, :128]!
|
||||
vmull.s16 q12, d16, d0
|
||||
vld1.16 {d18, d19}, [r2, :128]!
|
||||
vmull.s16 q13, d17, d0
|
||||
vmull.s16 q14, d18, d0
|
||||
vmull.s16 q15, d19, d0
|
||||
|
||||
vld1.16 {d4, d5}, [r2, :128]!
|
||||
vmlal.s16 q6, d4, d1
|
||||
vld1.16 {d6, d7}, [r2, :128]!
|
||||
vmlal.s16 q7, d5, d1
|
||||
vmlal.s16 q8, d6, d1
|
||||
vmlal.s16 q9, d7, d1
|
||||
vld1.16 {d16, d17}, [r2, :128]!
|
||||
vmlal.s16 q12, d16, d1
|
||||
vld1.16 {d18, d19}, [r2, :128]!
|
||||
vmlal.s16 q13, d17, d1
|
||||
vmlal.s16 q14, d18, d1
|
||||
vmlal.s16 q15, d19, d1
|
||||
|
||||
vld1.16 {d4, d5}, [r2, :128]!
|
||||
vmlal.s16 q6, d4, d2
|
||||
vld1.16 {d6, d7}, [r2, :128]!
|
||||
vmlal.s16 q7, d5, d2
|
||||
vmlal.s16 q8, d6, d2
|
||||
vmlal.s16 q9, d7, d2
|
||||
vld1.16 {d16, d17}, [r2, :128]!
|
||||
vmlal.s16 q12, d16, d2
|
||||
vld1.16 {d18, d19}, [r2, :128]!
|
||||
vmlal.s16 q13, d17, d2
|
||||
vmlal.s16 q14, d18, d2
|
||||
vmlal.s16 q15, d19, d2
|
||||
|
||||
vld1.16 {d4, d5}, [r2, :128]!
|
||||
vmlal.s16 q6, d4, d3
|
||||
vld1.16 {d6, d7}, [r2, :128]!
|
||||
vmlal.s16 q7, d5, d3
|
||||
vmlal.s16 q8, d6, d3
|
||||
vmlal.s16 q9, d7, d3
|
||||
vld1.16 {d16, d17}, [r2, :128]!
|
||||
vmlal.s16 q12, d16, d3
|
||||
vld1.16 {d18, d19}, [r2, :128]!
|
||||
vmlal.s16 q13, d17, d3
|
||||
vmlal.s16 q14, d18, d3
|
||||
vmlal.s16 q15, d19, d3
|
||||
|
||||
vpadd.s32 d0, d12, d13 /* TODO: can be eliminated */
|
||||
vpadd.s32 d1, d14, d15 /* TODO: can be eliminated */
|
||||
vpadd.s32 d2, d16, d17 /* TODO: can be eliminated */
|
||||
vpadd.s32 d3, d18, d19 /* TODO: can be eliminated */
|
||||
vpadd.s32 d0, d24, d25 /* TODO: can be eliminated */
|
||||
vpadd.s32 d1, d26, d27 /* TODO: can be eliminated */
|
||||
vpadd.s32 d2, d28, d29 /* TODO: can be eliminated */
|
||||
vpadd.s32 d3, d30, d31 /* TODO: can be eliminated */
|
||||
|
||||
vst1.32 {d0, d1, d2, d3}, [r1, :128]
|
||||
|
||||
|
||||
+5
-5
@@ -869,7 +869,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
|
||||
|
||||
binkb_init_bundles(c);
|
||||
ref_start = frame->data[plane_idx];
|
||||
ref_end = frame->data[plane_idx] + (bh * frame->linesize[plane_idx] + bw) * 8;
|
||||
ref_end = frame->data[plane_idx] + ((bh - 1) * frame->linesize[plane_idx] + bw - 1) * 8;
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
coordmap[i] = (i & 7) + (i >> 3) * stride;
|
||||
@@ -925,7 +925,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
|
||||
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
|
||||
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
|
||||
ref = dst + xoff + yoff * stride;
|
||||
if (ref < ref_start || ref + 8*stride > ref_end) {
|
||||
if (ref < ref_start || ref > ref_end) {
|
||||
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
|
||||
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
|
||||
c->put_pixels_tab(dst, ref, stride, 8);
|
||||
@@ -941,7 +941,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
|
||||
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
|
||||
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
|
||||
ref = dst + xoff + yoff * stride;
|
||||
if (ref < ref_start || ref + 8 * stride > ref_end) {
|
||||
if (ref < ref_start || ref > ref_end) {
|
||||
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
|
||||
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
|
||||
c->put_pixels_tab(dst, ref, stride, 8);
|
||||
@@ -973,7 +973,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
|
||||
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
|
||||
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
|
||||
ref = dst + xoff + yoff * stride;
|
||||
if (ref < ref_start || ref + 8 * stride > ref_end) {
|
||||
if (ref < ref_start || ref > ref_end) {
|
||||
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
|
||||
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
|
||||
c->put_pixels_tab(dst, ref, stride, 8);
|
||||
@@ -1086,7 +1086,7 @@ static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
|
||||
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
|
||||
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
|
||||
// 16x16 block type on odd line means part of the already decoded block, so skip it
|
||||
if ((by & 1) && blk == SCALED_BLOCK) {
|
||||
if (((by & 1) || (bx & 1)) && blk == SCALED_BLOCK) {
|
||||
bx++;
|
||||
dst += 8;
|
||||
prev += 8;
|
||||
|
||||
@@ -239,7 +239,7 @@ static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
|
||||
for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
|
||||
memcpy(out + FFMAX(0, hinc) + stride * y,
|
||||
in + FFMAX(0, hinc) - hinc + (y - vinc) * stride,
|
||||
FFMIN(stride + hinc, stride));
|
||||
FFABS(stride) - FFABS(hinc));
|
||||
|
||||
if (vinc > 0)
|
||||
cdg_fill_wrapper(0, 0, out,
|
||||
|
||||
+8
-3
@@ -215,7 +215,7 @@ static uint8_t prob_dst_x_bit(int c)
|
||||
return (ff_reverse[c & 127] >> 1) + 1;
|
||||
}
|
||||
|
||||
static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets)
|
||||
static int build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets)
|
||||
{
|
||||
int i, j, k, l;
|
||||
|
||||
@@ -226,14 +226,17 @@ static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *
|
||||
int total = av_clip(length - j * 8, 0, 8);
|
||||
|
||||
for (k = 0; k < 256; k++) {
|
||||
int v = 0;
|
||||
int64_t v = 0;
|
||||
|
||||
for (l = 0; l < total; l++)
|
||||
v += (((k >> l) & 1) * 2 - 1) * fsets->coeff[i][j * 8 + l];
|
||||
if ((int16_t)v != v)
|
||||
return AVERROR_INVALIDDATA;
|
||||
table[i][j][k] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
@@ -329,7 +332,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_INVALIDDATA;
|
||||
ac_init(ac, gb);
|
||||
|
||||
build_filter(s->filter, &s->fsets);
|
||||
ret = build_filter(s->filter, &s->fsets);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
memset(s->status, 0xAA, sizeof(s->status));
|
||||
memset(dsd, 0, frame->nb_samples * 4 * channels);
|
||||
|
||||
@@ -139,9 +139,11 @@ static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
|
||||
// spx_noise_blend and spx_signal_blend are both FP.23
|
||||
nscale *= 1.0 / (1<<23);
|
||||
sscale *= 1.0 / (1<<23);
|
||||
if (nscale < -1.0)
|
||||
nscale = -1.0;
|
||||
#endif
|
||||
for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
|
||||
float noise = nscale * (int32_t)av_lfg_get(&s->dith_state);
|
||||
UINTFLOAT noise = (INTFLOAT)(nscale * (int32_t)av_lfg_get(&s->dith_state));
|
||||
s->transform_coeffs[ch][bin] *= sscale;
|
||||
s->transform_coeffs[ch][bin++] += noise;
|
||||
}
|
||||
|
||||
+11
-3
@@ -61,7 +61,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb)
|
||||
static int tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb)
|
||||
{
|
||||
uint8_t *perm = s->scantable.permutated;
|
||||
int i, j, value;
|
||||
@@ -69,6 +69,8 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb
|
||||
for (i = 1; i < 64;) {
|
||||
switch (show_bits(gb, 3)) {
|
||||
case 4:
|
||||
if (i >= 63)
|
||||
return AVERROR_INVALIDDATA;
|
||||
block[perm[i++]] = 0;
|
||||
case 0:
|
||||
block[perm[i++]] = 0;
|
||||
@@ -78,6 +80,8 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb
|
||||
case 1:
|
||||
skip_bits(gb, 2);
|
||||
value = get_bits(gb, 6);
|
||||
if (value > 64 - i)
|
||||
return AVERROR_INVALIDDATA;
|
||||
for (j = 0; j < value; j++)
|
||||
block[perm[i++]] = 0;
|
||||
break;
|
||||
@@ -105,6 +109,7 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb
|
||||
}
|
||||
}
|
||||
block[0] += 128 << 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], AVFrame *frame,
|
||||
@@ -164,8 +169,11 @@ static int tgq_decode_mb(TgqContext *s, AVFrame *frame, int mb_y, int mb_x)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
tgq_decode_block(s, s->block[i], &gb);
|
||||
for (i = 0; i < 6; i++) {
|
||||
int ret = tgq_decode_block(s, s->block[i], &gb);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);
|
||||
bytestream2_skip(&s->gb, mode);
|
||||
} else {
|
||||
|
||||
@@ -88,11 +88,6 @@ static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth,
|
||||
unsigned i, j;
|
||||
CodeBook cb = { 0 };
|
||||
|
||||
if (size >= INT_MAX / 34 || get_bits_left(gb) < size * 34)
|
||||
return cb;
|
||||
|
||||
if (size >= INT_MAX / sizeof(MacroBlock))
|
||||
return cb;
|
||||
cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1);
|
||||
if (!cb.blocks)
|
||||
return cb;
|
||||
@@ -226,7 +221,7 @@ static int escape124_decode_frame(AVCodecContext *avctx,
|
||||
// represent a lower bound of the space needed for skipped superblocks. Non
|
||||
// skipped SBs need more space.
|
||||
if (get_bits_left(&gb) < 64 + s->num_superblocks * 23LL / 4320)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
frame_flags = get_bits_long(&gb, 32);
|
||||
frame_size = get_bits_long(&gb, 32);
|
||||
@@ -277,9 +272,14 @@ static int escape124_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
av_freep(&s->codebooks[i].blocks);
|
||||
if (cb_size >= INT_MAX / 34 || get_bits_left(&gb) < (int)cb_size * 34)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (cb_size >= INT_MAX / sizeof(MacroBlock))
|
||||
return AVERROR_INVALIDDATA;
|
||||
s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size);
|
||||
if (!s->codebooks[i].blocks)
|
||||
return -1;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-4
@@ -1240,7 +1240,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
|
||||
td->ysize = FFMIN(s->tile_attr.ySize, s->ydelta - tile_y * s->tile_attr.ySize);
|
||||
td->xsize = FFMIN(s->tile_attr.xSize, s->xdelta - tile_x * s->tile_attr.xSize);
|
||||
|
||||
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX)
|
||||
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
|
||||
av_image_check_size2(td->xsize, td->ysize, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
|
||||
@@ -1264,7 +1265,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
|
||||
td->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */
|
||||
td->xsize = s->xdelta;
|
||||
|
||||
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX)
|
||||
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
|
||||
av_image_check_size2(td->xsize, td->ysize, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
|
||||
@@ -1945,9 +1947,12 @@ static int decode_header(EXRContext *s, AVFrame *frame)
|
||||
"preview", 16)) >= 0) {
|
||||
uint32_t pw = bytestream2_get_le32(gb);
|
||||
uint32_t ph = bytestream2_get_le32(gb);
|
||||
int64_t psize = 4LL * pw * ph;
|
||||
uint64_t psize = pw * ph;
|
||||
if (psize > INT64_MAX / 4)
|
||||
return AVERROR_INVALIDDATA;
|
||||
psize *= 4;
|
||||
|
||||
if (psize >= bytestream2_get_bytes_left(gb))
|
||||
if ((int64_t)psize >= bytestream2_get_bytes_left(gb))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
bytestream2_skip(gb, psize);
|
||||
|
||||
+48
-26
@@ -166,24 +166,34 @@ static int decode_slice_header(FFV1Context *f, FFV1Context *fs)
|
||||
RangeCoder *c = &fs->c;
|
||||
uint8_t state[CONTEXT_SIZE];
|
||||
unsigned ps, i, context_count;
|
||||
int sx, sy, sw, sh;
|
||||
|
||||
memset(state, 128, sizeof(state));
|
||||
sx = get_symbol(c, state, 0);
|
||||
sy = get_symbol(c, state, 0);
|
||||
sw = get_symbol(c, state, 0) + 1U;
|
||||
sh = get_symbol(c, state, 0) + 1U;
|
||||
|
||||
av_assert0(f->version > 2);
|
||||
|
||||
fs->slice_x = get_symbol(c, state, 0) * f->width ;
|
||||
fs->slice_y = get_symbol(c, state, 0) * f->height;
|
||||
fs->slice_width = (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x;
|
||||
fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
|
||||
|
||||
fs->slice_x /= f->num_h_slices;
|
||||
fs->slice_y /= f->num_v_slices;
|
||||
fs->slice_width = fs->slice_width /f->num_h_slices - fs->slice_x;
|
||||
fs->slice_height = fs->slice_height/f->num_v_slices - fs->slice_y;
|
||||
if ((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > f->height)
|
||||
return -1;
|
||||
if ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width
|
||||
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
|
||||
return -1;
|
||||
if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
fs->slice_x = sx * (int64_t)f->width / f->num_h_slices;
|
||||
fs->slice_y = sy * (int64_t)f->height / f->num_v_slices;
|
||||
fs->slice_width = (sx + sw) * (int64_t)f->width / f->num_h_slices - fs->slice_x;
|
||||
fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - fs->slice_y;
|
||||
|
||||
av_assert0((unsigned)fs->slice_width <= f->width &&
|
||||
(unsigned)fs->slice_height <= f->height);
|
||||
av_assert0 ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width <= f->width
|
||||
&& (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height);
|
||||
|
||||
if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for (i = 0; i < f->plane_count; i++) {
|
||||
PlaneContext * const p = &fs->plane[i];
|
||||
@@ -298,8 +308,11 @@ static int decode_slice(AVCodecContext *c, void *arg)
|
||||
}
|
||||
if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0)
|
||||
return ret;
|
||||
if (f->cur->key_frame || fs->slice_reset_contexts)
|
||||
if (f->cur->key_frame || fs->slice_reset_contexts) {
|
||||
ff_ffv1_clear_slice_state(f, fs);
|
||||
} else if (fs->slice_damaged) {
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
width = fs->slice_width;
|
||||
height = fs->slice_height;
|
||||
@@ -462,6 +475,11 @@ static int read_extra_header(FFV1Context *f)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (f->num_h_slices > MAX_SLICES / f->num_v_slices) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "slice count unsupported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
f->quant_table_count = get_symbol(c, state, 0);
|
||||
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES || !f->quant_table_count) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "quant table count %d is invalid\n", f->quant_table_count);
|
||||
@@ -764,21 +782,25 @@ static int read_header(FFV1Context *f)
|
||||
fs->slice_damaged = 0;
|
||||
|
||||
if (f->version == 2) {
|
||||
fs->slice_x = get_symbol(c, state, 0) * f->width ;
|
||||
fs->slice_y = get_symbol(c, state, 0) * f->height;
|
||||
fs->slice_width = (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x;
|
||||
fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
|
||||
int sx = get_symbol(c, state, 0);
|
||||
int sy = get_symbol(c, state, 0);
|
||||
int sw = get_symbol(c, state, 0) + 1U;
|
||||
int sh = get_symbol(c, state, 0) + 1U;
|
||||
|
||||
fs->slice_x /= f->num_h_slices;
|
||||
fs->slice_y /= f->num_v_slices;
|
||||
fs->slice_width = fs->slice_width / f->num_h_slices - fs->slice_x;
|
||||
fs->slice_height = fs->slice_height / f->num_v_slices - fs->slice_y;
|
||||
if ((unsigned)fs->slice_width > f->width ||
|
||||
(unsigned)fs->slice_height > f->height)
|
||||
if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width
|
||||
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
|
||||
if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
fs->slice_x = sx * (int64_t)f->width / f->num_h_slices;
|
||||
fs->slice_y = sy * (int64_t)f->height / f->num_v_slices;
|
||||
fs->slice_width = (sx + sw) * (int64_t)f->width / f->num_h_slices - fs->slice_x;
|
||||
fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - fs->slice_y;
|
||||
|
||||
av_assert0((unsigned)fs->slice_width <= f->width &&
|
||||
(unsigned)fs->slice_height <= f->height);
|
||||
av_assert0 ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width <= f->width
|
||||
&& (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height);
|
||||
}
|
||||
|
||||
for (i = 0; i < f->plane_count; i++) {
|
||||
|
||||
@@ -93,11 +93,11 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
|
||||
run_count--;
|
||||
}
|
||||
} else {
|
||||
while (run_count > 1 && w-x > 1) {
|
||||
sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
|
||||
x++;
|
||||
run_count--;
|
||||
}
|
||||
while (run_count > 1 && w-x > 1) {
|
||||
sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
|
||||
x++;
|
||||
run_count--;
|
||||
}
|
||||
}
|
||||
run_count--;
|
||||
if (run_count < 0) {
|
||||
|
||||
+15
-6
@@ -401,20 +401,17 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
PutByteContext *pb = &s->pb;
|
||||
AVFrame *frame = data;
|
||||
int ret, y, x;
|
||||
int key_frame;
|
||||
|
||||
if (avpkt->size < 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
bytestream2_init(gb, avpkt->data, avpkt->size);
|
||||
bytestream2_skip(gb, 2);
|
||||
|
||||
frame->key_frame = !!bytestream2_get_le16(gb);
|
||||
frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
||||
key_frame = !!bytestream2_get_le16(gb);
|
||||
|
||||
if (frame->key_frame) {
|
||||
if (key_frame) {
|
||||
const uint8_t *src;
|
||||
unsigned type, size;
|
||||
uint8_t *dst;
|
||||
@@ -434,6 +431,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
frame->key_frame = 1;
|
||||
frame->pict_type = AV_PICTURE_TYPE_I;
|
||||
|
||||
src = s->buffer;
|
||||
dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
|
||||
for (y = 0; y < avctx->height; y++) {
|
||||
@@ -514,6 +517,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
dst = &rect[block_h * s->stride];
|
||||
}
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
frame->key_frame = 0;
|
||||
frame->pict_type = AV_PICTURE_TYPE_P;
|
||||
|
||||
ssrc = s->buffer;
|
||||
ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
|
||||
for (y = 0; y < avctx->height; y++) {
|
||||
|
||||
@@ -545,6 +545,8 @@ retry:
|
||||
avctx->has_b_frames = !s->low_delay;
|
||||
|
||||
if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
|
||||
if (s->pict_type != AV_PICTURE_TYPE_B && s->mb_num/2 > get_bits_left(&s->gb))
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (ff_mpeg4_workaround_bugs(avctx) == 1)
|
||||
goto retry;
|
||||
if (s->studio_profile != (s->idsp.idct == NULL))
|
||||
|
||||
@@ -654,6 +654,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
|
||||
avpriv_request_sample(avctx, "data partitioning");
|
||||
break;
|
||||
case H264_NAL_SEI:
|
||||
if (h->setup_finished) {
|
||||
avpriv_request_sample(avctx, "Late SEI");
|
||||
break;
|
||||
}
|
||||
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
|
||||
h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1;
|
||||
if (avctx->debug & FF_DEBUG_GREEN_MD)
|
||||
|
||||
@@ -145,11 +145,22 @@ int i, j;
|
||||
|
||||
if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) {
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j+=8)
|
||||
for (j = 0; j < width - 7; j+=8)
|
||||
AV_COPY64U(dst+j, src+j);
|
||||
dst += stride_dst;
|
||||
src += stride_src;
|
||||
}
|
||||
if (width&7) {
|
||||
dst += ((width>>3)<<3) - stride_dst * height;
|
||||
src += ((width>>3)<<3) - stride_src * height;
|
||||
width &= 7;
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j++)
|
||||
dst[j] = src[j];
|
||||
dst += stride_dst;
|
||||
src += stride_src;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j+=16)
|
||||
|
||||
@@ -3338,7 +3338,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
|
||||
}
|
||||
} else {
|
||||
/* verify the SEI checksum */
|
||||
if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded &&
|
||||
if (avctx->err_recognition & AV_EF_CRCCHECK && s->ref && s->is_decoded &&
|
||||
s->sei.picture_hash.is_md5) {
|
||||
ret = verify_md5(s, s->ref->frame);
|
||||
if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) {
|
||||
|
||||
@@ -313,7 +313,7 @@ static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
|
||||
offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++)
|
||||
dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
|
||||
dst[x] = av_clip_pixel(src[x] + offset_table[(src[x] >> shift) & 31]);
|
||||
dst += stride_dst;
|
||||
src += stride_src;
|
||||
}
|
||||
|
||||
@@ -478,19 +478,19 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
|
||||
for (i = 0; i < s->height; i++) {
|
||||
switch(s->xfrm) {
|
||||
case 1:
|
||||
for (x = off; x < w; x += 3) {
|
||||
for (x = off; x + 2 < w; x += 3) {
|
||||
src[x ] += src[x+1] + 128;
|
||||
src[x+2] += src[x+1] + 128;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (x = off; x < w; x += 3) {
|
||||
for (x = off; x + 2 < w; x += 3) {
|
||||
src[x ] += src[x+1] + 128;
|
||||
src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (x = off; x < w; x += 3) {
|
||||
for (x = off; x + 2 < w; x += 3) {
|
||||
int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
|
||||
src[x+0] = src[x+2] + g + 128;
|
||||
src[x+2] = src[x+1] + g + 128;
|
||||
@@ -498,7 +498,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (x = off; x < w; x += 3) {
|
||||
for (x = off; x + 2 < w; x += 3) {
|
||||
int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
|
||||
int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
|
||||
int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
|
||||
|
||||
@@ -408,6 +408,9 @@ output_zeros:
|
||||
if (zero_run) {
|
||||
zero_run = 0;
|
||||
i += esc_count;
|
||||
if (i > end - dst ||
|
||||
i >= src_end - src)
|
||||
return AVERROR_INVALIDDATA;
|
||||
memcpy(dst, src, i);
|
||||
dst += i;
|
||||
l->zeros_rem = lag_calc_zero_run(src[i]);
|
||||
|
||||
@@ -205,7 +205,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
ret = cae->api->encoder_encode(cae->encoder, &pic, &cae->packet);
|
||||
|
||||
if (ret) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Encoding error occured.\n");
|
||||
av_log(avctx, AV_LOG_ERROR, "Encoding error occurred.\n");
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,12 +202,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
bytestream2_skip(gb, 8);
|
||||
uncompressed = bytestream2_get_le32(gb);
|
||||
|
||||
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
if (uncompressed) {
|
||||
ret = decode_mvdv(s, avctx, frame);
|
||||
} else {
|
||||
if (!uncompressed) {
|
||||
av_fast_padded_malloc(&s->uncompressed, &s->uncompressed_size, 16LL * (avpkt->size - 12));
|
||||
if (!s->uncompressed)
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -216,9 +211,13 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
bytestream2_init(gb, s->uncompressed, ret);
|
||||
ret = decode_mvdv(s, avctx, frame);
|
||||
}
|
||||
|
||||
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
ret = decode_mvdv(s, avctx, frame);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
key = ret;
|
||||
|
||||
@@ -1082,6 +1082,10 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (s->bayer) {
|
||||
if (s->rct || s->pegasus_rct)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
||||
s->restart_count = s->restart_interval;
|
||||
@@ -1198,6 +1202,8 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
|
||||
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
|
||||
}
|
||||
} else if (s->bayer) {
|
||||
if (s->bits <= 8)
|
||||
return AVERROR_PATCHWELCOME;
|
||||
if (nb_components == 1) {
|
||||
/* Leave decoding to the TIFF/DNG decoder (see comment in ff_mjpeg_decode_sof) */
|
||||
for (mb_x = 0; mb_x < width; mb_x++)
|
||||
@@ -1932,6 +1938,8 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
|
||||
}
|
||||
|
||||
len -= 9;
|
||||
if (s->bayer)
|
||||
goto out;
|
||||
if (s->got_picture)
|
||||
if (rgb != s->rgb || pegasus_rct != s->pegasus_rct) {
|
||||
av_log(s->avctx, AV_LOG_WARNING, "Mismatching LJIF tag\n");
|
||||
|
||||
@@ -247,7 +247,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
|
||||
default: av_assert0(0);
|
||||
}
|
||||
|
||||
put_bits(pb, 16, 17);
|
||||
put_bits(pb, 16, 8 + 3 * components);
|
||||
if (lossless && ( avctx->pix_fmt == AV_PIX_FMT_BGR0
|
||||
|| avctx->pix_fmt == AV_PIX_FMT_BGRA
|
||||
|| avctx->pix_fmt == AV_PIX_FMT_BGR24))
|
||||
|
||||
+1
-1
@@ -521,7 +521,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
|
||||
|
||||
/* This should happen for TrueHD streams with >6 channels and MLP's noise
|
||||
* type. It is not yet known if this is allowed. */
|
||||
if (max_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) {
|
||||
if (max_matrix_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) {
|
||||
avpriv_request_sample(m->avctx,
|
||||
"%d channels (more than the "
|
||||
"maximum supported by the decoder)",
|
||||
|
||||
@@ -329,7 +329,7 @@ static av_cold int mobiclip_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_qtables(AVCodecContext *avctx, int quantizer)
|
||||
static int setup_qtables(AVCodecContext *avctx, int64_t quantizer)
|
||||
{
|
||||
MobiClipContext *s = avctx->priv_data;
|
||||
int qx, qy;
|
||||
@@ -1256,7 +1256,7 @@ static int mobiclip_decode(AVCodecContext *avctx, void *data,
|
||||
frame->key_frame = 0;
|
||||
s->dct_tab_idx = 0;
|
||||
|
||||
ret = setup_qtables(avctx, s->quantizer + get_se_golomb(gb));
|
||||
ret = setup_qtables(avctx, s->quantizer + (int64_t)get_se_golomb(gb));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ static YuvPixel mp_get_yuv_from_rgb(MotionPixelsContext *mp, int x, int y)
|
||||
int color;
|
||||
|
||||
color = *(uint16_t *)&mp->frame->data[0][y * mp->frame->linesize[0] + x * 2];
|
||||
return mp_rgb_yuv_table[color];
|
||||
return mp_rgb_yuv_table[color & 0x7FFF];
|
||||
}
|
||||
|
||||
static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const YuvPixel *p)
|
||||
|
||||
@@ -2999,6 +2999,10 @@ static int ipu_decode_frame(AVCodecContext *avctx, void *data,
|
||||
AVFrame * const frame = data;
|
||||
int ret;
|
||||
|
||||
// Check for minimal intra MB size (considering mb header, luma & chroma dc VLC, ac EOB VLC)
|
||||
if (avpkt->size*8LL < (avctx->width+15)/16 * ((avctx->height+15)/16) * (2 + 3*4 + 2*2 + 2*6))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
ret = ff_get_buffer(avctx, frame, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -372,7 +372,7 @@ static int handle_crc(MPADecodeContext *s, int sec_len)
|
||||
crc_val = av_crc(crc_tab, crc_val, &buf[6], sec_byte_len);
|
||||
|
||||
AV_WB32(tmp_buf,
|
||||
((buf[6 + sec_byte_len] & (0xFF00 >> sec_rem_bits)) << 24) +
|
||||
((buf[6 + sec_byte_len] & (0xFF00U >> sec_rem_bits)) << 24) +
|
||||
((s->crc << 16) >> sec_rem_bits));
|
||||
|
||||
crc_val = av_crc(crc_tab, crc_val, tmp_buf, 3);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/thread.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bytestream.h"
|
||||
@@ -476,6 +477,9 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
width, height);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (av_image_check_size2(width, height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (quality < 1 || quality > 100) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid quality setting %d\n", quality);
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
+3
-2
@@ -1025,8 +1025,9 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
|
||||
|
||||
av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
|
||||
|
||||
//CQ mode shall discard avg bitrate & honor max bitrate;
|
||||
// CQ mode shall discard avg bitrate/vbv buffer size and honor only max bitrate
|
||||
ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
|
||||
ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
|
||||
ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
|
||||
}
|
||||
}
|
||||
@@ -1925,7 +1926,7 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
|
||||
pkt->pts = params->outputTimeStamp;
|
||||
pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list);
|
||||
|
||||
pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1);
|
||||
pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1) * FFMAX(avctx->time_base.num, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -245,8 +245,6 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
run = bytestream2_get_le16(&s->g);
|
||||
val = bytestream2_get_byte(&s->g);
|
||||
}
|
||||
if (!bytestream2_get_bytes_left(&s->g))
|
||||
break;
|
||||
|
||||
if (bits_per_plane == 8) {
|
||||
picmemset_8bpp(s, frame, val, run, &x, &y);
|
||||
|
||||
+1
-1
@@ -322,7 +322,7 @@ void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
|
||||
static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
|
||||
{ \
|
||||
int i; \
|
||||
for (i = 0; i < size; i += 3 + alpha) { \
|
||||
for (i = 0; i < size - 2; i += 3 + alpha) { \
|
||||
int g = dst [i + 1]; \
|
||||
dst[i + 0] += g; \
|
||||
dst[i + 2] += g; \
|
||||
|
||||
+35
-11
@@ -145,6 +145,12 @@ typedef struct FrameThreadContext {
|
||||
* Set for the first N packets, where N is the number of threads.
|
||||
* While it is set, ff_thread_en/decode_frame won't return any results.
|
||||
*/
|
||||
|
||||
/* hwaccel state is temporarily stored here in order to transfer its ownership
|
||||
* to the next decoding thread without the need for extra synchronization */
|
||||
const AVHWAccel *stash_hwaccel;
|
||||
void *stash_hwaccel_context;
|
||||
void *stash_hwaccel_priv;
|
||||
} FrameThreadContext;
|
||||
|
||||
#if FF_API_THREAD_SAFE_CALLBACKS
|
||||
@@ -229,9 +235,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
ff_thread_finish_setup(avctx);
|
||||
|
||||
if (p->hwaccel_serializing) {
|
||||
/* wipe hwaccel state to avoid stale pointers lying around;
|
||||
* the state was transferred to FrameThreadContext in
|
||||
* ff_thread_finish_setup(), so nothing is leaked */
|
||||
avctx->hwaccel = NULL;
|
||||
avctx->hwaccel_context = NULL;
|
||||
avctx->internal->hwaccel_priv_data = NULL;
|
||||
|
||||
p->hwaccel_serializing = 0;
|
||||
pthread_mutex_unlock(&p->parent->hwaccel_mutex);
|
||||
}
|
||||
av_assert0(!avctx->hwaccel);
|
||||
|
||||
if (p->async_serializing) {
|
||||
p->async_serializing = 0;
|
||||
@@ -293,14 +307,10 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
|
||||
dst->color_range = src->color_range;
|
||||
dst->chroma_sample_location = src->chroma_sample_location;
|
||||
|
||||
dst->hwaccel = src->hwaccel;
|
||||
dst->hwaccel_context = src->hwaccel_context;
|
||||
|
||||
dst->channels = src->channels;
|
||||
dst->sample_rate = src->sample_rate;
|
||||
dst->sample_fmt = src->sample_fmt;
|
||||
dst->channel_layout = src->channel_layout;
|
||||
dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
|
||||
|
||||
if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
|
||||
(dst->hw_frames_ctx && dst->hw_frames_ctx->data != src->hw_frames_ctx->data)) {
|
||||
@@ -446,6 +456,12 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx,
|
||||
}
|
||||
}
|
||||
|
||||
/* transfer the stashed hwaccel state, if any */
|
||||
av_assert0(!p->avctx->hwaccel);
|
||||
FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel);
|
||||
FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context);
|
||||
FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
|
||||
|
||||
av_packet_unref(p->avpkt);
|
||||
ret = av_packet_ref(p->avpkt, avpkt);
|
||||
if (ret < 0) {
|
||||
@@ -649,6 +665,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
|
||||
async_lock(p->parent);
|
||||
}
|
||||
|
||||
/* save hwaccel state for passing to the next thread;
|
||||
* this is done here so that this worker thread can wipe its own hwaccel
|
||||
* state after decoding, without requiring synchronization */
|
||||
av_assert0(!p->parent->stash_hwaccel);
|
||||
p->parent->stash_hwaccel = avctx->hwaccel;
|
||||
p->parent->stash_hwaccel_context = avctx->hwaccel_context;
|
||||
p->parent->stash_hwaccel_priv = avctx->internal->hwaccel_priv_data;
|
||||
|
||||
pthread_mutex_lock(&p->progress_mutex);
|
||||
if(atomic_load(&p->state) == STATE_SETUP_FINISHED){
|
||||
av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n");
|
||||
@@ -743,13 +767,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
|
||||
|
||||
park_frame_worker_threads(fctx, thread_count);
|
||||
|
||||
if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
|
||||
fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
|
||||
if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Failed to update user thread.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
|
||||
if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");
|
||||
@@ -803,6 +820,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
|
||||
av_freep(&fctx->threads);
|
||||
free_pthread(fctx, thread_ctx_offsets);
|
||||
|
||||
/* if we have stashed hwaccel state, move it to the user-facing context,
|
||||
* so it will be freed in avcodec_close() */
|
||||
av_assert0(!avctx->hwaccel);
|
||||
FFSWAP(const AVHWAccel*, avctx->hwaccel, fctx->stash_hwaccel);
|
||||
FFSWAP(void*, avctx->hwaccel_context, fctx->stash_hwaccel_context);
|
||||
FFSWAP(void*, avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
|
||||
|
||||
av_freep(&avctx->internal->thread_ctx);
|
||||
|
||||
if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
|
||||
|
||||
+1
-1
@@ -369,7 +369,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
bytestream2_skip(&gbc, 18);
|
||||
colors = bytestream2_get_be16(&gbc);
|
||||
|
||||
if (colors < 0 || colors > 256) {
|
||||
if (colors < 0 || colors > 255) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Error color count - %i(0x%X)\n", colors, colors);
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
@@ -198,7 +198,7 @@ static void OPNAME ## qpel8_mc01_c(uint8_t *dst, const uint8_t *src, \
|
||||
uint8_t full[16 * 9]; \
|
||||
uint8_t half[64]; \
|
||||
\
|
||||
copy_block9(full, src, 16, stride, 9); \
|
||||
copy_block8(full, src, 16, stride, 9); \
|
||||
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
|
||||
OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \
|
||||
} \
|
||||
@@ -208,7 +208,7 @@ static void OPNAME ## qpel8_mc02_c(uint8_t *dst, const uint8_t *src, \
|
||||
{ \
|
||||
uint8_t full[16 * 9]; \
|
||||
\
|
||||
copy_block9(full, src, 16, stride, 9); \
|
||||
copy_block8(full, src, 16, stride, 9); \
|
||||
OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
|
||||
} \
|
||||
\
|
||||
@@ -218,7 +218,7 @@ static void OPNAME ## qpel8_mc03_c(uint8_t *dst, const uint8_t *src, \
|
||||
uint8_t full[16 * 9]; \
|
||||
uint8_t half[64]; \
|
||||
\
|
||||
copy_block9(full, src, 16, stride, 9); \
|
||||
copy_block8(full, src, 16, stride, 9); \
|
||||
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
|
||||
OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \
|
||||
} \
|
||||
@@ -458,7 +458,7 @@ static void OPNAME ## qpel16_mc01_c(uint8_t *dst, const uint8_t *src, \
|
||||
uint8_t full[24 * 17]; \
|
||||
uint8_t half[256]; \
|
||||
\
|
||||
copy_block17(full, src, 24, stride, 17); \
|
||||
copy_block16(full, src, 24, stride, 17); \
|
||||
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
|
||||
OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \
|
||||
} \
|
||||
@@ -468,7 +468,7 @@ static void OPNAME ## qpel16_mc02_c(uint8_t *dst, const uint8_t *src, \
|
||||
{ \
|
||||
uint8_t full[24 * 17]; \
|
||||
\
|
||||
copy_block17(full, src, 24, stride, 17); \
|
||||
copy_block16(full, src, 24, stride, 17); \
|
||||
OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
|
||||
} \
|
||||
\
|
||||
@@ -478,7 +478,7 @@ static void OPNAME ## qpel16_mc03_c(uint8_t *dst, const uint8_t *src, \
|
||||
uint8_t full[24 * 17]; \
|
||||
uint8_t half[256]; \
|
||||
\
|
||||
copy_block17(full, src, 24, stride, 17); \
|
||||
copy_block16(full, src, 24, stride, 17); \
|
||||
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
|
||||
OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \
|
||||
} \
|
||||
|
||||
+15
-7
@@ -204,7 +204,7 @@ static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr,
|
||||
|
||||
// loop thru and compare pixels
|
||||
for (y = 0; y < bi->block_height; y++) {
|
||||
for (x = 0; x < bi->block_width; x++){
|
||||
for (x = 0; x < bi->block_width; x++) {
|
||||
// TODO: optimize
|
||||
min_r = FFMIN(R(block_ptr[x]), min_r);
|
||||
min_g = FFMIN(G(block_ptr[x]), min_g);
|
||||
@@ -276,7 +276,7 @@ static int leastsquares(uint16_t *block_ptr, BlockInfo *bi,
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < bi->block_height; i++) {
|
||||
for (j = 0; j < bi->block_width; j++){
|
||||
for (j = 0; j < bi->block_width; j++) {
|
||||
x = GET_CHAN(block_ptr[j], xchannel);
|
||||
y = GET_CHAN(block_ptr[j], ychannel);
|
||||
sumx += x;
|
||||
@@ -323,7 +323,7 @@ static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi,
|
||||
int max_err = 0;
|
||||
|
||||
for (i = 0; i < bi->block_height; i++) {
|
||||
for (j = 0; j < bi->block_width; j++){
|
||||
for (j = 0; j < bi->block_width; j++) {
|
||||
int x_inc, lin_y, lin_x;
|
||||
x = GET_CHAN(block_ptr[j], xchannel);
|
||||
y = GET_CHAN(block_ptr[j], ychannel);
|
||||
@@ -418,7 +418,9 @@ static void update_block_in_prev_frame(const uint16_t *src_pixels,
|
||||
uint16_t *dest_pixels,
|
||||
const BlockInfo *bi, int block_counter)
|
||||
{
|
||||
for (int y = 0; y < 4; y++) {
|
||||
const int y_size = FFMIN(4, bi->image_height - bi->row * 4);
|
||||
|
||||
for (int y = 0; y < y_size; y++) {
|
||||
memcpy(dest_pixels, src_pixels, 8);
|
||||
dest_pixels += bi->rowstride;
|
||||
src_pixels += bi->rowstride;
|
||||
@@ -728,14 +730,15 @@ post_skip :
|
||||
|
||||
if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK
|
||||
uint16_t *row_ptr;
|
||||
int rgb555;
|
||||
int y_size, rgb555;
|
||||
|
||||
block_offset = get_block_info(&bi, block_counter);
|
||||
|
||||
row_ptr = &src_pixels[block_offset];
|
||||
y_size = FFMIN(4, bi.image_height - bi.row * 4);
|
||||
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 4; x++){
|
||||
for (int y = 0; y < y_size; y++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
rgb555 = row_ptr[x] & ~0x8000;
|
||||
|
||||
put_bits(&s->pb, 16, rgb555);
|
||||
@@ -743,6 +746,11 @@ post_skip :
|
||||
row_ptr += bi.rowstride;
|
||||
}
|
||||
|
||||
for (int y = y_size; y < 4; y++) {
|
||||
for (int x = 0; x < 4; x++)
|
||||
put_bits(&s->pb, 16, 0);
|
||||
}
|
||||
|
||||
block_counter++;
|
||||
} else { // FOUR COLOR BLOCK
|
||||
block_counter += encode_four_color_block(min_color, max_color,
|
||||
|
||||
@@ -114,8 +114,8 @@ static void sbr_qmf_deint_neg_c(int *v, const int *src)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 32; i++) {
|
||||
v[ i] = ( src[63 - 2*i ] + 0x10) >> 5;
|
||||
v[63 - i] = (-src[63 - 2*i - 1] + 0x10) >> 5;
|
||||
v[ i] = (int)(0x10U + src[63 - 2*i ]) >> 5;
|
||||
v[63 - i] = (int)(0x10U - src[63 - 2*i - 1]) >> 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -459,6 +459,9 @@ static int decompress_p(AVCodecContext *avctx,
|
||||
int run, bx = x * 16 + sx1, by = y * 16 + sy1;
|
||||
uint32_t r, g, b, clr, ptype = 0;
|
||||
|
||||
if (bx >= avctx->width)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for (; by < y * 16 + sy2 && by < avctx->height;) {
|
||||
ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -1168,6 +1168,9 @@ static int decompress_p3(AVCodecContext *avctx,
|
||||
int run, bx = x * 16 + sx1, by = y * 16 + sy1;
|
||||
uint32_t clr, ptype = 0, r, g, b;
|
||||
|
||||
if (bx >= avctx->width)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for (; by < y * 16 + sy2 && by < avctx->height;) {
|
||||
ret = decode_value3(s, 5, &s->op_model3[ptype].cntsum,
|
||||
s->op_model3[ptype].freqs[0],
|
||||
|
||||
@@ -1544,10 +1544,10 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
|
||||
int level, orientation, x, y;
|
||||
|
||||
for(level=0; level<s->spatial_decomposition_count; level++){
|
||||
int64_t error=0;
|
||||
for(orientation=level ? 1 : 0; orientation<4; orientation++){
|
||||
SubBand *b= &p->band[level][orientation];
|
||||
IDWTELEM *ibuf= b->ibuf;
|
||||
int64_t error=0;
|
||||
|
||||
memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height);
|
||||
ibuf[b->width/2 + b->height/2*b->stride]= 256*16;
|
||||
@@ -1558,9 +1558,13 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
|
||||
error += d*d;
|
||||
}
|
||||
}
|
||||
|
||||
if (orientation == 2)
|
||||
error /= 2;
|
||||
b->qlog= (int)(QROOT * log2(352256.0/sqrt(error)) + 0.5);
|
||||
if (orientation != 1)
|
||||
error = 0;
|
||||
}
|
||||
p->band[level][1].qlog = p->band[level][2].qlog;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -498,7 +498,9 @@ static int speedhq_decode_frame(AVCodecContext *avctx,
|
||||
uint32_t second_field_offset;
|
||||
int ret;
|
||||
|
||||
if (buf_size < 4 || avctx->width < 8)
|
||||
if (buf_size < 4 || avctx->width < 8 || avctx->width % 8 != 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (buf_size < avctx->width*avctx->height / 64 / 4)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
quality = buf[0];
|
||||
|
||||
+17
-2
@@ -19,6 +19,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
@@ -75,6 +76,12 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (maplength > 768) {
|
||||
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
// This also checks depth to be valid
|
||||
switch (depth) {
|
||||
case 1:
|
||||
avctx->pix_fmt = maplength ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_MONOWHITE;
|
||||
@@ -96,15 +103,23 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
// This checks w and h to be valid in the sense that bytes of a padded bitmap are addressable with 32bit int
|
||||
ret = ff_set_dimensions(avctx, w, h);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
// ensured by ff_set_dimensions()
|
||||
av_assert0(w <= (INT32_MAX - 7) / depth);
|
||||
|
||||
/* scanlines are aligned on 16 bit boundaries */
|
||||
len = (depth * w + 7) >> 3;
|
||||
alen = len + (len & 1);
|
||||
|
||||
if (buf_end - buf < maplength + (len * h) * 3 / 256)
|
||||
// ensured by ff_set_dimensions()
|
||||
av_assert0(h <= INT32_MAX / (3 * len));
|
||||
|
||||
// maplength is limited to 768 and the right term is limited to INT32_MAX / 256 so the add needs no check
|
||||
if (buf_end - buf < (uint64_t)maplength + (len * h) * 3 / 256)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
|
||||
@@ -118,7 +133,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
||||
} else if (maplength) {
|
||||
unsigned int len = maplength / 3;
|
||||
|
||||
if (maplength % 3 || maplength > 768) {
|
||||
if (maplength % 3) {
|
||||
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
+24
-12
@@ -31,11 +31,13 @@ int main(void){
|
||||
#define width 256
|
||||
#define height 256
|
||||
int buffer[2][width*height];
|
||||
short obuffer[width*height];
|
||||
SnowContext s;
|
||||
int i;
|
||||
AVLFG prng;
|
||||
s.spatial_decomposition_count=6;
|
||||
s.spatial_decomposition_type=1;
|
||||
int ret = 0;
|
||||
|
||||
s.temp_dwt_buffer = av_mallocz_array(width, sizeof(DWTELEM));
|
||||
s.temp_idwt_buffer = av_mallocz_array(width, sizeof(IDWTELEM));
|
||||
@@ -49,24 +51,34 @@ int main(void){
|
||||
|
||||
printf("testing 5/3 DWT\n");
|
||||
for(i=0; i<width*height; i++)
|
||||
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
|
||||
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 19000 - 9000;
|
||||
|
||||
ff_spatial_dwt(buffer[0], s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
for(i=0; i<width*height; i++)
|
||||
obuffer[i] = buffer[0][i];
|
||||
ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
|
||||
for(i=0; i<width*height; i++)
|
||||
if(buffer[0][i]!= buffer[1][i]) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
|
||||
if(buffer[1][i]!= obuffer[i]) {
|
||||
printf("fsck: %4dx%4dx %12d %7d\n",i%width, i/width, buffer[1][i], obuffer[i]);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
printf("testing 9/7 DWT\n");
|
||||
s.spatial_decomposition_type=0;
|
||||
for(i=0; i<width*height; i++)
|
||||
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
|
||||
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 11000 - 5000;
|
||||
|
||||
ff_spatial_dwt(buffer[0], s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
for(i=0; i<width*height; i++)
|
||||
obuffer[i] = buffer[0][i];
|
||||
ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
|
||||
for(i=0; i<width*height; i++)
|
||||
if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
|
||||
if(FFABS(buffer[1][i] - obuffer[i])>20) {
|
||||
printf("fsck: %4dx%4d %12d %7d\n",i%width, i/width, buffer[1][i], obuffer[i]);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
{
|
||||
int level, orientation, x, y;
|
||||
@@ -81,18 +93,18 @@ int main(void){
|
||||
int w= width >> (s.spatial_decomposition_count-level);
|
||||
int h= height >> (s.spatial_decomposition_count-level);
|
||||
int stride= width << (s.spatial_decomposition_count-level);
|
||||
DWTELEM *buf= buffer[0];
|
||||
IDWTELEM *buf= obuffer;
|
||||
int64_t error=0;
|
||||
|
||||
if(orientation&1) buf+=w;
|
||||
if(orientation>1) buf+=stride>>1;
|
||||
|
||||
memset(buffer[0], 0, sizeof(int)*width*height);
|
||||
buf[w/2 + h/2*stride]= 256*256;
|
||||
ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
memset(obuffer, 0, sizeof(short)*width*height);
|
||||
buf[w/2 + h/2*stride]= 8*256;
|
||||
ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
|
||||
for(y=0; y<height; y++){
|
||||
for(x=0; x<width; x++){
|
||||
int64_t d= buffer[0][x + y*width];
|
||||
int64_t d= obuffer[x + y*width];
|
||||
error += d*d;
|
||||
if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d);
|
||||
}
|
||||
@@ -143,5 +155,5 @@ int main(void){
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -255,11 +255,11 @@ static void optimize_colors(const uint8_t *block, ptrdiff_t stride,
|
||||
|
||||
muv = minv = maxv = bp[0];
|
||||
for (y = 0; y < 4; y++) {
|
||||
for (x = 4; x < 4; x += 4) {
|
||||
for (x = 0; x < 4; x++) {
|
||||
muv += bp[x * 4 + y * stride];
|
||||
if (bp[x] < minv)
|
||||
if (bp[x * 4 + y * stride] < minv)
|
||||
minv = bp[x * 4 + y * stride];
|
||||
else if (bp[x] > maxv)
|
||||
else if (bp[x * 4 + y * stride] > maxv)
|
||||
maxv = bp[x * 4 + y * stride];
|
||||
}
|
||||
}
|
||||
|
||||
+10
-6
@@ -100,7 +100,6 @@ typedef struct TiffContext {
|
||||
int is_tiled;
|
||||
int tile_byte_counts_offset, tile_offsets_offset;
|
||||
int tile_width, tile_length;
|
||||
int tile_count;
|
||||
|
||||
int is_jpeg;
|
||||
|
||||
@@ -773,6 +772,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
|
||||
if (s->is_bayer) {
|
||||
av_assert0(width == (s->bpp * s->width + 7) >> 3);
|
||||
}
|
||||
av_assert0(!(s->is_bayer && is_yuv));
|
||||
if (p->format == AV_PIX_FMT_GRAY12) {
|
||||
av_fast_padded_malloc(&s->yuv_line, &s->yuv_line_size, width);
|
||||
if (s->yuv_line == NULL) {
|
||||
@@ -856,6 +856,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
|
||||
av_log(s->avctx, AV_LOG_ERROR, "More than one DNG JPEG strips unsupported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (!s->is_bayer)
|
||||
return AVERROR_PATCHWELCOME;
|
||||
if ((ret = dng_decode_jpeg(s->avctx, p, s->stripsize, 0, 0, s->width, s->height)) < 0)
|
||||
return ret;
|
||||
return 0;
|
||||
@@ -974,6 +976,9 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
|
||||
int pos_x = 0, pos_y = 0;
|
||||
int ret;
|
||||
|
||||
if (s->tile_width <= 0 || s->tile_length <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
has_width_leftover = (s->width % s->tile_width != 0);
|
||||
has_height_leftover = (s->height % s->tile_length != 0);
|
||||
|
||||
@@ -982,7 +987,7 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
|
||||
tile_count_y = (s->height + s->tile_length - 1) / s->tile_length;
|
||||
|
||||
/* Iterate over the number of tiles */
|
||||
for (tile_idx = 0; tile_idx < s->tile_count; tile_idx++) {
|
||||
for (tile_idx = 0; tile_idx < tile_count_x * tile_count_y; tile_idx++) {
|
||||
tile_x = tile_idx % tile_count_x;
|
||||
tile_y = tile_idx / tile_count_x;
|
||||
|
||||
@@ -1402,7 +1407,6 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
|
||||
break;
|
||||
case TIFF_TILE_OFFSETS:
|
||||
s->tile_offsets_offset = off;
|
||||
s->tile_count = count;
|
||||
s->is_tiled = 1;
|
||||
break;
|
||||
case TIFF_TILE_BYTE_COUNTS:
|
||||
@@ -1758,7 +1762,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
TiffContext *const s = avctx->priv_data;
|
||||
AVFrame *const p = data;
|
||||
ThreadFrame frame = { .f = data };
|
||||
unsigned off, last_off;
|
||||
unsigned off, last_off = 0;
|
||||
int le, ret, plane, planes;
|
||||
int i, j, entries, stride;
|
||||
unsigned soff, ssize;
|
||||
@@ -1823,7 +1827,6 @@ again:
|
||||
/** whether we should process this multi-page IFD's next page */
|
||||
retry_for_page = s->get_page && s->cur_page + 1 < s->get_page; // get_page is 1-indexed
|
||||
|
||||
last_off = off;
|
||||
if (retry_for_page) {
|
||||
// set offset to the next IFD
|
||||
off = ff_tget_long(&s->gb, le);
|
||||
@@ -1841,6 +1844,7 @@ again:
|
||||
avpriv_request_sample(s->avctx, "non increasing IFD offset");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
last_off = off;
|
||||
if (off >= UINT_MAX - 14 || avpkt->size < off + 14) {
|
||||
av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -1897,7 +1901,7 @@ again:
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
has_tile_bits = s->is_tiled || s->tile_byte_counts_offset || s->tile_offsets_offset || s->tile_width || s->tile_length || s->tile_count;
|
||||
has_tile_bits = s->is_tiled || s->tile_byte_counts_offset || s->tile_offsets_offset || s->tile_width || s->tile_length;
|
||||
has_strip_bits = s->strippos || s->strips || s->stripoff || s->rps || s->sot || s->sstype || s->stripsize || s->stripsizesoff;
|
||||
|
||||
if (has_tile_bits && has_strip_bits) {
|
||||
|
||||
+9
-2
@@ -371,8 +371,15 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
|
||||
case 3: {
|
||||
// shift samples for 24-bit sample format
|
||||
int32_t *samples = (int32_t *)frame->data[0];
|
||||
for (i = 0; i < framelen * s->channels; i++)
|
||||
*samples++ *= 256;
|
||||
int overflow = 0;
|
||||
|
||||
for (i = 0; i < framelen * s->channels; i++) {
|
||||
int scaled = *samples * 256U;
|
||||
overflow += (scaled >> 8 != *samples);
|
||||
*samples++ = scaled;
|
||||
}
|
||||
if (overflow)
|
||||
av_log(avctx, AV_LOG_WARNING, "%d overflows occurred on 24bit upscale\n", overflow);
|
||||
// reset decode buffer
|
||||
s->decode_buffer = NULL;
|
||||
break;
|
||||
|
||||
@@ -236,6 +236,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
case AV_PIX_FMT_GBRAP16BE:
|
||||
w_align = 16; //FIXME assume 16 pixel per macroblock
|
||||
h_align = 16 * 2; // interlaced needs 2 macroblocks height
|
||||
if (s->codec_id == AV_CODEC_ID_BINKVIDEO)
|
||||
w_align = 16*2;
|
||||
break;
|
||||
case AV_PIX_FMT_YUV411P:
|
||||
case AV_PIX_FMT_YUVJ411P:
|
||||
@@ -314,6 +316,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
*width = FFALIGN(*width, w_align);
|
||||
*height = FFALIGN(*height, h_align);
|
||||
if (s->codec_id == AV_CODEC_ID_H264 || s->lowres ||
|
||||
s->codec_id == AV_CODEC_ID_VC1 || s->codec_id == AV_CODEC_ID_WMV3 ||
|
||||
s->codec_id == AV_CODEC_ID_VP5 || s->codec_id == AV_CODEC_ID_VP6 ||
|
||||
s->codec_id == AV_CODEC_ID_VP6F || s->codec_id == AV_CODEC_ID_VP6A
|
||||
) {
|
||||
@@ -327,6 +330,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
// the next rounded up width is 32
|
||||
*width = FFMAX(*width, 32);
|
||||
}
|
||||
if (s->codec_id == AV_CODEC_ID_SVQ3) {
|
||||
*width = FFMAX(*width, 32);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
linesize_align[i] = STRIDE_ALIGN;
|
||||
|
||||
@@ -60,7 +60,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
|
||||
av_assert2(start_x < end_x && block_w);
|
||||
|
||||
w = end_x - start_x;
|
||||
src += start_y * src_linesize + start_x * sizeof(pixel);
|
||||
src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel);
|
||||
buf += start_x * sizeof(pixel);
|
||||
|
||||
// top
|
||||
@@ -83,7 +83,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
|
||||
buf += buf_linesize;
|
||||
}
|
||||
|
||||
buf -= block_h * buf_linesize + start_x * sizeof(pixel);
|
||||
buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel);
|
||||
while (block_h--) {
|
||||
pixel *bufp = (pixel *) buf;
|
||||
|
||||
|
||||
@@ -608,8 +608,7 @@ static void videotoolbox_decoder_callback(void *opaque,
|
||||
CMTime pts,
|
||||
CMTime duration)
|
||||
{
|
||||
AVCodecContext *avctx = opaque;
|
||||
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
|
||||
VTContext *vtctx = opaque;
|
||||
|
||||
if (vtctx->frame) {
|
||||
CVPixelBufferRelease(vtctx->frame);
|
||||
@@ -617,7 +616,8 @@ static void videotoolbox_decoder_callback(void *opaque,
|
||||
}
|
||||
|
||||
if (!image_buffer) {
|
||||
av_log(avctx, AV_LOG_DEBUG, "vt decoder cb: output image buffer is null\n");
|
||||
av_log(vtctx->logctx, AV_LOG_DEBUG,
|
||||
"vt decoder cb: output image buffer is null: %i\n", status);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ static int videotoolbox_start(AVCodecContext *avctx)
|
||||
videotoolbox->cv_pix_fmt_type);
|
||||
|
||||
decoder_cb.decompressionOutputCallback = videotoolbox_decoder_callback;
|
||||
decoder_cb.decompressionOutputRefCon = avctx;
|
||||
decoder_cb.decompressionOutputRefCon = avctx->internal->hwaccel_priv_data;
|
||||
|
||||
status = VTDecompressionSessionCreate(NULL, // allocator
|
||||
videotoolbox->cm_fmt_desc, // videoFormatDescription
|
||||
@@ -1040,6 +1040,8 @@ static int videotoolbox_common_init(AVCodecContext *avctx)
|
||||
AVHWFramesContext *hw_frames;
|
||||
int err;
|
||||
|
||||
vtctx->logctx = avctx;
|
||||
|
||||
// Old API - do nothing.
|
||||
if (avctx->hwaccel_context)
|
||||
return 0;
|
||||
|
||||
+6
-1
@@ -2683,8 +2683,13 @@ static int vp3_decode_frame(AVCodecContext *avctx,
|
||||
if ((ret = ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF)) < 0)
|
||||
goto error;
|
||||
|
||||
if (!s->edge_emu_buffer)
|
||||
if (!s->edge_emu_buffer) {
|
||||
s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));
|
||||
if (!s->edge_emu_buffer) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->keyframe) {
|
||||
if (!s->theora) {
|
||||
|
||||
@@ -42,6 +42,8 @@ typedef struct VTContext {
|
||||
// Current H264 parameters (used to trigger decoder restart on SPS changes).
|
||||
uint8_t sps[3];
|
||||
bool reconfig_needed;
|
||||
|
||||
void *logctx;
|
||||
} VTContext;
|
||||
|
||||
int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame);
|
||||
|
||||
@@ -128,7 +128,7 @@ static av_always_inline unsigned get_tail(GetBitContext *gb, int k)
|
||||
e = (1 << (p + 1)) - k - 1;
|
||||
res = get_bitsz(gb, p);
|
||||
if (res >= e)
|
||||
res = (res << 1) - e + get_bits1(gb);
|
||||
res = res * 2U - e + get_bits1(gb);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -498,6 +498,8 @@ static int wv_unpack_dsd_high(WavpackFrameContext *s, uint8_t *dst_left, uint8_t
|
||||
sp[0].fltr0 = 0;
|
||||
}
|
||||
|
||||
if (DSD_BYTE_READY(high, low) && !bytestream2_get_bytes_left(&s->gbyte))
|
||||
return AVERROR_INVALIDDATA;
|
||||
while (DSD_BYTE_READY(high, low) && bytestream2_get_bytes_left(&s->gbyte)) {
|
||||
value = (value << 8) | bytestream2_get_byte(&s->gbyte);
|
||||
high = (high << 8) | 0xff;
|
||||
@@ -533,6 +535,8 @@ static int wv_unpack_dsd_high(WavpackFrameContext *s, uint8_t *dst_left, uint8_t
|
||||
sp[1].fltr0 = 0;
|
||||
}
|
||||
|
||||
if (DSD_BYTE_READY(high, low) && !bytestream2_get_bytes_left(&s->gbyte))
|
||||
return AVERROR_INVALIDDATA;
|
||||
while (DSD_BYTE_READY(high, low) && bytestream2_get_bytes_left(&s->gbyte)) {
|
||||
value = (value << 8) | bytestream2_get_byte(&s->gbyte);
|
||||
high = (high << 8) | 0xff;
|
||||
|
||||
@@ -126,6 +126,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||
|
||||
if (avctx->width <= 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
|
||||
|
||||
ff_thread_once(&init_static_once, wnv1_init_static);
|
||||
|
||||
@@ -355,6 +355,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (size > SIZE_MAX / 4)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
size *= 4;
|
||||
|
||||
ptr += mod_strcspn(ptr, ",") + 1;
|
||||
|
||||
+17
-7
@@ -353,15 +353,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||
{
|
||||
Frei0rContext *s = inlink->dst->priv;
|
||||
AVFilterLink *outlink = inlink->dst->outputs[0];
|
||||
AVFrame *out;
|
||||
AVFrame *out = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 16);
|
||||
if (!out)
|
||||
goto fail;
|
||||
|
||||
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
|
||||
if (!out) {
|
||||
av_frame_free(&in);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
av_frame_copy_props(out, in);
|
||||
|
||||
if (in->linesize[0] != out->linesize[0]) {
|
||||
AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 16);
|
||||
if (!in2)
|
||||
goto fail;
|
||||
av_frame_copy(in2, in);
|
||||
av_frame_free(&in);
|
||||
in = in2;
|
||||
}
|
||||
|
||||
s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
|
||||
(const uint32_t *)in->data[0],
|
||||
(uint32_t *)out->data[0]);
|
||||
@@ -369,6 +375,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||
av_frame_free(&in);
|
||||
|
||||
return ff_filter_frame(outlink, out);
|
||||
fail:
|
||||
av_frame_free(&in);
|
||||
av_frame_free(&out);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
|
||||
@@ -467,7 +477,7 @@ static int source_config_props(AVFilterLink *outlink)
|
||||
static int source_request_frame(AVFilterLink *outlink)
|
||||
{
|
||||
Frei0rContext *s = outlink->src->priv;
|
||||
AVFrame *frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
|
||||
AVFrame *frame = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 16);
|
||||
|
||||
if (!frame)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
+10
-10
@@ -493,19 +493,19 @@ static int config_props(AVFilterLink *outlink)
|
||||
if ((ret = scale_eval_dimensions(ctx)) < 0)
|
||||
goto fail;
|
||||
|
||||
ff_scale_adjust_dimensions(inlink, &scale->w, &scale->h,
|
||||
outlink->w = scale->w;
|
||||
outlink->h = scale->h;
|
||||
|
||||
ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
|
||||
scale->force_original_aspect_ratio,
|
||||
scale->force_divisible_by);
|
||||
|
||||
if (scale->w > INT_MAX ||
|
||||
scale->h > INT_MAX ||
|
||||
(scale->h * inlink->w) > INT_MAX ||
|
||||
(scale->w * inlink->h) > INT_MAX)
|
||||
if (outlink->w > INT_MAX ||
|
||||
outlink->h > INT_MAX ||
|
||||
(outlink->h * inlink->w) > INT_MAX ||
|
||||
(outlink->w * inlink->h) > INT_MAX)
|
||||
av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
|
||||
|
||||
outlink->w = scale->w;
|
||||
outlink->h = scale->h;
|
||||
|
||||
/* TODO: make algorithm configurable */
|
||||
|
||||
scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL;
|
||||
@@ -684,9 +684,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
|
||||
goto scale;
|
||||
|
||||
if (scale->eval_mode == EVAL_MODE_INIT) {
|
||||
snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
|
||||
snprintf(buf, sizeof(buf) - 1, "%d", scale->w);
|
||||
av_opt_set(scale, "w", buf, 0);
|
||||
snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
|
||||
snprintf(buf, sizeof(buf) - 1, "%d", scale->h);
|
||||
av_opt_set(scale, "h", buf, 0);
|
||||
|
||||
ret = scale_parse_expr(ctx, NULL, &scale->w_pexpr, "width", scale->w_expr);
|
||||
|
||||
@@ -454,12 +454,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
||||
av_log(ctx, AV_LOG_INFO, " %08"PRIX32, plane_checksum[plane]);
|
||||
av_log(ctx, AV_LOG_INFO, "] mean:[");
|
||||
for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
|
||||
av_log(ctx, AV_LOG_INFO, "%"PRId64" ", (sum[plane] + pixelcount[plane]/2) / pixelcount[plane]);
|
||||
av_log(ctx, AV_LOG_INFO, "\b] stdev:[");
|
||||
av_log(ctx, AV_LOG_INFO, "%s%"PRId64,
|
||||
plane ? " ":"",
|
||||
(sum[plane] + pixelcount[plane]/2) / pixelcount[plane]);
|
||||
av_log(ctx, AV_LOG_INFO, "] stdev:[");
|
||||
for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
|
||||
av_log(ctx, AV_LOG_INFO, "%3.1f ",
|
||||
av_log(ctx, AV_LOG_INFO, "%s%3.1f",
|
||||
plane ? " ":"",
|
||||
sqrt((sum2[plane] - sum[plane]*(double)sum[plane]/pixelcount[plane])/pixelcount[plane]));
|
||||
av_log(ctx, AV_LOG_INFO, "\b]");
|
||||
av_log(ctx, AV_LOG_INFO, "]");
|
||||
}
|
||||
av_log(ctx, AV_LOG_INFO, "\n");
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
|
||||
dw1 = inlink->w / 32;
|
||||
if (inlink->w % 32)
|
||||
dw2 = dw1 + 1;
|
||||
denom = (sc->divide) ? dh1 * dh2 * dw1 * dw2 : 1;
|
||||
denom = (sc->divide) ? dh1 * (int64_t)dh2 * dw1 * dw2 : 1;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
rowcount = 0;
|
||||
@@ -250,7 +250,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
|
||||
}
|
||||
}
|
||||
|
||||
denom = (sc->divide) ? 1 : dh1 * dh2 * dw1 * dw2;
|
||||
denom = (sc->divide) ? 1 : dh1 * (int64_t)dh2 * dw1 * dw2;
|
||||
|
||||
for (i = 0; i < ELEMENT_COUNT; i++) {
|
||||
const ElemCat* elemcat = elements[i];
|
||||
|
||||
@@ -139,8 +139,8 @@ static int activate(AVFilterContext *ctx)
|
||||
if (!(s->desc->flags & AV_PIX_FMT_FLAG_PAL || s->desc->flags & FF_PSEUDOPAL)) {
|
||||
for (i = 1; i < 3; i ++) {
|
||||
if (out->data[i]) {
|
||||
out->data[i] += (y >> s->desc->log2_chroma_w) * out->linesize[i];
|
||||
out->data[i] += (x >> s->desc->log2_chroma_h) * s->max_step[i];
|
||||
out->data[i] += (y >> s->desc->log2_chroma_h) * out->linesize[i];
|
||||
out->data[i] += (x >> s->desc->log2_chroma_w) * s->max_step[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -41,7 +41,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
|
||||
return ff_get_video_buffer(link->dst->outputs[0], w, h);
|
||||
}
|
||||
|
||||
AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
|
||||
AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align)
|
||||
{
|
||||
AVFrame *frame = NULL;
|
||||
int pool_width = 0;
|
||||
@@ -96,6 +96,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
|
||||
return frame;
|
||||
}
|
||||
|
||||
AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
|
||||
{
|
||||
return ff_default_get_video_buffer2(link, w, h, av_cpu_max_align());
|
||||
}
|
||||
|
||||
AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h)
|
||||
{
|
||||
AVFrame *ret = NULL;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "avfilter.h"
|
||||
|
||||
AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h);
|
||||
AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align);
|
||||
AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h);
|
||||
|
||||
/**
|
||||
|
||||
@@ -134,6 +134,9 @@ static av_cold int init(AVFilterContext *ctx)
|
||||
s-> next_cache= av_malloc_array(s->cache_allocated, sizeof(*s-> next_cache));
|
||||
s-> zyklus = av_malloc_array(s->maxiter + 16, sizeof(*s->zyklus));
|
||||
|
||||
if (!s->point_cache || !s->next_cache || !s->zyklus)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,6 +262,8 @@ static int aax_read_header(AVFormatContext *s)
|
||||
|
||||
start = avio_rb32(pb);
|
||||
size = avio_rb32(pb);
|
||||
if (!size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
a->segments[r].start = start + a->data_offset;
|
||||
a->segments[r].end = a->segments[r].start + size;
|
||||
} else {
|
||||
|
||||
+4
-1
@@ -66,6 +66,7 @@ static int read_header(AVFormatContext *s)
|
||||
AVIOContext *pb = s->pb;
|
||||
int size;
|
||||
AVStream* st;
|
||||
int ret;
|
||||
|
||||
int min,sec,msec;
|
||||
|
||||
@@ -75,7 +76,9 @@ static int read_header(AVFormatContext *s)
|
||||
|
||||
avio_skip(pb, 16);
|
||||
size=avio_rl32(pb);
|
||||
ff_get_wav_header(s, pb, st->codecpar, size, 0);
|
||||
ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
8000Hz (Fine-rec) file format has 10 bytes long
|
||||
|
||||
+15
-18
@@ -53,9 +53,9 @@ static enum AVCodecID aiff_codec_get_id(int bps)
|
||||
}
|
||||
|
||||
/* returns the size of the found tag */
|
||||
static int get_tag(AVIOContext *pb, uint32_t * tag)
|
||||
static int64_t get_tag(AVIOContext *pb, uint32_t * tag)
|
||||
{
|
||||
int size;
|
||||
int64_t size;
|
||||
|
||||
if (avio_feof(pb))
|
||||
return AVERROR(EIO);
|
||||
@@ -63,16 +63,16 @@ static int get_tag(AVIOContext *pb, uint32_t * tag)
|
||||
*tag = avio_rl32(pb);
|
||||
size = avio_rb32(pb);
|
||||
|
||||
if (size < 0)
|
||||
size = 0x7fffffff;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Metadata string read */
|
||||
static void get_meta(AVFormatContext *s, const char *key, int size)
|
||||
static void get_meta(AVFormatContext *s, const char *key, int64_t size)
|
||||
{
|
||||
uint8_t *str = av_malloc(size+1);
|
||||
uint8_t *str = NULL;
|
||||
|
||||
if (size < SIZE_MAX)
|
||||
str = av_malloc(size+1);
|
||||
|
||||
if (str) {
|
||||
int res = avio_read(s->pb, str, size);
|
||||
@@ -89,7 +89,7 @@ static void get_meta(AVFormatContext *s, const char *key, int size)
|
||||
}
|
||||
|
||||
/* Returns the number of sound data frames or negative on error */
|
||||
static int get_aiff_header(AVFormatContext *s, int size,
|
||||
static int get_aiff_header(AVFormatContext *s, int64_t size,
|
||||
unsigned version)
|
||||
{
|
||||
AVIOContext *pb = s->pb;
|
||||
@@ -100,9 +100,6 @@ static int get_aiff_header(AVFormatContext *s, int size,
|
||||
int sample_rate;
|
||||
unsigned int num_frames;
|
||||
|
||||
if (size == INT_MAX)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (size & 1)
|
||||
size++;
|
||||
par->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
@@ -213,7 +210,8 @@ static int aiff_probe(const AVProbeData *p)
|
||||
/* aiff input */
|
||||
static int aiff_read_header(AVFormatContext *s)
|
||||
{
|
||||
int ret, size, filesize;
|
||||
int ret;
|
||||
int64_t filesize, size;
|
||||
int64_t offset = 0, position;
|
||||
uint32_t tag;
|
||||
unsigned version = AIFF_C_VERSION1;
|
||||
@@ -224,7 +222,7 @@ static int aiff_read_header(AVFormatContext *s)
|
||||
|
||||
/* check FORM header */
|
||||
filesize = get_tag(pb, &tag);
|
||||
if (filesize < 0 || tag != MKTAG('F', 'O', 'R', 'M'))
|
||||
if (filesize < 4 || tag != MKTAG('F', 'O', 'R', 'M'))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* AIFF data type */
|
||||
@@ -251,10 +249,7 @@ static int aiff_read_header(AVFormatContext *s)
|
||||
if (size < 0)
|
||||
return size;
|
||||
|
||||
if (size >= 0x7fffffff - 8)
|
||||
filesize = 0;
|
||||
else
|
||||
filesize -= size + 8;
|
||||
filesize -= size + 8;
|
||||
|
||||
switch (tag) {
|
||||
case MKTAG('C', 'O', 'M', 'M'): /* Common chunk */
|
||||
@@ -374,6 +369,8 @@ got_sound:
|
||||
av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n");
|
||||
return -1;
|
||||
}
|
||||
if (aiff->block_duration < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* Now positioned, get the sound data start and end */
|
||||
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
|
||||
@@ -428,7 +425,7 @@ static int aiff_read_packet(AVFormatContext *s,
|
||||
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||
/* Only one stream in an AIFF file */
|
||||
pkt->stream_index = 0;
|
||||
pkt->duration = (res / st->codecpar->block_align) * aiff->block_duration;
|
||||
pkt->duration = (res / st->codecpar->block_align) * (int64_t) aiff->block_duration;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -42,8 +42,8 @@
|
||||
|
||||
typedef struct APEFrame {
|
||||
int64_t pos;
|
||||
int64_t size;
|
||||
int nblocks;
|
||||
int size;
|
||||
int skip;
|
||||
int64_t pts;
|
||||
} APEFrame;
|
||||
@@ -130,7 +130,7 @@ static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx)
|
||||
|
||||
av_log(s, AV_LOG_DEBUG, "\nFrames\n\n");
|
||||
for (i = 0; i < ape_ctx->totalframes; i++)
|
||||
av_log(s, AV_LOG_DEBUG, "%8d %8"PRId64" %8d (%d samples)\n", i,
|
||||
av_log(s, AV_LOG_DEBUG, "%8d %8"PRId64" %8"PRId64" (%d samples)\n", i,
|
||||
ape_ctx->frames[i].pos, ape_ctx->frames[i].size,
|
||||
ape_ctx->frames[i].nblocks);
|
||||
|
||||
@@ -148,7 +148,8 @@ static int ape_read_header(AVFormatContext * s)
|
||||
AVStream *st;
|
||||
uint32_t tag;
|
||||
int i, ret;
|
||||
int total_blocks, final_size = 0;
|
||||
int total_blocks;
|
||||
int64_t final_size = 0;
|
||||
int64_t pts, file_size;
|
||||
|
||||
/* Skip any leading junk such as id3v2 tags */
|
||||
@@ -300,6 +301,8 @@ static int ape_read_header(AVFormatContext * s)
|
||||
ape->frames[i].pos -= ape->frames[i].skip;
|
||||
ape->frames[i].size += ape->frames[i].skip;
|
||||
}
|
||||
if (ape->frames[i].size > INT_MAX - 3)
|
||||
return AVERROR_INVALIDDATA;
|
||||
ape->frames[i].size = (ape->frames[i].size + 3) & ~3;
|
||||
}
|
||||
if (ape->fileversion < 3810) {
|
||||
@@ -397,7 +400,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
|
||||
if (ape->frames[ape->currentframe].size <= 0 ||
|
||||
ape->frames[ape->currentframe].size > INT_MAX - extra_size) {
|
||||
av_log(s, AV_LOG_ERROR, "invalid packet size: %d\n",
|
||||
av_log(s, AV_LOG_ERROR, "invalid packet size: %8"PRId64"\n",
|
||||
ape->frames[ape->currentframe].size);
|
||||
ape->currentframe++;
|
||||
return AVERROR(EIO);
|
||||
|
||||
@@ -104,7 +104,7 @@ typedef struct ASFContext {
|
||||
int ts_is_pts;
|
||||
int packet_multi_size;
|
||||
int packet_time_delta;
|
||||
int packet_time_start;
|
||||
int64_t packet_time_start;
|
||||
int64_t packet_pos;
|
||||
|
||||
int stream_index;
|
||||
@@ -1321,10 +1321,12 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
|
||||
if ((ret = av_new_packet(&asf_st->pkt, asf_st->packet_obj_size)) < 0)
|
||||
return ret;
|
||||
asf_st->seq = asf->packet_seq;
|
||||
if (asf->ts_is_pts) {
|
||||
asf_st->pkt.pts = asf->packet_frag_timestamp - asf->hdr.preroll;
|
||||
} else
|
||||
asf_st->pkt.dts = asf->packet_frag_timestamp - asf->hdr.preroll;
|
||||
if (asf->packet_frag_timestamp != AV_NOPTS_VALUE) {
|
||||
if (asf->ts_is_pts) {
|
||||
asf_st->pkt.pts = asf->packet_frag_timestamp - asf->hdr.preroll;
|
||||
} else
|
||||
asf_st->pkt.dts = asf->packet_frag_timestamp - asf->hdr.preroll;
|
||||
}
|
||||
asf_st->pkt.stream_index = asf->stream_index;
|
||||
asf_st->pkt.pos = asf_st->packet_pos = asf->packet_pos;
|
||||
asf_st->pkt_clean = 0;
|
||||
|
||||
@@ -113,6 +113,7 @@ typedef struct ASFContext {
|
||||
int64_t data_offset;
|
||||
int64_t first_packet_offset; // packet offset
|
||||
int64_t unknown_offset; // for top level header objects or subobjects without specified behavior
|
||||
int in_asf_read_unknown;
|
||||
|
||||
// ASF file must not contain more than 128 streams according to the specification
|
||||
ASFStream *asf_st[ASF_MAX_STREAMS];
|
||||
@@ -177,7 +178,7 @@ static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g)
|
||||
uint64_t size = avio_rl64(pb);
|
||||
int ret;
|
||||
|
||||
if (size > INT64_MAX)
|
||||
if (size > INT64_MAX || asf->in_asf_read_unknown > 5)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (asf->is_header)
|
||||
@@ -186,8 +187,11 @@ static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g)
|
||||
if (!g->is_subobject) {
|
||||
if (!(ret = strcmp(g->name, "Header Extension")))
|
||||
avio_skip(pb, 22); // skip reserved fields and Data Size
|
||||
if ((ret = detect_unknown_subobject(s, asf->unknown_offset,
|
||||
asf->unknown_size)) < 0)
|
||||
asf->in_asf_read_unknown ++;
|
||||
ret = detect_unknown_subobject(s, asf->unknown_offset,
|
||||
asf->unknown_size);
|
||||
asf->in_asf_read_unknown --;
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
if (size < 24) {
|
||||
@@ -1350,6 +1354,8 @@ static int asf_read_packet_header(AVFormatContext *s)
|
||||
unsigned char error_flags, len_flags, pay_flags;
|
||||
|
||||
asf->packet_offset = avio_tell(pb);
|
||||
if (asf->packet_offset > INT64_MAX/2)
|
||||
asf->packet_offset = 0;
|
||||
error_flags = avio_r8(pb); // read Error Correction Flags
|
||||
if (error_flags & ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT) {
|
||||
if (!(error_flags & ASF_ERROR_CORRECTION_LENGTH_TYPE)) {
|
||||
|
||||
+11
-1
@@ -79,6 +79,8 @@ typedef struct AVIContext {
|
||||
int stream_index;
|
||||
DVDemuxContext *dv_demux;
|
||||
int odml_depth;
|
||||
int64_t odml_read;
|
||||
int64_t odml_max_pos;
|
||||
int use_odml;
|
||||
#define MAX_ODML_DEPTH 1000
|
||||
int64_t dts_max;
|
||||
@@ -198,7 +200,7 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num)
|
||||
st = s->streams[stream_id];
|
||||
ast = st->priv_data;
|
||||
|
||||
if (index_sub_type)
|
||||
if (index_sub_type || entries_in_use < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
avio_rl32(pb);
|
||||
@@ -219,11 +221,18 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num)
|
||||
}
|
||||
|
||||
for (i = 0; i < entries_in_use; i++) {
|
||||
avi->odml_max_pos = FFMAX(avi->odml_max_pos, avio_tell(pb));
|
||||
|
||||
// If we read more than there are bytes then we must have been reading something twice
|
||||
if (avi->odml_read > avi->odml_max_pos)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (index_type) {
|
||||
int64_t pos = avio_rl32(pb) + base - 8;
|
||||
int len = avio_rl32(pb);
|
||||
int key = len >= 0;
|
||||
len &= 0x7FFFFFFF;
|
||||
avi->odml_read += 8;
|
||||
|
||||
av_log(s, AV_LOG_TRACE, "pos:%"PRId64", len:%X\n", pos, len);
|
||||
|
||||
@@ -242,6 +251,7 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num)
|
||||
int64_t offset, pos;
|
||||
int duration;
|
||||
int ret;
|
||||
avi->odml_read += 16;
|
||||
|
||||
offset = avio_rl64(pb);
|
||||
avio_rl32(pb); /* size */
|
||||
|
||||
@@ -1005,6 +1005,9 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
|
||||
if (buf_size <= s->buf_end - s->buf_ptr)
|
||||
return 0;
|
||||
|
||||
if (buf_size > INT_MAX - max_buffer_size)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
buf_size += max_buffer_size - 1;
|
||||
|
||||
if (buf_size + s->buf_ptr - s->buffer <= s->buffer_size || s->seekable || !s->read_packet)
|
||||
|
||||
+3
-3
@@ -140,12 +140,12 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
audio_offset = avio_rl32(pb);
|
||||
avio_rl32(pb);
|
||||
video_offset = avio_rl32(pb);
|
||||
audio_size = video_offset - audio_offset;
|
||||
bfi->video_size = chunk_size - video_offset;
|
||||
if (audio_size < 0 || bfi->video_size < 0) {
|
||||
if (audio_offset < 0 || video_offset < audio_offset || chunk_size < video_offset) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid audio/video offsets or chunk size\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
audio_size = video_offset - audio_offset;
|
||||
bfi->video_size = chunk_size - video_offset;
|
||||
|
||||
//Tossing an audio packet at the audio decoder.
|
||||
ret = av_get_packet(pb, pkt, audio_size);
|
||||
|
||||
@@ -342,7 +342,7 @@ static int read_header(AVFormatContext *s)
|
||||
|
||||
found_data:
|
||||
if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) {
|
||||
if (caf->data_size > 0)
|
||||
if (caf->data_size > 0 && caf->data_size / caf->bytes_per_packet < INT64_MAX / caf->frames_per_packet)
|
||||
st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
|
||||
} else if (st->nb_index_entries && st->duration > 0) {
|
||||
if (st->codecpar->sample_rate && caf->data_size / st->duration > INT64_MAX / st->codecpar->sample_rate / 8) {
|
||||
|
||||
+5
-2
@@ -118,9 +118,12 @@ static int dxa_read_header(AVFormatContext *s)
|
||||
if(tag == MKTAG('d', 'a', 't', 'a')) break;
|
||||
avio_skip(pb, fsize);
|
||||
}
|
||||
c->bpc = (fsize + c->frames - 1) / c->frames;
|
||||
if(ast->codecpar->block_align)
|
||||
c->bpc = (fsize + (int64_t)c->frames - 1) / c->frames;
|
||||
if(ast->codecpar->block_align) {
|
||||
if (c->bpc > INT_MAX - ast->codecpar->block_align + 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
c->bpc = ((c->bpc + ast->codecpar->block_align - 1) / ast->codecpar->block_align) * ast->codecpar->block_align;
|
||||
}
|
||||
c->bytes_left = fsize;
|
||||
c->wavpos = avio_tell(pb);
|
||||
avio_seek(pb, c->vidpos, SEEK_SET);
|
||||
|
||||
@@ -64,7 +64,7 @@ typedef struct FLVContext {
|
||||
uint8_t resync_buffer[2*RESYNC_BUFFER_SIZE];
|
||||
|
||||
int broken_sizes;
|
||||
int sum_flv_tag_size;
|
||||
int64_t sum_flv_tag_size;
|
||||
|
||||
int last_keyframe_stream_index;
|
||||
int keyframe_count;
|
||||
@@ -461,6 +461,8 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m
|
||||
goto invalid;
|
||||
if (current_array == × && (d <= INT64_MIN / 1000 || d >= INT64_MAX / 1000))
|
||||
goto invalid;
|
||||
if (avio_feof(ioc))
|
||||
goto invalid;
|
||||
current_array[0][i] = d;
|
||||
}
|
||||
if (times && filepositions) {
|
||||
@@ -1031,7 +1033,7 @@ retry:
|
||||
type = (avio_r8(s->pb) & 0x1F);
|
||||
orig_size =
|
||||
size = avio_rb24(s->pb);
|
||||
flv->sum_flv_tag_size += size + 11;
|
||||
flv->sum_flv_tag_size += size + 11LL;
|
||||
dts = avio_rb24(s->pb);
|
||||
dts |= (unsigned)avio_r8(s->pb) << 24;
|
||||
av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb));
|
||||
@@ -1333,7 +1335,7 @@ leave:
|
||||
!avio_feof(s->pb) &&
|
||||
(last != orig_size || !last) && last != flv->sum_flv_tag_size &&
|
||||
!flv->broken_sizes) {
|
||||
av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %d\n", last, orig_size + 11, flv->sum_flv_tag_size);
|
||||
av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %"PRId64"\n", last, orig_size + 11, flv->sum_flv_tag_size);
|
||||
avio_seek(s->pb, pos + 1, SEEK_SET);
|
||||
ret = resync(s);
|
||||
av_packet_unref(pkt);
|
||||
|
||||
@@ -67,6 +67,9 @@ static int genh_read_header(AVFormatContext *s)
|
||||
return AVERROR_INVALIDDATA;
|
||||
st->codecpar->block_align = align * st->codecpar->channels;
|
||||
st->codecpar->sample_rate = avio_rl32(s->pb);
|
||||
if (st->codecpar->sample_rate < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
avio_skip(s->pb, 4);
|
||||
st->duration = avio_rl32(s->pb);
|
||||
|
||||
|
||||
+4
-3
@@ -236,6 +236,7 @@ static void free_init_section_list(struct playlist *pls)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < pls->n_init_sections; i++) {
|
||||
av_freep(&pls->init_sections[i]->key);
|
||||
av_freep(&pls->init_sections[i]->url);
|
||||
av_freep(&pls->init_sections[i]);
|
||||
}
|
||||
@@ -826,10 +827,10 @@ static int parse_playlist(HLSContext *c, const char *url,
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
seq_no = strtoull(ptr, NULL, 10);
|
||||
if (seq_no > INT64_MAX) {
|
||||
if (seq_no > INT64_MAX/2) {
|
||||
av_log(c->ctx, AV_LOG_DEBUG, "MEDIA-SEQUENCE higher than "
|
||||
"INT64_MAX, mask out the highest bit\n");
|
||||
seq_no &= INT64_MAX;
|
||||
"INT64_MAX/2, mask out the highest bit\n");
|
||||
seq_no &= INT64_MAX/2;
|
||||
}
|
||||
pls->start_seq_no = seq_no;
|
||||
} else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
|
||||
|
||||
@@ -203,6 +203,9 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
AV_WL32(buf + 32, image->nb_pal);
|
||||
}
|
||||
|
||||
if (image->nb_pal > INT_MAX / 4 - 14 - 40)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
AV_WL32(buf - 4, 14 + 40 + image->nb_pal * 4);
|
||||
AV_WL32(buf + 8, AV_RL32(buf + 8) / 2);
|
||||
}
|
||||
|
||||
+2
-2
@@ -376,10 +376,10 @@ static void read_uslt(AVFormatContext *s, AVIOContext *pb, int taglen,
|
||||
lang[3] = '\0';
|
||||
taglen -= 3;
|
||||
|
||||
if (decode_str(s, pb, encoding, &descriptor, &taglen) < 0)
|
||||
if (decode_str(s, pb, encoding, &descriptor, &taglen) < 0 || taglen < 0)
|
||||
goto error;
|
||||
|
||||
if (decode_str(s, pb, encoding, &text, &taglen) < 0)
|
||||
if (decode_str(s, pb, encoding, &text, &taglen) < 0 || taglen < 0)
|
||||
goto error;
|
||||
|
||||
// FFmpeg does not support hierarchical metadata, so concatenate the keys.
|
||||
|
||||
+6
-2
@@ -385,7 +385,7 @@ static int read_dst_frame(AVFormatContext *s, AVPacket *pkt)
|
||||
avio_skip(pb, 1);
|
||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||
pkt->stream_index = 0;
|
||||
pkt->duration = 588LL * s->streams[0]->codecpar->sample_rate / 44100;
|
||||
pkt->duration = s->streams[0]->codecpar->sample_rate / 75;
|
||||
pkt->pos = chunk_pos;
|
||||
|
||||
chunk_pos = avio_tell(pb);
|
||||
@@ -398,7 +398,8 @@ static int read_dst_frame(AVFormatContext *s, AVPacket *pkt)
|
||||
case ID_FRTE:
|
||||
if (data_size < 4)
|
||||
return AVERROR_INVALIDDATA;
|
||||
s->streams[0]->duration = avio_rb32(pb) * 588LL * s->streams[0]->codecpar->sample_rate / 44100;
|
||||
s->streams[0]->duration = avio_rb32(pb) * (uint64_t)s->streams[0]->codecpar->sample_rate / 75;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -501,6 +502,9 @@ static int iff_read_header(AVFormatContext *s)
|
||||
case ID_DST:
|
||||
case ID_MDAT:
|
||||
iff->body_pos = avio_tell(pb);
|
||||
if (iff->body_pos < 0 || iff->body_pos + data_size > INT64_MAX)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
iff->body_end = iff->body_pos + data_size;
|
||||
iff->body_size = data_size;
|
||||
if (chunk_id == ID_DST) {
|
||||
|
||||
@@ -152,7 +152,7 @@ static int get_shift(int timeres, const char *buf)
|
||||
ret = 0;
|
||||
switch (n) {
|
||||
case 4:
|
||||
ret = sign * (((int64_t)a*3600 + b*60 + c) * timeres + d);
|
||||
ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d);
|
||||
break;
|
||||
case 3:
|
||||
ret = sign * (( (int64_t)a*60 + b) * timeres + c);
|
||||
|
||||
@@ -51,7 +51,7 @@ static int zmq_proto_wait(URLContext *h, void *socket, int write)
|
||||
zmq_pollitem_t items = { .socket = socket, .fd = 0, .events = ev, .revents = 0 };
|
||||
ret = zmq_poll(&items, 1, POLLING_TIME);
|
||||
if (ret == -1) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_poll(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_poll(): %s\n", ZMQ_STRERROR);
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
return items.revents & ev ? 0 : AVERROR(EAGAIN);
|
||||
@@ -90,7 +90,7 @@ static int zmq_proto_open(URLContext *h, const char *uri, int flags)
|
||||
s->context = zmq_ctx_new();
|
||||
if (!s->context) {
|
||||
/*errno not set on failure during zmq_ctx_new()*/
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_ctx_new()\n");
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_ctx_new()\n");
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
|
||||
@@ -100,13 +100,13 @@ static int zmq_proto_open(URLContext *h, const char *uri, int flags)
|
||||
if (h->flags & AVIO_FLAG_WRITE) {
|
||||
s->socket = zmq_socket(s->context, ZMQ_PUB);
|
||||
if (!s->socket) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_socket(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_socket(): %s\n", ZMQ_STRERROR);
|
||||
goto fail_term;
|
||||
}
|
||||
|
||||
ret = zmq_bind(s->socket, uri);
|
||||
if (ret == -1) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_bind(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_bind(): %s\n", ZMQ_STRERROR);
|
||||
goto fail_close;
|
||||
}
|
||||
}
|
||||
@@ -115,19 +115,19 @@ static int zmq_proto_open(URLContext *h, const char *uri, int flags)
|
||||
if (h->flags & AVIO_FLAG_READ) {
|
||||
s->socket = zmq_socket(s->context, ZMQ_SUB);
|
||||
if (!s->socket) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_socket(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_socket(): %s\n", ZMQ_STRERROR);
|
||||
goto fail_term;
|
||||
}
|
||||
|
||||
ret = zmq_setsockopt(s->socket, ZMQ_SUBSCRIBE, "", 0);
|
||||
if (ret == -1) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_setsockopt(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_setsockopt(): %s\n", ZMQ_STRERROR);
|
||||
goto fail_close;
|
||||
}
|
||||
|
||||
ret = zmq_connect(s->socket, uri);
|
||||
if (ret == -1) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_connect(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_connect(): %s\n", ZMQ_STRERROR);
|
||||
goto fail_close;
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ static int zmq_proto_write(URLContext *h, const unsigned char *buf, int size)
|
||||
return ret;
|
||||
ret = zmq_send(s->socket, buf, size, 0);
|
||||
if (ret == -1) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_send(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_send(): %s\n", ZMQ_STRERROR);
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
return ret; /*number of bytes sent*/
|
||||
@@ -166,7 +166,7 @@ static int zmq_proto_read(URLContext *h, unsigned char *buf, int size)
|
||||
return ret;
|
||||
ret = zmq_recv(s->socket, buf, size, 0);
|
||||
if (ret == -1) {
|
||||
av_log(h, AV_LOG_ERROR, "Error occured during zmq_recv(): %s\n", ZMQ_STRERROR);
|
||||
av_log(h, AV_LOG_ERROR, "Error occurred during zmq_recv(): %s\n", ZMQ_STRERROR);
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
if (ret > size) {
|
||||
|
||||
@@ -2802,11 +2802,14 @@ static int matroska_parse_tracks(AVFormatContext *s)
|
||||
mkv_stereo_mode_display_mul(track->video.stereo_mode, &display_width_mul, &display_height_mul);
|
||||
|
||||
if (track->video.display_unit < MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN) {
|
||||
av_reduce(&st->sample_aspect_ratio.num,
|
||||
&st->sample_aspect_ratio.den,
|
||||
st->codecpar->height * track->video.display_width * display_width_mul,
|
||||
st->codecpar->width * track->video.display_height * display_height_mul,
|
||||
INT_MAX);
|
||||
if (track->video.display_width && track->video.display_height &&
|
||||
st->codecpar->height < INT64_MAX / track->video.display_width / display_width_mul &&
|
||||
st->codecpar->width < INT64_MAX / track->video.display_height / display_height_mul)
|
||||
av_reduce(&st->sample_aspect_ratio.num,
|
||||
&st->sample_aspect_ratio.den,
|
||||
st->codecpar->height * track->video.display_width * display_width_mul,
|
||||
st->codecpar->width * track->video.display_height * display_height_mul,
|
||||
INT_MAX);
|
||||
}
|
||||
if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
|
||||
@@ -3963,6 +3963,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
|
||||
if (keyframe)
|
||||
distance = 0;
|
||||
sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizes[current_sample];
|
||||
if (current_offset > INT64_MAX - sample_size) {
|
||||
av_log(mov->fc, AV_LOG_ERROR, "Current offset %"PRId64" or sample size %u is too large\n",
|
||||
current_offset,
|
||||
sample_size);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sc->pseudo_stream_id == -1 ||
|
||||
sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) {
|
||||
AVIndexEntry *e;
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "mxf.h"
|
||||
|
||||
#define MXF_MAX_CHUNK_SIZE (32 << 20)
|
||||
#define RUN_IN_MAX (65535+1) // S377m-2004 section 5.5 and S377-1-2009 section 6.5, the +1 is to be slightly more tolerant
|
||||
|
||||
typedef enum {
|
||||
Header,
|
||||
@@ -3357,6 +3358,7 @@ static int mxf_read_header(AVFormatContext *s)
|
||||
KLVPacket klv;
|
||||
int64_t essence_offset = 0;
|
||||
int ret;
|
||||
int64_t run_in;
|
||||
|
||||
mxf->last_forward_tell = INT64_MAX;
|
||||
|
||||
@@ -3367,7 +3369,10 @@ static int mxf_read_header(AVFormatContext *s)
|
||||
}
|
||||
avio_seek(s->pb, -14, SEEK_CUR);
|
||||
mxf->fc = s;
|
||||
mxf->run_in = avio_tell(s->pb);
|
||||
run_in = avio_tell(s->pb);
|
||||
if (run_in < 0 || run_in > RUN_IN_MAX)
|
||||
return AVERROR_INVALIDDATA;
|
||||
mxf->run_in = run_in;
|
||||
|
||||
mxf_read_random_index_pack(s);
|
||||
|
||||
@@ -3511,8 +3516,8 @@ static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st,
|
||||
if ((sample_rate.num / sample_rate.den) == 48000) {
|
||||
return av_rescale_q(edit_unit, sample_rate, track->edit_rate);
|
||||
} else {
|
||||
int remainder = (sample_rate.num * time_base.num) %
|
||||
(time_base.den * sample_rate.den);
|
||||
int64_t remainder = (sample_rate.num * (int64_t) time_base.num) %
|
||||
( time_base.den * (int64_t)sample_rate.den);
|
||||
if (remainder)
|
||||
av_log(mxf->fc, AV_LOG_WARNING,
|
||||
"seeking detected on stream #%d with time base (%d/%d) and "
|
||||
@@ -3780,7 +3785,7 @@ static int mxf_read_close(AVFormatContext *s)
|
||||
|
||||
static int mxf_probe(const AVProbeData *p) {
|
||||
const uint8_t *bufp = p->buf;
|
||||
const uint8_t *end = p->buf + p->buf_size;
|
||||
const uint8_t *end = p->buf + FFMIN(p->buf_size, RUN_IN_MAX + 1 + sizeof(mxf_header_partition_pack_key));
|
||||
|
||||
if (p->buf_size < sizeof(mxf_header_partition_pack_key))
|
||||
return 0;
|
||||
|
||||
+19
-4
@@ -199,6 +199,8 @@ static int decode_main_header(NUTContext *nut)
|
||||
int tmp_stream, tmp_mul, tmp_pts, tmp_size, tmp_res, tmp_head_idx;
|
||||
|
||||
length = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
|
||||
if (length == (uint64_t)-1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
end = length + avio_tell(bc);
|
||||
|
||||
nut->version = ffio_read_varlen(bc);
|
||||
@@ -242,6 +244,11 @@ static int decode_main_header(NUTContext *nut)
|
||||
for (i = 0; i < 256;) {
|
||||
int tmp_flags = ffio_read_varlen(bc);
|
||||
int tmp_fields = ffio_read_varlen(bc);
|
||||
if (tmp_fields < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "fields %d is invalid\n", tmp_fields);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (tmp_fields > 0)
|
||||
tmp_pts = get_s(bc);
|
||||
@@ -351,8 +358,12 @@ static int decode_main_header(NUTContext *nut)
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
for (i = 0; i < stream_count; i++)
|
||||
avformat_new_stream(s, NULL);
|
||||
for (i = 0; i < stream_count; i++) {
|
||||
if (!avformat_new_stream(s, NULL)) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
@@ -800,19 +811,23 @@ static int nut_read_header(AVFormatContext *s)
|
||||
NUTContext *nut = s->priv_data;
|
||||
AVIOContext *bc = s->pb;
|
||||
int64_t pos;
|
||||
int initialized_stream_count;
|
||||
int initialized_stream_count, ret;
|
||||
|
||||
nut->avf = s;
|
||||
|
||||
/* main header */
|
||||
pos = 0;
|
||||
ret = 0;
|
||||
do {
|
||||
if (ret == AVERROR(ENOMEM))
|
||||
return ret;
|
||||
|
||||
pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1;
|
||||
if (pos < 0 + 1) {
|
||||
av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
|
||||
goto fail;
|
||||
}
|
||||
} while (decode_main_header(nut) < 0);
|
||||
} while ((ret = decode_main_header(nut)) < 0);
|
||||
|
||||
/* stream headers */
|
||||
pos = 0;
|
||||
|
||||
@@ -61,7 +61,7 @@ static int32_t parse_value(const char *value, int32_t min)
|
||||
}
|
||||
}
|
||||
|
||||
if (abs(db) > (INT32_MAX - mb) / 100000)
|
||||
if (llabs(db) > (INT32_MAX - mb) / 100000)
|
||||
return min;
|
||||
|
||||
return db * 100000 + sign * mb;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user