Compare commits
219 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e4ec87720 | |||
| ab70292fd0 | |||
| 073fcfe358 | |||
| 9f0e36b101 | |||
| 3a1aaec9bb | |||
| 6c83283c3a | |||
| 70720f3e4d | |||
| 9ee155c745 | |||
| 311de799a8 | |||
| c676db730e | |||
| c02a9f1c6e | |||
| bafd5c3c80 | |||
| 9459490c2a | |||
| e5a2128ead | |||
| 142f8308a1 | |||
| ae43464740 | |||
| f19d3fe8e9 | |||
| 0819598b00 | |||
| 1aa415ffb1 | |||
| ec94195b80 | |||
| 4ecdd45d24 | |||
| f91e71cc68 | |||
| ce15d773d4 | |||
| 516525a103 | |||
| c3f268b01c | |||
| 53ddc450c8 | |||
| 5cc411022e | |||
| a3ec4b307b | |||
| 95bdbfe851 | |||
| 733510fb65 | |||
| af3e5bdd0d | |||
| 02764f12a6 | |||
| 453542f14d | |||
| b6932f6434 | |||
| c44ee37cbd | |||
| 961a1f73e3 | |||
| 20de3b007b | |||
| e8054a9595 | |||
| e9ec9be146 | |||
| ee5ba259d1 | |||
| 65d6748d9e | |||
| 75fa9c0b39 | |||
| 3cef69c576 | |||
| f1058efc81 | |||
| 50870dd3de | |||
| 9aa4b9c2a3 | |||
| aa780a5271 | |||
| dccb80dd50 | |||
| 3449b47dc5 | |||
| 9356635e76 | |||
| 6ba69f60ec | |||
| 0814b140b1 | |||
| 3879202d68 | |||
| 99e080ec38 | |||
| 52d332b044 | |||
| f68ff799eb | |||
| 00dc345a83 | |||
| ac302efb91 | |||
| d73a8ae70f | |||
| c15f5068ca | |||
| 7ce70e6914 | |||
| 76950e5247 | |||
| a3ff74c872 | |||
| 51ac1ce966 | |||
| fe191124a9 | |||
| 5d9bee34f9 | |||
| 2f89546333 | |||
| 1bb7529ac2 | |||
| 99dd039d74 | |||
| f0db50a57f | |||
| a3753ba10d | |||
| eaf03fa830 | |||
| 71fc26403f | |||
| a2a93b0a8f | |||
| ac19d8eb3a | |||
| b5b29b22c0 | |||
| c6769b6d56 | |||
| 7cdd319b01 | |||
| 3ea20e60dc | |||
| 873ee14b56 | |||
| 47b6ea314d | |||
| 45c30d84b6 | |||
| ec35bb729c | |||
| f66787d345 | |||
| 79b16c6e5e | |||
| c09fe0346d | |||
| 7ffe708297 | |||
| e5c9396a02 | |||
| 6f08086992 | |||
| ab79e3d1a5 | |||
| a38a41df39 | |||
| db13758b88 | |||
| ae1156ef2a | |||
| aa464dc041 | |||
| 372ded7f69 | |||
| 79e477823f | |||
| 2ccab79595 | |||
| 458b1fda34 | |||
| 5ed5acb910 | |||
| 16cbc7a930 | |||
| 68c0d66d4d | |||
| ba944121e2 | |||
| 6f024dfd53 | |||
| 910df0f871 | |||
| 31ae0693d8 | |||
| 4410505b42 | |||
| 5999a89190 | |||
| 7bd9ae4afb | |||
| 554dffb35f | |||
| 6e288d5274 | |||
| 46a7fe2417 | |||
| 045121959e | |||
| d837407ae0 | |||
| f3e33608a5 | |||
| d3af86c867 | |||
| 18f36c70ec | |||
| 6b4a22b5e9 | |||
| 4edb236c49 | |||
| f085ce3265 | |||
| 6e629b0b66 | |||
| 13b34510b6 | |||
| f5ce1a7626 | |||
| 30f4512477 | |||
| 0045969e41 | |||
| b06958917c | |||
| cc39b2be23 | |||
| e0bd87de8f | |||
| 3faf444010 | |||
| 5b41bb29d7 | |||
| 1c058d94b9 | |||
| b15311eb6f | |||
| 98f1672022 | |||
| cbaa9ef0d6 | |||
| ac3358d73a | |||
| eac75d405b | |||
| 595af5a036 | |||
| 33629ff60f | |||
| 43956940ea | |||
| 2d582d142c | |||
| d2b0aae5e1 | |||
| 8fe79605fd | |||
| 7ae349a324 | |||
| 24f1698758 | |||
| 649f09c4cf | |||
| e3bacdbaad | |||
| 3bc20fe48c | |||
| 7a7ec3ccd9 | |||
| 634605f79e | |||
| cf27b297ca | |||
| bd5cf1dd8f | |||
| f78573466d | |||
| 41fba53525 | |||
| a23a6bf06b | |||
| cbc5d2bf30 | |||
| c58b0d981e | |||
| 3fb241210a | |||
| 9463930faf | |||
| 9e52f6b986 | |||
| 7ecaa736e7 | |||
| 7fdc2ba3d4 | |||
| 514d0e29c8 | |||
| 47a5cde6ac | |||
| c6e16ec711 | |||
| 3dfadef522 | |||
| e35c534890 | |||
| 2789d15114 | |||
| a47bc9a056 | |||
| 925adad3e0 | |||
| 286e14667f | |||
| 1795bef7c7 | |||
| d50d11c56c | |||
| bada03d746 | |||
| 2f1bff1690 | |||
| 60a3bd625f | |||
| 0077298904 | |||
| b3745ce8c2 | |||
| 933ae708c5 | |||
| e588252a42 | |||
| 7de7d81ee5 | |||
| 9d0aa058c9 | |||
| 5302adb323 | |||
| c5dd6fefd4 | |||
| 13a9a0c1a4 | |||
| 9da5ba1f57 | |||
| 8c8406462b | |||
| 18aef7c075 | |||
| cd83ff5d4c | |||
| 22349b9f7d | |||
| d54ca4167c | |||
| 670832e2a2 | |||
| 6ff5c4cd49 | |||
| 402f832984 | |||
| d768242152 | |||
| 84cf741861 | |||
| 8fc8b3eebe | |||
| 5709ac5c42 | |||
| 4121c1db15 | |||
| 0081afeaa7 | |||
| df2258f18d | |||
| 8498cf60b2 | |||
| 3943086656 | |||
| 35ab85884b | |||
| f141ac2d70 | |||
| e0f859e8fe | |||
| 7da1e8a0d8 | |||
| 8b0a063ba9 | |||
| 80b1cc31b8 | |||
| c49b88b93b | |||
| dfc147d24f | |||
| 859ce02c98 | |||
| aa3ec219e1 | |||
| a9f108bd78 | |||
| 02477323b9 | |||
| d9655621b3 | |||
| 1a4cb3b29c | |||
| ff02eeafd8 | |||
| bd28de1b4d | |||
| 57d094e3e3 | |||
| 65d61a4bbb |
@@ -1,6 +1,216 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 2.4.12:
|
||||
- avcodec/ffv1dec: Clear quant_table_count if its invalid
|
||||
- avcodec/ffv1dec: Print an error if the quant table count is invalid
|
||||
- avcodec/hevc: Check max ctb addresses for WPP
|
||||
- avcodec/vp3: ensure header is parsed successfully before tables
|
||||
- avcodec/jpeg2000dec: Check bpno in decode_cblk()
|
||||
- avcodec/pgssubdec: Fix left shift of 255 by 24 places cannot be represented in type int
|
||||
- swscale/utils: Fix for runtime error: left shift of negative value -1
|
||||
- avcodec/hevc: Fix integer overflow of entry_point_offset
|
||||
- avcodec/dirac_parser: Check that there is a previous PU before accessing it
|
||||
- avcodec/dirac_parser: Add basic validity checks for next_pu_offset and prev_pu_offset
|
||||
- avcodec/dirac_parser: Fix potential overflows in pointer checks
|
||||
- avcodec/wmaprodec: Check bits per sample to be within the range not causing integer overflows
|
||||
- avcodec/wmaprodec: Fix overflow of cutoff
|
||||
- avformat/smacker: fix integer overflow with pts_inc
|
||||
- avcodec/vp3: Fix "runtime error: left shift of negative value"
|
||||
- mpegencts: Fix overflow in cbr mode period calculations
|
||||
- avutil/timecode: Fix fps check
|
||||
- avutil/mathematics: return INT64_MIN (=AV_NOPTS_VALUE) from av_rescale_rnd() for overflows
|
||||
- avcodec/apedec: Check length in long_filter_high_3800()
|
||||
- avcodec/vp3: always set pix_fmt in theora_decode_header()
|
||||
- avcodec/mpeg4videodec: Check available data before reading custom matrix
|
||||
- avutil/mathematics: Do not treat INT64_MIN as positive in av_rescale_rnd
|
||||
- avutil/integer: Fix av_mod_i() with negative dividend
|
||||
- avformat/dump: Fix integer overflow in av_dump_format()
|
||||
- avcodec/utils: Clear dimensions in ff_get_buffer() on failure
|
||||
- avcodec/utils: Use 64bit for aspect ratio calculation in avcodec_string()
|
||||
- avcodec/vp3: Clear context on reinitialization failure
|
||||
- avcodec/hevc: allocate entries unconditionally
|
||||
- avcodec/hevc_cabac: Fix multiple integer overflows
|
||||
- avcodec/jpeg2000dwt: Check ndeclevels before calling dwt_encode*()
|
||||
- avcodec/jpeg2000dwt: Check ndeclevels before calling dwt_decode*()
|
||||
- avcodec/hevc: Check entry_point_offsets
|
||||
- avcodec/cabac: Check initial cabac decoder state
|
||||
- avcodec/cabac_functions: Fix "left shift of negative value -31767"
|
||||
- avcodec/h264_slice: Limit max_contexts when slice_context_count is initialized
|
||||
- avcodec/vp8: Do not use num_coeff_partitions in thread/buffer setup
|
||||
- rtmpcrypt: Do the xtea decryption in little endian mode
|
||||
- avformat/matroskadec: Check subtitle stream before dereferencing
|
||||
- avformat/utils: Do not init parser if probing is unfinished
|
||||
- avcodec/jpeg2000dec: Fix potential integer overflow with tile dimensions
|
||||
- avcodec/jpeg2000dec: Check SIZ dimensions to be within the supported range
|
||||
- avcodec/jpeg2000: Check comp coords to be within the supported size
|
||||
- avcodec/jpeg2000: Use av_image_check_size() in ff_jpeg2000_init_component()
|
||||
- avcodec/wmaprodec: Check for overread in decode_packet()
|
||||
- avcodec/smacker: Check that the data size is a multiple of a sample vector
|
||||
- avcodec/takdec: Skip last p2 sample (which is unused)
|
||||
- avcodec/dxtory: Fix input size check in dxtory_decode_v1_410()
|
||||
- avcodec/dxtory: Fix input size check in dxtory_decode_v1_420()
|
||||
- avcodec/error_resilience: avoid accessing previous or next frames tables beyond height
|
||||
- avcodec/dpx: Move need_align to act per line
|
||||
- avcodec/flashsv: Check size before updating it
|
||||
- avcodec/ivi: Check image dimensions
|
||||
- avcodec/utils: Better check for channels in av_get_audio_frame_duration()
|
||||
- avcodec/jpeg2000dec: Check for duplicate SIZ marker
|
||||
- avcodec/jpeg2000dec: Clip all tile coordinates
|
||||
- avcodec/microdvddec: Check for string end in 'P' case
|
||||
- avcodec/dirac_parser: Fix undefined memcpy() use
|
||||
- avformat/xmv: Discard remainder of packet on error
|
||||
- avformat/xmv: factor return check out of if/else
|
||||
- libavutil/channel_layout: Check strtol*() for failure
|
||||
- avcodec/ffv1dec: Check for 0 quant tables
|
||||
- avcodec/mjpegdec: Reinitialize IDCT on BPP changes
|
||||
- avcodec/mjpegdec: Check index in ljpeg_decode_yuv_scan() before using it
|
||||
- avutil/file_open: avoid file handle inheritance on Windows
|
||||
- avcodec/ffv1: Initialize vlc_state on allocation
|
||||
- avcodec/ffv1dec: update progress in case of broken pointer chains
|
||||
- avcodec/ffv1dec: Clear slice coordinates if they are invalid or slice header decoding fails for other reasons
|
||||
- avformat/httpauth: Add space after commas in HTTP/RTSP auth header
|
||||
- avcodec/x86/sbrdsp: Fix using uninitialized upper 32bit of noise
|
||||
- avcodec/ffv1dec: Fix off by 1 error in quant_table_count check
|
||||
- avcodec/ffv1dec: Explicitly check read_quant_table() return value
|
||||
- avcodec/rangecoder: Check e
|
||||
- lavf/webvttenc: Require webvtt file to contain exactly one WebVTT stream.
|
||||
- avcodec/mjpegdec: Fix decoding RGBA RCT LJPEG
|
||||
- avfilter/af_asyncts: use llabs for int64_t
|
||||
- avcodec/g2meet: Also clear tile dimensions on header_fail
|
||||
- avcodec/g2meet: Fix potential overflow in tile dimensions check
|
||||
- avcodec/svq1dec: Check init_get_bits8() for failure
|
||||
- avcodec/tta: Check init_get_bits8() for failure
|
||||
- swresample/swresample: Fix integer overflow in seed calculation
|
||||
- avformat/mov: Fix integer overflow in FFABS
|
||||
- avutil/common: Add FFNABS()
|
||||
- avutil/common: Document FFABS() corner case
|
||||
- avformat/dump: Fix integer overflow in aspect ratio calculation
|
||||
- avcodec/truemotion1: Check for even width
|
||||
- avcodec/libopusenc: Fix infinite loop on flushing after 0 input
|
||||
- doc/filters/drawtext: fix centering example
|
||||
- avcodec: avoid division by zero in avcodec_string
|
||||
- mpegvideo: clear overread in clear_context
|
||||
- dvdsubdec: validate offset2 similar to offset1
|
||||
- avcodec/takdec: Use memove, avoid undefined memcpy() use
|
||||
- jvdec: avoid unsigned overflow in comparison
|
||||
- avcodec/mpeg12dec: Do not call show_bits() with invalid bits
|
||||
- opusdec: Don't run vector_fmul_scalar on zero length arrays
|
||||
- avcodec/opusdec: Fix extra samples read index
|
||||
- riffdec: prevent negative bit rate
|
||||
- Merge commit 'd80811c94e068085aab797f9ba35790529126f85'
|
||||
- imc: use correct position for flcoeffs2 calculation
|
||||
- snow: remove an obsolete av_assert2
|
||||
- wavpack: limit extra_bits to 32 and use get_bits_long
|
||||
- huffyuvdec: validate image size
|
||||
- wavpack: use get_bits_long to read up to 32 bits
|
||||
- nutdec: check maxpos in read_sm_data before returning success
|
||||
- s302m: fix arithmetic exception
|
||||
- mpegaudiodec: copy AVFloatDSPContext from first context to all contexts
|
||||
- vc1dec: use get_bits_long and limit the read bits to 32
|
||||
- avcodec/s302m: Only set the sample rate when some data is output
|
||||
- avidec: check for valid bit_rate range
|
||||
- vp9: add support for resolution changes in inter frames.
|
||||
- vp9: avoid infinite loop with broken files
|
||||
- videodsp: don't overread edges in vfix3 emu_edge.
|
||||
- avformat/oggenc: Check segments_count for headers too
|
||||
- avformat/avidec: Workaround broken initial frame
|
||||
- hevc: properly handle no_rasl_output_flag when removing pictures from the DPB
|
||||
- hevc: fix wpp threading deadlock.
|
||||
- avcodec/ffv1: seperate slice_count from max_slice_count
|
||||
- lavf/img2dec: Fix memory leak
|
||||
- avcodec/mp3: fix skipping zeros
|
||||
- doc: mention libavcodec can decode Opus natively
|
||||
|
||||
|
||||
version 2.4.11:
|
||||
- avformat/hevc: Check num_long_term_ref_pics_sps to avoid potentially long loops
|
||||
- avformat/hevc: Fix parsing errors
|
||||
- ffmpeg: Use correct codec_id for av_parser_change() check
|
||||
- ffmpeg: Check av_parser_change() for failure
|
||||
- avcodec/h264_mp4toannexb_bsf: Reorder operations in nal_size check
|
||||
- ffmpeg: Check for RAWVIDEO and do not relay only on AVFMT_RAWPICTURE
|
||||
- ffmpeg: check avpicture_fill() return value
|
||||
- avformat/mux: Update sidedata in ff_write_chained()
|
||||
- avcodec/flashsvenc: Correct max dimension in error message
|
||||
- avcodec/svq1enc: Check dimensions
|
||||
- avcodec/dcaenc: clear bitstream end
|
||||
- libavcodec/aacdec_template: Use init_get_bits8() in aac_decode_frame()
|
||||
- rawdec: fix mjpeg probing buffer size check
|
||||
- rawdec: fix mjpeg probing
|
||||
- avcodec/vp8: Check buffer size in vp8_decode_frame_header()
|
||||
- avcodec/vp8: Fix null pointer dereference in ff_vp8_decode_free()
|
||||
- avcodec/diracdec: Check for hpel_base allocation failure
|
||||
- avcodec/rv34: Clear pointers in ff_rv34_decode_init_thread_copy()
|
||||
- avfilter/af_aresample: Check ff_all_* for allocation failures
|
||||
- avcodec/pthread_frame: clear priv_data, avoid stale pointer in error case
|
||||
- swscale/utils: Clear pix buffers
|
||||
- avutil/fifo: Fix the case where func() returns less bytes than requested in av_fifo_generic_write()
|
||||
- avformat/mov: Fix deallocation when MOVStreamContext failed to allocate
|
||||
- ffmpeg: Fix cleanup with ost = NULL
|
||||
- avcodec/pthread_frame: check avctx on deallocation
|
||||
- avcodec/sanm: Reset sizes in destroy_buffers()
|
||||
- avcodec/alac: Clear pointers in allocate_buffers()
|
||||
- bytestream2: set the reader to the end when reading more than available
|
||||
- avcodec/utils: use a minimum 32pixel width in avcodec_align_dimensions2() for H.264
|
||||
- avcodec/mpegvideo: Clear pointers in ff_mpv_common_init()
|
||||
- oggparsedirac: check return value of init_get_bits
|
||||
- wmalosslessdec: reset frame->nb_samples on packet loss
|
||||
- wmalosslessdec: avoid reading 0 bits with get_bits
|
||||
- avcodec/rawenc: Use ff_alloc_packet() instead of ff_alloc_packet2()
|
||||
- avcodec/aacsbr: Assert that bs_num_env is positive
|
||||
- avcodec/aacsbr: check that the element type matches before applying SBR
|
||||
- avcodec/h264_slice: Use w/h from the AVFrame instead of mb_w/h
|
||||
- vp9/update_prob: prevent out of bounds table read
|
||||
- avfilter/vf_transpose: Fix rounding error
|
||||
- avcodec/pngdec: Only allow one IHDR chunk
|
||||
- wmavoice: limit wmavoice_decode_packet return value to packet size
|
||||
- swscale/swscale_unscaled: Fix rounding difference with RGBA output between little and big endian
|
||||
- ffmpeg: Do not use the data/size of a bitstream filter after failure
|
||||
- swscale/x86/rgb2rgb_template: fix signedness of v in shuffle_bytes_2103_{mmx,mmxext}
|
||||
- swscale/x86/rgb2rgb_template: add missing xmm clobbers
|
||||
- vda: unlock the pixel buffer base address.
|
||||
- swscale/rgb2rgb_template: Fix signedness of v in shuffle_bytes_2103_c()
|
||||
- swscale/rgb2rgb_template: Implement shuffle_bytes_0321_c and fix shuffle_bytes_2103_c on BE
|
||||
- swscale/rgb2rgb_template: Disable shuffle_bytes_2103_c on big endian
|
||||
- swr: Remember previously set int_sample_format from user
|
||||
- matroskadec: check audio sample rate
|
||||
- matroskadec: validate audio channels and bitdepth
|
||||
- avcodec/dpxenc: implement write16/32 as functions
|
||||
- postproc: fix unaligned access
|
||||
- avio: fix potential crashes when combining ffio_ensure_seekback + crc
|
||||
- h264: er: Copy from the previous reference only if compatible
|
||||
- sonic: set avctx->channels in sonic_decode_init
|
||||
- vp8: change mv_{min,max}.{x,y} type to int
|
||||
- vp9: change type of tile_size from unsigned to int64_t
|
||||
- arm: only enable setend on ARMv6
|
||||
- libopenjpegdec: check existence of image component data
|
||||
- mov: abort on EOF in ff_mov_read_chan
|
||||
- ffmpeg_opt: Check for localtime() failure
|
||||
- avformat: Fix bug in parse_rps for HEVC.
|
||||
- takdec: ensure chan2 is a valid channel index
|
||||
- avcodec/h264_slice: Use AVFrame diemensions for grayscale handling
|
||||
- avdevice/lavfi: do not rescale AV_NOPTS_VALUE in lavfi_read_packet()
|
||||
- libavutil/channel_layout: Correctly return layout when channel specification ends with a trailing 'c'.
|
||||
- avcodec/jpeg2000dec: Check that coords match before applying ICT
|
||||
- avformat/ffmdec: Check ffio_set_buf_size() return value
|
||||
- avcodec/adpcm: Check for overreads
|
||||
- avcodec/alsdec: Check for overread
|
||||
- avcodec/atrac3plusdec: consume only as many bytes as available
|
||||
- swresample/swresample: Cleanup on init failure.
|
||||
- Revert "avformat/rtpenc: check av_packet_get_side_data() return, fix null ptr dereference"
|
||||
- avformat/mxfenc: Accept MXF D-10 with 49.999840 Mbit/sec
|
||||
- swresample/dither: check memory allocation
|
||||
- opusdec: properly handle mismatching configurations in multichannel streams
|
||||
- MAINTAINERS: Remove myself as leader
|
||||
- h263: Always check both dimensions
|
||||
- avformat/swfdec: Do not error out on pixel format changes
|
||||
- avcodec/exr: fix crash caused by merge
|
||||
- avcodec/x86/h264_weight: handle weight1=128
|
||||
- avcodec/hevc_ps: Only discard overread VPS if a previous is available
|
||||
- avformat/mov: Mark avio context of decompressed atoms as seekable
|
||||
_ avfilter/x86/vf_hqdn3d: Fix register types
|
||||
|
||||
version 2.4.10:
|
||||
- diracdec: check if reference could not be allocated
|
||||
- diracdec: avoid overflow of bytes*8 in decode_lowdelay
|
||||
|
||||
@@ -14,7 +14,6 @@ patches and related discussions.
|
||||
Project Leader
|
||||
==============
|
||||
|
||||
Michael Niedermayer
|
||||
final design decisions
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.4.10
|
||||
PROJECT_NUMBER = 2.4.12
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
+1
-1
@@ -4146,7 +4146,7 @@ within the parameter list.
|
||||
@item
|
||||
Show the text at the center of the video frame:
|
||||
@example
|
||||
drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
|
||||
drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
|
||||
@end example
|
||||
|
||||
@item
|
||||
|
||||
+2
-2
@@ -935,8 +935,8 @@ following image formats are supported:
|
||||
@item Musepack SV8 @tab @tab X
|
||||
@item Nellymoser Asao @tab X @tab X
|
||||
@item On2 AVC (Audio for Video Codec) @tab @tab X
|
||||
@item Opus @tab E @tab E
|
||||
@tab supported through external library libopus
|
||||
@item Opus @tab E @tab X
|
||||
@tab encoding supported through external library libopus
|
||||
@item PCM A-law @tab X @tab X
|
||||
@item PCM mu-law @tab X @tab X
|
||||
@item PCM signed 8-bit planar @tab X @tab X
|
||||
|
||||
@@ -466,7 +466,12 @@ static void ffmpeg_cleanup(int ret)
|
||||
}
|
||||
for (i = 0; i < nb_output_streams; i++) {
|
||||
OutputStream *ost = output_streams[i];
|
||||
AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
|
||||
AVBitStreamFilterContext *bsfc;
|
||||
|
||||
if (!ost)
|
||||
continue;
|
||||
|
||||
bsfc = ost->bitstream_filters;
|
||||
while (bsfc) {
|
||||
AVBitStreamFilterContext *next = bsfc->next;
|
||||
av_bitstream_filter_close(bsfc);
|
||||
@@ -645,6 +650,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
|
||||
if (!new_pkt.buf)
|
||||
exit_program(1);
|
||||
} else if (a < 0) {
|
||||
new_pkt = *pkt;
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open bitstream filter %s for stream %d with codec %s",
|
||||
bsfc->filter->name, pkt->stream_index,
|
||||
avctx->codec ? avctx->codec->name : "copy");
|
||||
@@ -1681,17 +1687,21 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
||||
|
||||
opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);
|
||||
opkt.flags = pkt->flags;
|
||||
|
||||
// FIXME remove the following 2 lines they shall be replaced by the bitstream filters
|
||||
if ( ost->enc_ctx->codec_id != AV_CODEC_ID_H264
|
||||
&& ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG1VIDEO
|
||||
&& ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG2VIDEO
|
||||
&& ost->enc_ctx->codec_id != AV_CODEC_ID_VC1
|
||||
if ( ost->st->codec->codec_id != AV_CODEC_ID_H264
|
||||
&& ost->st->codec->codec_id != AV_CODEC_ID_MPEG1VIDEO
|
||||
&& ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO
|
||||
&& ost->st->codec->codec_id != AV_CODEC_ID_VC1
|
||||
) {
|
||||
if (av_parser_change(ost->parser, ost->st->codec,
|
||||
int ret = av_parser_change(ost->parser, ost->st->codec,
|
||||
&opkt.data, &opkt.size,
|
||||
pkt->data, pkt->size,
|
||||
pkt->flags & AV_PKT_FLAG_KEY)) {
|
||||
pkt->flags & AV_PKT_FLAG_KEY);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_FATAL, "av_parser_change failed\n");
|
||||
exit_program(1);
|
||||
}
|
||||
if (ret) {
|
||||
opkt.buf = av_buffer_create(opkt.data, opkt.size, av_buffer_default_free, NULL, 0);
|
||||
if (!opkt.buf)
|
||||
exit_program(1);
|
||||
@@ -1702,9 +1712,15 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
||||
}
|
||||
av_copy_packet_side_data(&opkt, pkt);
|
||||
|
||||
if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) {
|
||||
if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
ost->st->codec->codec_id == AV_CODEC_ID_RAWVIDEO &&
|
||||
(of->ctx->oformat->flags & AVFMT_RAWPICTURE)) {
|
||||
/* store AVPicture in AVPacket, as expected by the output format */
|
||||
avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
|
||||
int ret = avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_FATAL, "avpicture_fill failed\n");
|
||||
exit_program(1);
|
||||
}
|
||||
opkt.data = (uint8_t *)&pict;
|
||||
opkt.size = sizeof(AVPicture);
|
||||
opkt.flags |= AV_PKT_FLAG_KEY;
|
||||
|
||||
@@ -2321,6 +2321,9 @@ static int opt_vstats(void *optctx, const char *opt, const char *arg)
|
||||
time_t today2 = time(NULL);
|
||||
struct tm *today = localtime(&today2);
|
||||
|
||||
if (!today)
|
||||
return AVERROR(errno);
|
||||
|
||||
snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
|
||||
today->tm_sec);
|
||||
return opt_vstats_file(NULL, opt, filename);
|
||||
|
||||
@@ -77,6 +77,8 @@ static int vda_retrieve_data(AVCodecContext *s, AVFrame *frame)
|
||||
frame->width, frame->height);
|
||||
|
||||
ret = av_frame_copy_props(vda->tmp_frame, frame);
|
||||
CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
+1
-1
@@ -3096,7 +3096,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (INT_MAX / 8 <= buf_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((err = init_get_bits(&gb, buf, buf_size * 8)) < 0)
|
||||
if ((err = init_get_bits8(&gb, buf, buf_size)) < 0)
|
||||
return err;
|
||||
|
||||
switch (ac->oc[1].m4ac.object_type) {
|
||||
|
||||
@@ -1018,6 +1018,8 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr,
|
||||
{
|
||||
unsigned int cnt = get_bits_count(gb);
|
||||
|
||||
sbr->id_aac = id_aac;
|
||||
|
||||
if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) {
|
||||
if (read_sbr_single_channel_element(ac, sbr, gb)) {
|
||||
sbr_turnoff(sbr);
|
||||
@@ -1688,6 +1690,12 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
|
||||
int nch = (id_aac == TYPE_CPE) ? 2 : 1;
|
||||
int err;
|
||||
|
||||
if (id_aac != sbr->id_aac) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR,
|
||||
"element type mismatch %d != %d\n", id_aac, sbr->id_aac);
|
||||
sbr_turnoff(sbr);
|
||||
}
|
||||
|
||||
if (!sbr->kx_and_m_pushed) {
|
||||
sbr->kx[0] = sbr->kx[1];
|
||||
sbr->m[0] = sbr->m[1];
|
||||
@@ -1711,6 +1719,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
|
||||
sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1,
|
||||
(const float (*)[40][2]) sbr->X_low, sbr->k[0]);
|
||||
sbr_chirp(sbr, &sbr->data[ch]);
|
||||
av_assert0(sbr->data[ch].bs_num_env > 0);
|
||||
sbr_hf_gen(ac, sbr, sbr->X_high,
|
||||
(const float (*)[40][2]) sbr->X_low,
|
||||
(const float (*)[2]) sbr->alpha0,
|
||||
|
||||
+12
-1
@@ -574,6 +574,8 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
case AV_CODEC_ID_ADPCM_IMA_DK4:
|
||||
if (avctx->block_align > 0)
|
||||
buf_size = FFMIN(buf_size, avctx->block_align);
|
||||
if (buf_size < 4 * ch)
|
||||
return AVERROR_INVALIDDATA;
|
||||
nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_IMA_RAD:
|
||||
@@ -587,13 +589,15 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
|
||||
if (avctx->block_align > 0)
|
||||
buf_size = FFMIN(buf_size, avctx->block_align);
|
||||
if (buf_size < 4 * ch)
|
||||
return AVERROR_INVALIDDATA;
|
||||
nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
|
||||
break;
|
||||
}
|
||||
case AV_CODEC_ID_ADPCM_MS:
|
||||
if (avctx->block_align > 0)
|
||||
buf_size = FFMIN(buf_size, avctx->block_align);
|
||||
nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
|
||||
nb_samples = (buf_size - 6 * ch) * 2 / ch;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_SBPRO_2:
|
||||
case AV_CODEC_ID_ADPCM_SBPRO_3:
|
||||
@@ -606,6 +610,8 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||
case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
|
||||
}
|
||||
if (!s->status[0].step_index) {
|
||||
if (buf_size < ch)
|
||||
return AVERROR_INVALIDDATA;
|
||||
nb_samples++;
|
||||
buf_size -= ch;
|
||||
}
|
||||
@@ -1524,6 +1530,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
|
||||
if (avpkt->size < bytestream2_tell(&gb)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Overread of %d < %d\n", avpkt->size, bytestream2_tell(&gb));
|
||||
return avpkt->size;
|
||||
}
|
||||
|
||||
return bytestream2_tell(&gb);
|
||||
}
|
||||
|
||||
|
||||
@@ -534,6 +534,12 @@ static int allocate_buffers(ALACContext *alac)
|
||||
int ch;
|
||||
int buf_size = alac->max_samples_per_frame * sizeof(int32_t);
|
||||
|
||||
for (ch = 0; ch < 2; ch++) {
|
||||
alac->predict_error_buffer[ch] = NULL;
|
||||
alac->output_samples_buffer[ch] = NULL;
|
||||
alac->extra_bits_buffer[ch] = NULL;
|
||||
}
|
||||
|
||||
for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
|
||||
FF_ALLOC_OR_GOTO(alac->avctx, alac->predict_error_buffer[ch],
|
||||
buf_size, buf_alloc_fail);
|
||||
|
||||
@@ -1493,6 +1493,11 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
||||
|
||||
// TODO: read_diff_float_data
|
||||
|
||||
if (get_bits_left(gb) < 0) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Overread %d\n", -get_bits_left(gb));
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -905,6 +905,9 @@ static void long_filter_high_3800(int32_t *buffer, int order, int shift,
|
||||
int i, j;
|
||||
int32_t dotprod, sign;
|
||||
|
||||
if (order >= length)
|
||||
return;
|
||||
|
||||
memset(coeffs, 0, order * sizeof(*coeffs));
|
||||
for (i = 0; i < order; i++)
|
||||
delay[i] = buffer[i];
|
||||
|
||||
@@ -381,7 +381,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
|
||||
return avctx->block_align;
|
||||
return FFMIN(avctx->block_align, avpkt->size);
|
||||
}
|
||||
|
||||
AVCodec ff_atrac3p_decoder = {
|
||||
|
||||
@@ -71,8 +71,10 @@ static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \
|
||||
} \
|
||||
static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \
|
||||
{ \
|
||||
if (g->buffer_end - g->buffer < bytes) \
|
||||
if (g->buffer_end - g->buffer < bytes) { \
|
||||
g->buffer = g->buffer_end; \
|
||||
return 0; \
|
||||
} \
|
||||
return bytestream2_get_ ## name ## u(g); \
|
||||
} \
|
||||
static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \
|
||||
|
||||
+4
-1
@@ -51,7 +51,7 @@ void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){
|
||||
*
|
||||
* @param buf_size size of buf in bits
|
||||
*/
|
||||
void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
|
||||
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
|
||||
c->bytestream_start=
|
||||
c->bytestream= buf;
|
||||
c->bytestream_end= buf + buf_size;
|
||||
@@ -64,6 +64,9 @@ void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
|
||||
#endif
|
||||
c->low+= ((*c->bytestream++)<<2) + 2;
|
||||
c->range= 0x1FE;
|
||||
if ((c->range<<(CABAC_BITS+1)) < c->low)
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ff_init_cabac_states(void)
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ typedef struct CABACContext{
|
||||
}CABACContext;
|
||||
|
||||
void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size);
|
||||
void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size);
|
||||
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size);
|
||||
void ff_init_cabac_states(void);
|
||||
|
||||
#endif /* AVCODEC_CABAC_H */
|
||||
|
||||
@@ -74,7 +74,8 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
|
||||
|
||||
#ifndef get_cabac_inline
|
||||
static void refill2(CABACContext *c){
|
||||
int i, x;
|
||||
int i;
|
||||
unsigned x;
|
||||
|
||||
x= c->low ^ (c->low-1);
|
||||
i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)];
|
||||
@@ -190,7 +191,8 @@ static av_unused const uint8_t* skip_bytes(CABACContext *c, int n) {
|
||||
#endif
|
||||
if ((int) (c->bytestream_end - ptr) < n)
|
||||
return NULL;
|
||||
ff_init_cabac_decoder(c, ptr + n, c->bytestream_end - ptr - n);
|
||||
if (ff_init_cabac_decoder(c, ptr + n, c->bytestream_end - ptr - n) < 0)
|
||||
return NULL;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -939,6 +939,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
for (i = 0; i < SUBFRAMES; i++)
|
||||
put_subframe(c, i);
|
||||
|
||||
|
||||
for (i = put_bits_count(&c->pb); i < 8*c->frame_size; i++)
|
||||
put_bits(&c->pb, 1, 0);
|
||||
|
||||
flush_put_bits(&c->pb);
|
||||
|
||||
avpkt->pts = frame->pts;
|
||||
|
||||
@@ -100,10 +100,12 @@ typedef struct DiracParseUnit {
|
||||
static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc,
|
||||
int offset)
|
||||
{
|
||||
uint8_t *start = pc->buffer + offset;
|
||||
uint8_t *end = pc->buffer + pc->index;
|
||||
if (start < pc->buffer || (start + 13 > end))
|
||||
int8_t *start;
|
||||
|
||||
if (offset < 0 || pc->index - 13 < offset)
|
||||
return 0;
|
||||
|
||||
start = pc->buffer + offset;
|
||||
pu->pu_type = start[4];
|
||||
|
||||
pu->next_pu_offset = AV_RB32(start + 5);
|
||||
@@ -112,6 +114,15 @@ static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc,
|
||||
if (pu->pu_type == 0x10 && pu->next_pu_offset == 0)
|
||||
pu->next_pu_offset = 13;
|
||||
|
||||
if (pu->next_pu_offset && pu->next_pu_offset < 13) {
|
||||
av_log(NULL, AV_LOG_ERROR, "next_pu_offset %d is invalid\n", pu->next_pu_offset);
|
||||
return 0;
|
||||
}
|
||||
if (pu->prev_pu_offset && pu->prev_pu_offset < 13) {
|
||||
av_log(NULL, AV_LOG_ERROR, "prev_pu_offset %d is invalid\n", pu->prev_pu_offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -123,7 +134,7 @@ static int dirac_combine_frame(AVCodecParserContext *s, AVCodecContext *avctx,
|
||||
DiracParseContext *pc = s->priv_data;
|
||||
|
||||
if (pc->overread_index) {
|
||||
memcpy(pc->buffer, pc->buffer + pc->overread_index,
|
||||
memmove(pc->buffer, pc->buffer + pc->overread_index,
|
||||
pc->index - pc->overread_index);
|
||||
pc->index -= pc->overread_index;
|
||||
pc->overread_index = 0;
|
||||
@@ -186,7 +197,7 @@ static int dirac_combine_frame(AVCodecParserContext *s, AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
/* Get the picture number to set the pts and dts*/
|
||||
if (parse_timing_info) {
|
||||
if (parse_timing_info && pu1.prev_pu_offset >= 13) {
|
||||
uint8_t *cur_pu = pc->buffer +
|
||||
pc->index - 13 - pu1.prev_pu_offset;
|
||||
int pts = AV_RB32(cur_pu + 13);
|
||||
|
||||
+12
-4
@@ -1561,7 +1561,7 @@ static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen,
|
||||
}
|
||||
}
|
||||
|
||||
static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
|
||||
static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
|
||||
{
|
||||
/* chroma allocates an edge of 8 when subsampled
|
||||
which for 4:2:2 means an h edge of 16 and v edge of 8
|
||||
@@ -1573,11 +1573,14 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
|
||||
|
||||
/* no need for hpel if we only have fpel vectors */
|
||||
if (!s->mv_precision)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < 4; i++) {
|
||||
if (!ref->hpel_base[plane][i])
|
||||
ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe->linesize[plane] + 32);
|
||||
if (!ref->hpel_base[plane][i]) {
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
/* we need to be 16-byte aligned even for chroma */
|
||||
ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe->linesize[plane] + 16;
|
||||
}
|
||||
@@ -1591,6 +1594,8 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
|
||||
s->mpvencdsp.draw_edges(ref->hpel[plane][3], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
||||
}
|
||||
ref->interpolated[plane] = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1640,8 +1645,11 @@ static int dirac_decode_frame_internal(DiracContext *s)
|
||||
|
||||
select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen);
|
||||
|
||||
for (i = 0; i < s->num_refs; i++)
|
||||
interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
|
||||
for (i = 0; i < s->num_refs; i++) {
|
||||
int ret = interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
memset(s->mctmp, 0, 4*p->yoffset*p->stride);
|
||||
|
||||
|
||||
+2
-2
@@ -334,11 +334,11 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
// For 12 bit, ignore alpha
|
||||
if (elements == 4)
|
||||
buf += 2;
|
||||
// Jump to next aligned position
|
||||
buf += need_align;
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
ptr[i] += p->linesize[i];
|
||||
// Jump to next aligned position
|
||||
buf += need_align;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
|
||||
+13
-10
@@ -75,17 +75,20 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define write16(p, value) \
|
||||
do { \
|
||||
if (s->big_endian) AV_WB16(p, value); \
|
||||
else AV_WL16(p, value); \
|
||||
} while(0)
|
||||
static av_always_inline void write16_internal(int big_endian, void *p, int value)
|
||||
{
|
||||
if (big_endian) AV_WB16(p, value);
|
||||
else AV_WL16(p, value);
|
||||
}
|
||||
|
||||
#define write32(p, value) \
|
||||
do { \
|
||||
if (s->big_endian) AV_WB32(p, value); \
|
||||
else AV_WL32(p, value); \
|
||||
} while(0)
|
||||
static av_always_inline void write32_internal(int big_endian, void *p, int value)
|
||||
{
|
||||
if (big_endian) AV_WB32(p, value);
|
||||
else AV_WL32(p, value);
|
||||
}
|
||||
|
||||
#define write16(p, value) write16_internal(s->big_endian, p, value)
|
||||
#define write32(p, value) write32_internal(s->big_endian, p, value)
|
||||
|
||||
static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst)
|
||||
{
|
||||
|
||||
@@ -343,7 +343,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
|
||||
}
|
||||
}
|
||||
the_end:
|
||||
if (offset1 >= 0) {
|
||||
if (offset1 >= 0 && offset2 >= 0) {
|
||||
int w, h;
|
||||
uint8_t *bitmap;
|
||||
|
||||
|
||||
+2
-2
@@ -65,7 +65,7 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic,
|
||||
uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V;
|
||||
int ret;
|
||||
|
||||
if (src_size < avctx->width * avctx->height * 9LL / 8) {
|
||||
if (src_size < FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) * 9LL / 8) {
|
||||
av_log(avctx, AV_LOG_ERROR, "packet too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic,
|
||||
uint8_t *Y1, *Y2, *U, *V;
|
||||
int ret;
|
||||
|
||||
if (src_size < avctx->width * avctx->height * 3LL / 2) {
|
||||
if (src_size < FFALIGN(avctx->width, 2) * FFALIGN(avctx->height, 2) * 3LL / 2) {
|
||||
av_log(avctx, AV_LOG_ERROR, "packet too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
@@ -377,14 +377,19 @@ static void guess_mv(ERContext *s)
|
||||
#define MV_UNCHANGED 1
|
||||
const int mb_stride = s->mb_stride;
|
||||
const int mb_width = s->mb_width;
|
||||
const int mb_height = s->mb_height;
|
||||
int mb_height = s->mb_height;
|
||||
int i, depth, num_avail;
|
||||
int mb_x, mb_y, mot_step, mot_stride;
|
||||
|
||||
if (s->last_pic.f && s->last_pic.f->data[0])
|
||||
mb_height = FFMIN(mb_height, (s->last_pic.f->height+15)>>4);
|
||||
if (s->next_pic.f && s->next_pic.f->data[0])
|
||||
mb_height = FFMIN(mb_height, (s->next_pic.f->height+15)>>4);
|
||||
|
||||
set_mv_strides(s, &mot_step, &mot_stride);
|
||||
|
||||
num_avail = 0;
|
||||
for (i = 0; i < s->mb_num; i++) {
|
||||
for (i = 0; i < mb_width * mb_height; i++) {
|
||||
const int mb_xy = s->mb_index2xy[i];
|
||||
int f = 0;
|
||||
int error = s->error_status_table[mb_xy];
|
||||
@@ -409,7 +414,7 @@ static void guess_mv(ERContext *s)
|
||||
|
||||
if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
|
||||
num_avail <= mb_width / 2) {
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
|
||||
for (mb_y = 0; mb_y < mb_height; mb_y++) {
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
||||
const int mb_xy = mb_x + mb_y * s->mb_stride;
|
||||
int mv_dir = (s->last_pic.f && s->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
|
||||
@@ -438,7 +443,7 @@ static void guess_mv(ERContext *s)
|
||||
int score_sum = 0;
|
||||
|
||||
changed = 0;
|
||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
|
||||
for (mb_y = 0; mb_y < mb_height; mb_y++) {
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
||||
const int mb_xy = mb_x + mb_y * s->mb_stride;
|
||||
int mv_predictor[8][2] = { { 0 } };
|
||||
@@ -671,7 +676,7 @@ skip_last_mv:
|
||||
if (none_left)
|
||||
return;
|
||||
|
||||
for (i = 0; i < s->mb_num; i++) {
|
||||
for (i = 0; i < mb_width * mb_height; i++) {
|
||||
int mb_xy = s->mb_index2xy[i];
|
||||
if (fixed[mb_xy])
|
||||
fixed[mb_xy] = MV_FROZEN;
|
||||
|
||||
+16
-15
@@ -1011,6 +1011,22 @@ static int decode_header(EXRContext *s)
|
||||
int current_channel_offset = 0;
|
||||
int magic_number, version, flags, i;
|
||||
|
||||
s->xmin = ~0;
|
||||
s->xmax = ~0;
|
||||
s->ymin = ~0;
|
||||
s->ymax = ~0;
|
||||
s->xdelta = ~0;
|
||||
s->ydelta = ~0;
|
||||
s->channel_offsets[0] = -1;
|
||||
s->channel_offsets[1] = -1;
|
||||
s->channel_offsets[2] = -1;
|
||||
s->channel_offsets[3] = -1;
|
||||
s->pixel_type = EXR_UNKNOWN;
|
||||
s->compression = EXR_UNKN;
|
||||
s->nb_channels = 0;
|
||||
s->w = 0;
|
||||
s->h = 0;
|
||||
|
||||
if (bytestream2_get_bytes_left(&s->gb) < 10) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -1351,21 +1367,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
float one_gamma = 1.0f / s->gamma;
|
||||
|
||||
s->avctx = avctx;
|
||||
s->xmin = ~0;
|
||||
s->xmax = ~0;
|
||||
s->ymin = ~0;
|
||||
s->ymax = ~0;
|
||||
s->xdelta = ~0;
|
||||
s->ydelta = ~0;
|
||||
s->channel_offsets[0] = -1;
|
||||
s->channel_offsets[1] = -1;
|
||||
s->channel_offsets[2] = -1;
|
||||
s->channel_offsets[3] = -1;
|
||||
s->pixel_type = EXR_UNKNOWN;
|
||||
s->compression = EXR_UNKN;
|
||||
s->nb_channels = 0;
|
||||
s->w = 0;
|
||||
s->h = 0;
|
||||
|
||||
if ( one_gamma > 0.9999f && one_gamma < 1.0001f ) {
|
||||
for ( i = 0; i < 65536; ++i ) {
|
||||
|
||||
+17
-12
@@ -66,7 +66,7 @@ av_cold int ffv1_common_init(AVCodecContext *avctx)
|
||||
|
||||
av_cold int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
|
||||
{
|
||||
int j;
|
||||
int j, i;
|
||||
|
||||
fs->plane_count = f->plane_count;
|
||||
fs->transparency = f->transparency;
|
||||
@@ -80,10 +80,15 @@ av_cold int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
|
||||
if (!p->state)
|
||||
return AVERROR(ENOMEM);
|
||||
} else {
|
||||
if (!p->vlc_state)
|
||||
p->vlc_state = av_malloc_array(p->context_count, sizeof(VlcState));
|
||||
if (!p->vlc_state)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!p->vlc_state) {
|
||||
p->vlc_state = av_mallocz_array(p->context_count, sizeof(VlcState));
|
||||
if (!p->vlc_state)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < p->context_count; i++) {
|
||||
p->vlc_state[i].error_sum = 4;
|
||||
p->vlc_state[i].count = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +106,7 @@ av_cold int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
|
||||
av_cold int ffv1_init_slices_state(FFV1Context *f)
|
||||
{
|
||||
int i, ret;
|
||||
for (i = 0; i < f->slice_count; i++) {
|
||||
for (i = 0; i < f->max_slice_count; i++) {
|
||||
FFV1Context *fs = f->slice_context[i];
|
||||
if ((ret = ffv1_init_slice_state(f, fs)) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -113,10 +118,10 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
|
||||
{
|
||||
int i;
|
||||
|
||||
f->slice_count = f->num_h_slices * f->num_v_slices;
|
||||
av_assert0(f->slice_count > 0);
|
||||
f->max_slice_count = f->num_h_slices * f->num_v_slices;
|
||||
av_assert0(f->max_slice_count > 0);
|
||||
|
||||
for (i = 0; i < f->slice_count; i++) {
|
||||
for (i = 0; i < f->max_slice_count; i++) {
|
||||
FFV1Context *fs = av_mallocz(sizeof(*fs));
|
||||
int sx = i % f->num_h_slices;
|
||||
int sy = i / f->num_h_slices;
|
||||
@@ -201,7 +206,7 @@ av_cold int ffv1_close(AVCodecContext *avctx)
|
||||
ff_thread_release_buffer(avctx, &s->last_picture);
|
||||
av_frame_free(&s->last_picture.f);
|
||||
|
||||
for (j = 0; j < s->slice_count; j++) {
|
||||
for (j = 0; j < s->max_slice_count; j++) {
|
||||
FFV1Context *fs = s->slice_context[j];
|
||||
for (i = 0; i < s->plane_count; i++) {
|
||||
PlaneContext *p = &fs->plane[i];
|
||||
@@ -215,14 +220,14 @@ av_cold int ffv1_close(AVCodecContext *avctx)
|
||||
av_freep(&avctx->stats_out);
|
||||
for (j = 0; j < s->quant_table_count; j++) {
|
||||
av_freep(&s->initial_states[j]);
|
||||
for (i = 0; i < s->slice_count; i++) {
|
||||
for (i = 0; i < s->max_slice_count; i++) {
|
||||
FFV1Context *sf = s->slice_context[i];
|
||||
av_freep(&sf->rc_stat2[j]);
|
||||
}
|
||||
av_freep(&s->rc_stat2[j]);
|
||||
}
|
||||
|
||||
for (i = 0; i < s->slice_count; i++)
|
||||
for (i = 0; i < s->max_slice_count; i++)
|
||||
av_freep(&s->slice_context[i]);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -117,6 +117,7 @@ typedef struct FFV1Context {
|
||||
|
||||
struct FFV1Context *slice_context[MAX_SLICES];
|
||||
int slice_count;
|
||||
int max_slice_count;
|
||||
int num_v_slices;
|
||||
int num_h_slices;
|
||||
int slice_width;
|
||||
|
||||
+20
-7
@@ -47,8 +47,11 @@ static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state,
|
||||
else {
|
||||
int i, e, a;
|
||||
e = 0;
|
||||
while (get_rac(c, state + 1 + FFMIN(e, 9))) // 1..10
|
||||
while (get_rac(c, state + 1 + FFMIN(e, 9))) { // 1..10
|
||||
e++;
|
||||
if (e > 31)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
a = 1;
|
||||
for (i = e - 1; i >= 0; i--)
|
||||
@@ -303,7 +306,7 @@ static int decode_slice_header(FFV1Context *f, FFV1Context *fs)
|
||||
for (i = 0; i < f->plane_count; i++) {
|
||||
PlaneContext * const p = &fs->plane[i];
|
||||
int idx = get_symbol(c, state, 0);
|
||||
if (idx > (unsigned)f->quant_table_count) {
|
||||
if (idx >= (unsigned)f->quant_table_count) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -406,6 +409,7 @@ static int decode_slice(AVCodecContext *c, void *arg)
|
||||
if (ffv1_init_slice_state(f, fs) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
if (decode_slice_header(f, fs) < 0) {
|
||||
fs->slice_x = fs->slice_y = fs->slice_height = fs->slice_width = 0;
|
||||
fs->slice_damaged = 1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -500,7 +504,10 @@ static int read_quant_tables(RangeCoder *c,
|
||||
int context_count = 1;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
context_count *= read_quant_table(c, quant_table[i], context_count);
|
||||
int ret = read_quant_table(c, quant_table[i], context_count);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
context_count *= ret;
|
||||
if (context_count > 32768U) {
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -560,8 +567,11 @@ static int read_extra_header(FFV1Context *f)
|
||||
}
|
||||
|
||||
f->quant_table_count = get_symbol(c, state, 0);
|
||||
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES)
|
||||
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);
|
||||
f->quant_table_count = 0;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (i = 0; i < f->quant_table_count; i++) {
|
||||
f->context_count[i] = read_quant_tables(c, f->quant_tables[i]);
|
||||
@@ -770,6 +780,7 @@ static int read_header(FFV1Context *f)
|
||||
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
f->slice_count = f->max_slice_count;
|
||||
} else if (f->version < 3) {
|
||||
f->slice_count = get_symbol(c, state, 0);
|
||||
} else {
|
||||
@@ -784,8 +795,8 @@ static int read_header(FFV1Context *f)
|
||||
p -= size + trailer;
|
||||
}
|
||||
}
|
||||
if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid\n", f->slice_count);
|
||||
if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0 || f->slice_count > f->max_slice_count) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid (max=%d)\n", f->slice_count, f->max_slice_count);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
@@ -927,6 +938,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
else v = buf_p - c->bytestream_start;
|
||||
if (buf_p - c->bytestream_start < v) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n");
|
||||
ff_thread_report_progress(&f->picture, INT_MAX, 0);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
buf_p -= v;
|
||||
@@ -1008,6 +1020,7 @@ static int init_thread_copy(AVCodecContext *avctx)
|
||||
f->picture.f = NULL;
|
||||
f->last_picture.f = NULL;
|
||||
f->sample_buffer = NULL;
|
||||
f->max_slice_count = 0;
|
||||
f->slice_count = 0;
|
||||
|
||||
for (i = 0; i < f->quant_table_count; i++) {
|
||||
@@ -1078,7 +1091,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
|
||||
av_assert0(!fdst->sample_buffer);
|
||||
}
|
||||
|
||||
av_assert1(fdst->slice_count == fsrc->slice_count);
|
||||
av_assert1(fdst->max_slice_count == fsrc->max_slice_count);
|
||||
|
||||
|
||||
ff_thread_release_buffer(dst, &fdst->picture);
|
||||
|
||||
@@ -961,6 +961,7 @@ slices_ok:
|
||||
|
||||
if ((ret = ffv1_init_slice_contexts(s)) < 0)
|
||||
return ret;
|
||||
s->slice_count = s->max_slice_count;
|
||||
if ((ret = ffv1_init_slices_state(s)) < 0)
|
||||
return ret;
|
||||
|
||||
@@ -970,7 +971,7 @@ slices_ok:
|
||||
if (!avctx->stats_out)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < s->quant_table_count; i++)
|
||||
for (j = 0; j < s->slice_count; j++) {
|
||||
for (j = 0; j < s->max_slice_count; j++) {
|
||||
FFV1Context *sf = s->slice_context[j];
|
||||
av_assert0(!sf->rc_stat2[i]);
|
||||
sf->rc_stat2[i] = av_mallocz(s->context_count[i] *
|
||||
@@ -1194,6 +1195,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
for (i = 0; i < f->quant_table_count; i++)
|
||||
memset(f->rc_stat2[i], 0, f->context_count[i] * sizeof(*f->rc_stat2[i]));
|
||||
|
||||
av_assert0(f->slice_count == f->max_slice_count);
|
||||
for (j = 0; j < f->slice_count; j++) {
|
||||
FFV1Context *fs = f->slice_context[j];
|
||||
for (i = 0; i < 256; i++) {
|
||||
|
||||
@@ -413,6 +413,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
|
||||
if (has_diff) {
|
||||
if (size < 3) {
|
||||
av_log(avctx, AV_LOG_ERROR, "size too small for diff\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (!s->keyframe) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Inter frame without keyframe\n");
|
||||
@@ -440,6 +444,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
||||
int row = get_bits(&gb, 8);
|
||||
av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_curr %dx%d\n",
|
||||
i, j, col, row);
|
||||
if (size < 3) {
|
||||
av_log(avctx, AV_LOG_ERROR, "size too small for zlibprime_curr\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
size -= 2;
|
||||
avpriv_request_sample(avctx, "zlibprime_curr");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
|
||||
@@ -111,7 +111,7 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx)
|
||||
|
||||
if (avctx->width > 4095 || avctx->height > 4095) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Input dimensions too large, input must be max 4096x4096 !\n");
|
||||
"Input dimensions too large, input must be max 4095x4095 !\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -738,7 +738,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
c->tile_height = bytestream2_get_be32(&bc);
|
||||
if (c->tile_width <= 0 || c->tile_height <= 0 ||
|
||||
((c->tile_width | c->tile_height) & 0xF) ||
|
||||
c->tile_width * 4LL * c->tile_height >= INT_MAX
|
||||
c->tile_width * (uint64_t)c->tile_height >= INT_MAX / 4
|
||||
) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Invalid tile dimensions %dx%d\n",
|
||||
@@ -869,6 +869,8 @@ header_fail:
|
||||
c->height = 0;
|
||||
c->tiles_x =
|
||||
c->tiles_y = 0;
|
||||
c->tile_width =
|
||||
c->tile_height = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1999,6 +1999,7 @@ decode_intra_mb:
|
||||
const int mb_size = ff_h264_mb_sizes[h->sps.chroma_format_idc] *
|
||||
h->sps.bit_depth_luma >> 3;
|
||||
const uint8_t *ptr;
|
||||
int ret;
|
||||
|
||||
// We assume these blocks are very rare so we do not optimize it.
|
||||
// FIXME The two following lines get the bitstream position in the cabac
|
||||
@@ -2015,7 +2016,9 @@ decode_intra_mb:
|
||||
h->intra_pcm_ptr = ptr;
|
||||
ptr += mb_size;
|
||||
|
||||
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
|
||||
ret = ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
// All blocks are present
|
||||
h->cbp_table[mb_xy] = 0xf7ef;
|
||||
|
||||
@@ -173,7 +173,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
||||
buf += ctx->length_size;
|
||||
unit_type = *buf & 0x1f;
|
||||
|
||||
if (buf + nal_size > buf_end || nal_size < 0)
|
||||
if (nal_size > buf_end - buf || nal_size < 0)
|
||||
goto fail;
|
||||
|
||||
if (unit_type == 7 || unit_type == 8)
|
||||
|
||||
+15
-8
@@ -278,11 +278,11 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
|
||||
av_pix_fmt_get_chroma_sub_sample(pic->f.format,
|
||||
&h_chroma_shift, &v_chroma_shift);
|
||||
|
||||
for(i=0; i<FF_CEIL_RSHIFT(h->avctx->height, v_chroma_shift); i++) {
|
||||
for(i=0; i<FF_CEIL_RSHIFT(pic->f.height, v_chroma_shift); i++) {
|
||||
memset(pic->f.data[1] + pic->f.linesize[1]*i,
|
||||
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||
0x80, FF_CEIL_RSHIFT(pic->f.width, h_chroma_shift));
|
||||
memset(pic->f.data[2] + pic->f.linesize[2]*i,
|
||||
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||
0x80, FF_CEIL_RSHIFT(pic->f.width, h_chroma_shift));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,6 +1211,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
|
||||
nb_slices = max_slices;
|
||||
}
|
||||
h->slice_context_count = nb_slices;
|
||||
h->max_contexts = FFMIN(h->max_contexts, nb_slices);
|
||||
|
||||
if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
|
||||
ret = ff_h264_context_init(h);
|
||||
@@ -1690,14 +1691,17 @@ int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
|
||||
* vectors. Given we are concealing a lost frame, this probably
|
||||
* is not noticeable by comparison, but it should be fixed. */
|
||||
if (h->short_ref_count) {
|
||||
if (prev) {
|
||||
if (prev &&
|
||||
h->short_ref[0]->f.width == prev->f.width &&
|
||||
h->short_ref[0]->f.height == prev->f.height &&
|
||||
h->short_ref[0]->f.format == prev->f.format) {
|
||||
av_image_copy(h->short_ref[0]->f.data,
|
||||
h->short_ref[0]->f.linesize,
|
||||
(const uint8_t **)prev->f.data,
|
||||
prev->f.linesize,
|
||||
h->avctx->pix_fmt,
|
||||
h->mb_width * 16,
|
||||
h->mb_height * 16);
|
||||
prev->f.format,
|
||||
prev->f.width,
|
||||
prev->f.height);
|
||||
h->short_ref[0]->poc = prev->poc + 2;
|
||||
}
|
||||
h->short_ref[0]->frame_num = h->prev_frame_num;
|
||||
@@ -2441,13 +2445,16 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
|
||||
}
|
||||
|
||||
if (h->pps.cabac) {
|
||||
int ret;
|
||||
/* realign */
|
||||
align_get_bits(&h->gb);
|
||||
|
||||
/* init cabac */
|
||||
ff_init_cabac_decoder(&h->cabac,
|
||||
ret = ff_init_cabac_decoder(&h->cabac,
|
||||
h->gb.buffer + get_bits_count(&h->gb) / 8,
|
||||
(get_bits_left(&h->gb) + 7) / 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ff_h264_init_cabac_states(h);
|
||||
|
||||
|
||||
+26
-6
@@ -696,7 +696,7 @@ static int hls_slice_header(HEVCContext *s)
|
||||
av_freep(&sh->entry_point_offset);
|
||||
av_freep(&sh->offset);
|
||||
av_freep(&sh->size);
|
||||
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
|
||||
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned));
|
||||
sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
|
||||
sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
|
||||
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
|
||||
@@ -769,6 +769,8 @@ static int hls_slice_header(HEVCContext *s)
|
||||
s->HEVClc->tu.cu_qp_offset_cb = 0;
|
||||
s->HEVClc->tu.cu_qp_offset_cr = 0;
|
||||
|
||||
s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == NAL_CRA_NUT && s->last_eos);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2368,6 +2370,8 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
|
||||
|
||||
if (more_data < 0) {
|
||||
s->tab_slice_address[ctb_addr_rs] = -1;
|
||||
avpriv_atomic_int_set(&s1->wpp_err, 1);
|
||||
ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP);
|
||||
return more_data;
|
||||
}
|
||||
|
||||
@@ -2405,15 +2409,22 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
|
||||
HEVCLocalContext *lc = s->HEVClc;
|
||||
int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
|
||||
int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
|
||||
int offset;
|
||||
int startheader, cmpt = 0;
|
||||
int64_t offset;
|
||||
int64_t startheader, cmpt = 0;
|
||||
int i, j, res = 0;
|
||||
|
||||
if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * s->sps->ctb_width >= s->sps->ctb_width * s->sps->ctb_height) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n",
|
||||
s->sh.slice_ctb_addr_rs, s->sh.num_entry_point_offsets,
|
||||
s->sps->ctb_width, s->sps->ctb_height
|
||||
);
|
||||
res = AVERROR_INVALIDDATA;
|
||||
goto error;
|
||||
}
|
||||
|
||||
ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
|
||||
|
||||
if (!s->sList[1]) {
|
||||
ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
|
||||
|
||||
|
||||
for (i = 1; i < s->threads_number; i++) {
|
||||
s->sList[i] = av_malloc(sizeof(HEVCContext));
|
||||
memcpy(s->sList[i], s, sizeof(HEVCContext));
|
||||
@@ -2446,6 +2457,11 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
|
||||
}
|
||||
if (s->sh.num_entry_point_offsets != 0) {
|
||||
offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt;
|
||||
if (length < offset) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");
|
||||
res = AVERROR_INVALIDDATA;
|
||||
goto error;
|
||||
}
|
||||
s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
|
||||
s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
|
||||
|
||||
@@ -2472,6 +2488,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
|
||||
|
||||
for (i = 0; i <= s->sh.num_entry_point_offsets; i++)
|
||||
res += ret[i];
|
||||
error:
|
||||
av_free(ret);
|
||||
av_free(arg);
|
||||
return res;
|
||||
@@ -3308,6 +3325,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
|
||||
s->pocTid0 = s0->pocTid0;
|
||||
s->max_ra = s0->max_ra;
|
||||
s->eos = s0->eos;
|
||||
s->no_rasl_output_flag = s0->no_rasl_output_flag;
|
||||
|
||||
s->is_nalff = s0->is_nalff;
|
||||
s->nal_length_size = s0->nal_length_size;
|
||||
@@ -3402,6 +3420,7 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
|
||||
|
||||
s->enable_parallel_tiles = 0;
|
||||
s->picture_struct = 0;
|
||||
s->eos = 1;
|
||||
|
||||
if(avctx->active_thread_type & FF_THREAD_SLICE)
|
||||
s->threads_number = avctx->thread_count;
|
||||
@@ -3443,6 +3462,7 @@ static void hevc_decode_flush(AVCodecContext *avctx)
|
||||
HEVCContext *s = avctx->priv_data;
|
||||
ff_hevc_flush_dpb(s);
|
||||
s->max_ra = INT_MAX;
|
||||
s->eos = 1;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(HEVCContext, x)
|
||||
|
||||
+2
-1
@@ -607,7 +607,7 @@ typedef struct SliceHeader {
|
||||
|
||||
unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
|
||||
|
||||
int *entry_point_offset;
|
||||
unsigned *entry_point_offset;
|
||||
int * offset;
|
||||
int * size;
|
||||
int num_entry_point_offsets;
|
||||
@@ -844,6 +844,7 @@ typedef struct HEVCContext {
|
||||
int bs_height;
|
||||
|
||||
int is_decoded;
|
||||
int no_rasl_output_flag;
|
||||
|
||||
HEVCPredContext hpc;
|
||||
HEVCDSPContext hevcdsp;
|
||||
|
||||
@@ -883,11 +883,13 @@ static av_always_inline int mvd_decode(HEVCContext *s)
|
||||
int k = 1;
|
||||
|
||||
while (k < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc)) {
|
||||
ret += 1 << k;
|
||||
ret += 1U << k;
|
||||
k++;
|
||||
}
|
||||
if (k == CABAC_MAX_BIN)
|
||||
if (k == CABAC_MAX_BIN) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", k);
|
||||
return 0;
|
||||
}
|
||||
while (k--)
|
||||
ret += get_cabac_bypass(&s->HEVClc->cc) << k;
|
||||
return get_cabac_bypass_sign(&s->HEVClc->cc, -ret);
|
||||
@@ -1025,8 +1027,10 @@ static av_always_inline int coeff_abs_level_remaining_decode(HEVCContext *s, int
|
||||
|
||||
while (prefix < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc))
|
||||
prefix++;
|
||||
if (prefix == CABAC_MAX_BIN)
|
||||
if (prefix == CABAC_MAX_BIN) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", prefix);
|
||||
return 0;
|
||||
}
|
||||
if (prefix < 3) {
|
||||
for (i = 0; i < rc_rice_param; i++)
|
||||
suffix = (suffix << 1) | get_cabac_bypass(&s->HEVClc->cc);
|
||||
|
||||
@@ -461,7 +461,8 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
|
||||
if (get_bits_left(gb) < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Overread VPS by %d bits\n", -get_bits_left(gb));
|
||||
goto err;
|
||||
if (s->vps_list[vps_id])
|
||||
goto err;
|
||||
}
|
||||
|
||||
av_buffer_unref(&s->vps_list[vps_id]);
|
||||
|
||||
@@ -158,7 +158,7 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
|
||||
int min_poc = INT_MAX;
|
||||
int i, min_idx, ret;
|
||||
|
||||
if (s->sh.no_output_of_prior_pics_flag == 1) {
|
||||
if (s->sh.no_output_of_prior_pics_flag == 1 && s->no_rasl_output_flag == 1) {
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
|
||||
HEVCFrame *frame = &s->DPB[i];
|
||||
if (!(frame->flags & HEVC_FRAME_FLAG_BUMPING) && frame->poc != s->poc &&
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "huffyuv.h"
|
||||
#include "huffyuvdsp.h"
|
||||
#include "thread.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
|
||||
#define classic_shift_luma_table_size 42
|
||||
@@ -277,6 +278,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
HYuvContext *s = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ff_huffyuvdsp_init(&s->hdsp);
|
||||
memset(s->vlc, 0, 4 * sizeof(VLC));
|
||||
|
||||
|
||||
+2
-2
@@ -420,7 +420,7 @@ static void imc_decode_level_coefficients_raw(IMCContext *q, int *levlCoeffBuf,
|
||||
|
||||
pos = q->coef0_pos;
|
||||
flcoeffs1[pos] = 20000.0 / pow (2, levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125
|
||||
flcoeffs2[pos] = log2f(flcoeffs1[0]);
|
||||
flcoeffs2[pos] = log2f(flcoeffs1[pos]);
|
||||
tmp = flcoeffs1[pos];
|
||||
tmp2 = flcoeffs2[pos];
|
||||
|
||||
@@ -1018,7 +1018,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
IMCContext *q = avctx->priv_data;
|
||||
|
||||
LOCAL_ALIGNED_16(uint16_t, buf16, [IMC_BLOCK_SIZE / 2 + FF_INPUT_BUFFER_PADDING_SIZE/2]);
|
||||
LOCAL_ALIGNED_16(uint16_t, buf16, [(IMC_BLOCK_SIZE + FF_INPUT_BUFFER_PADDING_SIZE) / 2]);
|
||||
|
||||
if (buf_size < IMC_BLOCK_SIZE * avctx->channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "frame too small!\n");
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "avcodec.h"
|
||||
@@ -872,7 +873,7 @@ end:
|
||||
/* most is hardcoded. should extend to handle all h263 streams */
|
||||
int ff_h263_decode_picture_header(MpegEncContext *s)
|
||||
{
|
||||
int format, width, height, i;
|
||||
int format, width, height, i, ret;
|
||||
uint32_t startcode;
|
||||
|
||||
align_get_bits(&s->gb);
|
||||
@@ -927,8 +928,6 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
|
||||
/* H.263v1 */
|
||||
width = ff_h263_format[format][0];
|
||||
height = ff_h263_format[format][1];
|
||||
if (!width)
|
||||
return -1;
|
||||
|
||||
s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
|
||||
|
||||
@@ -1084,10 +1083,9 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
|
||||
s->qscale = get_bits(&s->gb, 5);
|
||||
}
|
||||
|
||||
if (s->width == 0 || s->height == 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "dimensions 0\n");
|
||||
return -1;
|
||||
}
|
||||
if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0)
|
||||
return ret;
|
||||
|
||||
s->mb_width = (s->width + 15) / 16;
|
||||
s->mb_height = (s->height + 15) / 16;
|
||||
s->mb_num = s->mb_width * s->mb_height;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#define BITSTREAM_READER_LE
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/timer.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
@@ -310,7 +311,7 @@ av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg,
|
||||
|
||||
ivi_free_buffers(planes);
|
||||
|
||||
if (cfg->pic_width < 1 || cfg->pic_height < 1 ||
|
||||
if (av_image_check_size(cfg->pic_width, cfg->pic_height, 0, NULL) < 0 ||
|
||||
cfg->luma_bands < 1 || cfg->chroma_bands < 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
|
||||
+10
-1
@@ -28,6 +28,7 @@
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "avcodec.h"
|
||||
#include "jpeg2000.h"
|
||||
@@ -210,9 +211,17 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
|
||||
codsty->nreslevels2decode - 1,
|
||||
codsty->transform))
|
||||
return ret;
|
||||
// component size comp->coord is uint16_t so ir cannot overflow
|
||||
|
||||
if (av_image_check_size(comp->coord[0][1] - comp->coord[0][0],
|
||||
comp->coord[1][1] - comp->coord[1][0], 0, avctx))
|
||||
return AVERROR_INVALIDDATA;
|
||||
csize = (comp->coord[0][1] - comp->coord[0][0]) *
|
||||
(comp->coord[1][1] - comp->coord[1][0]);
|
||||
if (comp->coord[0][1] > 32768 ||
|
||||
comp->coord[1][1] > 32768) {
|
||||
av_log(avctx, AV_LOG_ERROR, "component size too large\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (codsty->transform == FF_DWT97) {
|
||||
comp->i_data = NULL;
|
||||
|
||||
@@ -250,6 +250,10 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
avpriv_request_sample(s->avctx, "Support for image offsets");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (s->width > 32768U || s->height > 32768U) {
|
||||
avpriv_request_sample(s->avctx, "Large Dimensions");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (ncomponents <= 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid number of components: %d\n",
|
||||
@@ -684,10 +688,10 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
|
||||
Jpeg2000QuantStyle *qntsty = tile->qntsty + compno;
|
||||
int ret; // global bandno
|
||||
|
||||
comp->coord_o[0][0] = FFMAX(tilex * s->tile_width + s->tile_offset_x, s->image_offset_x);
|
||||
comp->coord_o[0][1] = FFMIN((tilex + 1) * s->tile_width + s->tile_offset_x, s->width);
|
||||
comp->coord_o[1][0] = FFMAX(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y);
|
||||
comp->coord_o[1][1] = FFMIN((tiley + 1) * s->tile_height + s->tile_offset_y, s->height);
|
||||
comp->coord_o[0][0] = av_clip(tilex * (int64_t)s->tile_width + s->tile_offset_x, s->image_offset_x, s->width);
|
||||
comp->coord_o[0][1] = av_clip((tilex + 1) * (int64_t)s->tile_width + s->tile_offset_x, s->image_offset_x, s->width);
|
||||
comp->coord_o[1][0] = av_clip(tiley * (int64_t)s->tile_height + s->tile_offset_y, s->image_offset_y, s->height);
|
||||
comp->coord_o[1][1] = av_clip((tiley + 1) * (int64_t)s->tile_height + s->tile_offset_y, s->image_offset_y, s->height);
|
||||
|
||||
comp->coord[0][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], s->reduction_factor);
|
||||
comp->coord[0][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][1], s->reduction_factor);
|
||||
@@ -1075,6 +1079,10 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
|
||||
ff_mqc_initdec(&t1->mqc, cblk->data);
|
||||
|
||||
while (passno--) {
|
||||
if (bpno < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "bpno became negative\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
switch(pass_t) {
|
||||
case 0:
|
||||
decode_sigpass(t1, width, height, bpno + 1, bandpos,
|
||||
@@ -1162,11 +1170,16 @@ static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
|
||||
int32_t *src[3], i0, i1, i2;
|
||||
float *srcf[3], i0f, i1f, i2f;
|
||||
|
||||
for (i = 1; i < 3; i++)
|
||||
for (i = 1; i < 3; i++) {
|
||||
if (tile->codsty[0].transform != tile->codsty[i].transform) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Transforms mismatch, MCT not supported\n");
|
||||
return;
|
||||
}
|
||||
if (memcmp(tile->comp[0].coord, tile->comp[i].coord, sizeof(tile->comp[0].coord))) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Coords mismatch, MCT not supported\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (tile->codsty[0].transform == FF_DWT97)
|
||||
@@ -1398,6 +1411,7 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
|
||||
memset(s->codsty, 0, sizeof(s->codsty));
|
||||
memset(s->qntsty, 0, sizeof(s->qntsty));
|
||||
s->numXtiles = s->numYtiles = 0;
|
||||
s->ncomponents = 0;
|
||||
}
|
||||
|
||||
static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
|
||||
@@ -1452,6 +1466,10 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
|
||||
|
||||
switch (marker) {
|
||||
case JPEG2000_SIZ:
|
||||
if (s->ncomponents) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Duplicate SIZ\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
ret = get_siz(s);
|
||||
if (!s->tile)
|
||||
s->numXtiles = s->numYtiles = 0;
|
||||
|
||||
@@ -540,6 +540,9 @@ int ff_jpeg2000_dwt_init(DWTContext *s, uint16_t border[2][2],
|
||||
|
||||
int ff_dwt_encode(DWTContext *s, void *t)
|
||||
{
|
||||
if (s->ndeclevels == 0)
|
||||
return 0;
|
||||
|
||||
switch(s->type){
|
||||
case FF_DWT97:
|
||||
dwt_encode97_float(s, t); break;
|
||||
@@ -555,6 +558,9 @@ int ff_dwt_encode(DWTContext *s, void *t)
|
||||
|
||||
int ff_dwt_decode(DWTContext *s, void *t)
|
||||
{
|
||||
if (s->ndeclevels == 0)
|
||||
return 0;
|
||||
|
||||
switch (s->type) {
|
||||
case FF_DWT97:
|
||||
dwt_decode97_float(s, t);
|
||||
|
||||
@@ -356,6 +356,15 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (i = 0; i < image->numcomps; i++) {
|
||||
if (!image->comps[i].data) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Image component %d contains no data.\n", i);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
|
||||
pixel_size = desc->comp[0].step_minus1 + 1;
|
||||
ispacked = libopenjpeg_ispacked(avctx->pix_fmt);
|
||||
|
||||
@@ -324,7 +324,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
} else
|
||||
audio = frame->data[0];
|
||||
} else {
|
||||
if (!opus->afq.remaining_samples)
|
||||
if (!opus->afq.remaining_samples || (!opus->afq.frame_alloc && !opus->afq.frame_count))
|
||||
return 0;
|
||||
audio = opus->samples;
|
||||
memset(audio, 0, opus->opts.packet_size * sample_size);
|
||||
|
||||
@@ -148,6 +148,8 @@ static char *microdvd_load_tags(struct microdvd_tag *tags, char *s)
|
||||
|
||||
/* Position */
|
||||
case 'P':
|
||||
if (!*s)
|
||||
break;
|
||||
tag.persistent = MICRODVD_PERSISTENT_ON;
|
||||
tag.data1 = (*s++ == '1');
|
||||
if (*s != '}')
|
||||
|
||||
+39
-10
@@ -96,6 +96,15 @@ static void parse_avid(MJpegDecodeContext *s, uint8_t *buf, int len)
|
||||
av_log(s->avctx, AV_LOG_INFO, "AVID: len:%d %d\n", len, len > 14 ? buf[12] : -1);
|
||||
}
|
||||
|
||||
static void init_idct(AVCodecContext *avctx)
|
||||
{
|
||||
MJpegDecodeContext *s = avctx->priv_data;
|
||||
|
||||
ff_idctdsp_init(&s->idsp, avctx);
|
||||
ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
|
||||
ff_zigzag_direct);
|
||||
}
|
||||
|
||||
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
MJpegDecodeContext *s = avctx->priv_data;
|
||||
@@ -110,9 +119,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
|
||||
s->avctx = avctx;
|
||||
ff_blockdsp_init(&s->bdsp, avctx);
|
||||
ff_hpeldsp_init(&s->hdsp, avctx->flags);
|
||||
ff_idctdsp_init(&s->idsp, avctx);
|
||||
ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
|
||||
ff_zigzag_direct);
|
||||
init_idct(avctx);
|
||||
s->buffer_size = 0;
|
||||
s->buffer = NULL;
|
||||
s->start_code = -1;
|
||||
@@ -254,9 +261,13 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
||||
|
||||
/* XXX: verify len field validity */
|
||||
len = get_bits(&s->gb, 16);
|
||||
s->avctx->bits_per_raw_sample =
|
||||
bits = get_bits(&s->gb, 8);
|
||||
|
||||
if (s->avctx->bits_per_raw_sample != bits) {
|
||||
av_log(s->avctx, AV_LOG_INFO, "Changeing bps to %d\n", bits);
|
||||
s->avctx->bits_per_raw_sample = bits;
|
||||
init_idct(s->avctx);
|
||||
}
|
||||
if (s->pegasus_rct)
|
||||
bits = 9;
|
||||
if (bits == 9 && !s->pegasus_rct)
|
||||
@@ -946,7 +957,14 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
|
||||
skip_bits(&s->gb, 16); /* skip RSTn */
|
||||
}
|
||||
}
|
||||
if (s->nb_components == 4) {
|
||||
if (s->rct && s->nb_components == 4) {
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
||||
ptr[4*mb_x + 2] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2);
|
||||
ptr[4*mb_x + 1] = buffer[mb_x][1] + ptr[4*mb_x + 2];
|
||||
ptr[4*mb_x + 3] = buffer[mb_x][2] + ptr[4*mb_x + 2];
|
||||
ptr[4*mb_x + 0] = buffer[mb_x][3];
|
||||
}
|
||||
} else if (s->nb_components == 4) {
|
||||
for(i=0; i<nb_components; i++) {
|
||||
int c= s->comp_index[i];
|
||||
if (s->bits <= 8) {
|
||||
@@ -1037,7 +1055,10 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
|
||||
dc = mjpeg_decode_dc(s, s->dc_index[i]);
|
||||
if(dc == 0xFFFFF)
|
||||
return -1;
|
||||
if(bits<=8){
|
||||
if ( h * mb_x + x >= s->width
|
||||
|| v * mb_y + y >= s->height) {
|
||||
// Nothing to do
|
||||
} else if (bits<=8) {
|
||||
ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
|
||||
if(y==0 && toprow){
|
||||
if(x==0 && leftcol){
|
||||
@@ -1105,7 +1126,10 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
|
||||
dc = mjpeg_decode_dc(s, s->dc_index[i]);
|
||||
if(dc == 0xFFFFF)
|
||||
return -1;
|
||||
if(bits<=8){
|
||||
if ( h * mb_x + x >= s->width
|
||||
|| v * mb_y + y >= s->height) {
|
||||
// Nothing to do
|
||||
} else if (bits<=8) {
|
||||
ptr = s->picture_ptr->data[c] +
|
||||
(linesize * (v * mb_y + y)) +
|
||||
(h * mb_x + x); //FIXME optimize this crap
|
||||
@@ -1173,7 +1197,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
|
||||
int mb_bitmask_size,
|
||||
const AVFrame *reference)
|
||||
{
|
||||
int i, mb_x, mb_y;
|
||||
int i, mb_x, mb_y, chroma_h_shift, chroma_v_shift, chroma_width, chroma_height;
|
||||
uint8_t *data[MAX_COMPONENTS];
|
||||
const uint8_t *reference_data[MAX_COMPONENTS];
|
||||
int linesize[MAX_COMPONENTS];
|
||||
@@ -1190,6 +1214,11 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
|
||||
|
||||
s->restart_count = 0;
|
||||
|
||||
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, &chroma_h_shift,
|
||||
&chroma_v_shift);
|
||||
chroma_width = FF_CEIL_RSHIFT(s->width, chroma_h_shift);
|
||||
chroma_height = FF_CEIL_RSHIFT(s->height, chroma_v_shift);
|
||||
|
||||
for (i = 0; i < nb_components; i++) {
|
||||
int c = s->comp_index[i];
|
||||
data[c] = s->picture_ptr->data[c];
|
||||
@@ -1226,8 +1255,8 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
|
||||
|
||||
if (s->interlaced && s->bottom_field)
|
||||
block_offset += linesize[c] >> 1;
|
||||
if ( 8*(h * mb_x + x) < s->width
|
||||
&& 8*(v * mb_y + y) < s->height) {
|
||||
if ( 8*(h * mb_x + x) < ((c == 1) || (c == 2) ? chroma_width : s->width)
|
||||
&& 8*(v * mb_y + y) < ((c == 1) || (c == 2) ? chroma_height : s->height)) {
|
||||
ptr = data[c] + block_offset;
|
||||
} else
|
||||
ptr = NULL;
|
||||
|
||||
@@ -1907,7 +1907,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
|
||||
(left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) ||
|
||||
((avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_AGGRESSIVE)) && left > 8)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n",
|
||||
left, show_bits(&s->gb, FFMIN(left, 23)));
|
||||
left, left>0 ? show_bits(&s->gb, FFMIN(left, 23)) : 0);
|
||||
return -1;
|
||||
} else
|
||||
goto eos;
|
||||
|
||||
@@ -1873,6 +1873,10 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
|
||||
int last = 0;
|
||||
for (i = 0; i < 64; i++) {
|
||||
int j;
|
||||
if (get_bits_left(gb) < 8) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "insufficient data for custom matrix\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
v = get_bits(gb, 8);
|
||||
if (v == 0)
|
||||
break;
|
||||
@@ -1896,6 +1900,10 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
|
||||
int last = 0;
|
||||
for (i = 0; i < 64; i++) {
|
||||
int j;
|
||||
if (get_bits_left(gb) < 8) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "insufficient data for custom matrix\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
v = get_bits(gb, 8);
|
||||
if (v == 0)
|
||||
break;
|
||||
|
||||
@@ -1642,9 +1642,11 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
|
||||
uint32_t header;
|
||||
int ret;
|
||||
|
||||
int skipped = 0;
|
||||
while(buf_size && !*buf){
|
||||
buf++;
|
||||
buf_size--;
|
||||
skipped++;
|
||||
}
|
||||
|
||||
if (buf_size < HEADER_SIZE)
|
||||
@@ -1699,7 +1701,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
|
||||
return ret;
|
||||
}
|
||||
s->frame_size = 0;
|
||||
return buf_size;
|
||||
return buf_size + skipped;
|
||||
}
|
||||
|
||||
static void mp_flush(MPADecodeContext *ctx)
|
||||
@@ -1878,6 +1880,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx)
|
||||
s->mp3decctx[i]->adu_mode = 1;
|
||||
s->mp3decctx[i]->avctx = avctx;
|
||||
s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
|
||||
s->mp3decctx[i]->fdsp = s->mp3decctx[0]->fdsp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+79
-4
@@ -1285,6 +1285,83 @@ fail:
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static void clear_context(MpegEncContext *s)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
memset(&s->next_picture, 0, sizeof(s->next_picture));
|
||||
memset(&s->last_picture, 0, sizeof(s->last_picture));
|
||||
memset(&s->current_picture, 0, sizeof(s->current_picture));
|
||||
memset(&s->new_picture, 0, sizeof(s->new_picture));
|
||||
|
||||
memset(s->thread_context, 0, sizeof(s->thread_context));
|
||||
|
||||
s->me.map = NULL;
|
||||
s->me.score_map = NULL;
|
||||
s->dct_error_sum = NULL;
|
||||
s->block = NULL;
|
||||
s->blocks = NULL;
|
||||
memset(s->pblocks, 0, sizeof(s->pblocks));
|
||||
s->ac_val_base = NULL;
|
||||
s->ac_val[0] =
|
||||
s->ac_val[1] =
|
||||
s->ac_val[2] =NULL;
|
||||
s->edge_emu_buffer = NULL;
|
||||
s->me.scratchpad = NULL;
|
||||
s->me.temp =
|
||||
s->rd_scratchpad =
|
||||
s->b_scratchpad =
|
||||
s->obmc_scratchpad = NULL;
|
||||
|
||||
s->parse_context.buffer = NULL;
|
||||
s->parse_context.buffer_size = 0;
|
||||
s->parse_context.overread = 0;
|
||||
s->bitstream_buffer = NULL;
|
||||
s->allocated_bitstream_buffer_size = 0;
|
||||
s->picture = NULL;
|
||||
s->mb_type = NULL;
|
||||
s->p_mv_table_base = NULL;
|
||||
s->b_forw_mv_table_base = NULL;
|
||||
s->b_back_mv_table_base = NULL;
|
||||
s->b_bidir_forw_mv_table_base = NULL;
|
||||
s->b_bidir_back_mv_table_base = NULL;
|
||||
s->b_direct_mv_table_base = NULL;
|
||||
s->p_mv_table = NULL;
|
||||
s->b_forw_mv_table = NULL;
|
||||
s->b_back_mv_table = NULL;
|
||||
s->b_bidir_forw_mv_table = NULL;
|
||||
s->b_bidir_back_mv_table = NULL;
|
||||
s->b_direct_mv_table = NULL;
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (k = 0; k < 2; k++) {
|
||||
s->b_field_mv_table_base[i][j][k] = NULL;
|
||||
s->b_field_mv_table[i][j][k] = NULL;
|
||||
}
|
||||
s->b_field_select_table[i][j] = NULL;
|
||||
s->p_field_mv_table_base[i][j] = NULL;
|
||||
s->p_field_mv_table[i][j] = NULL;
|
||||
}
|
||||
s->p_field_select_table[i] = NULL;
|
||||
}
|
||||
|
||||
s->dc_val_base = NULL;
|
||||
s->coded_block_base = NULL;
|
||||
s->mbintra_table = NULL;
|
||||
s->cbp_table = NULL;
|
||||
s->pred_dir_table = NULL;
|
||||
|
||||
s->mbskip_table = NULL;
|
||||
|
||||
s->er.error_status_table = NULL;
|
||||
s->er.er_temp_buffer = NULL;
|
||||
s->mb_index2xy = NULL;
|
||||
s->lambda_table = NULL;
|
||||
|
||||
s->cplx_tab = NULL;
|
||||
s->bits_tab = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* init common structure for both encoder and decoder.
|
||||
* this assumes that some variables like width/height are already set
|
||||
@@ -1296,6 +1373,8 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
|
||||
s->avctx->active_thread_type & FF_THREAD_SLICE) ?
|
||||
s->avctx->thread_count : 1;
|
||||
|
||||
clear_context(s);
|
||||
|
||||
if (s->encoding && s->avctx->slices)
|
||||
nb_slices = s->avctx->slices;
|
||||
|
||||
@@ -1343,10 +1422,6 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
|
||||
if (!s->picture[i].f)
|
||||
goto fail;
|
||||
}
|
||||
memset(&s->next_picture, 0, sizeof(s->next_picture));
|
||||
memset(&s->last_picture, 0, sizeof(s->last_picture));
|
||||
memset(&s->current_picture, 0, sizeof(s->current_picture));
|
||||
memset(&s->new_picture, 0, sizeof(s->new_picture));
|
||||
s->next_picture.f = av_frame_alloc();
|
||||
if (!s->next_picture.f)
|
||||
goto fail;
|
||||
|
||||
@@ -164,6 +164,16 @@ typedef struct ChannelMap {
|
||||
|
||||
typedef struct OpusContext {
|
||||
OpusStreamContext *streams;
|
||||
|
||||
/* current output buffers for each streams */
|
||||
float **out;
|
||||
int *out_size;
|
||||
/* Buffers for synchronizing the streams when they have different
|
||||
* resampling delays */
|
||||
AVAudioFifo **sync_buffers;
|
||||
/* number of decoded samples for each stream */
|
||||
int *decoded_samples;
|
||||
|
||||
int nb_streams;
|
||||
int nb_stereo_streams;
|
||||
|
||||
|
||||
+86
-16
@@ -366,12 +366,17 @@ static int opus_decode_frame(OpusStreamContext *s, const uint8_t *data, int size
|
||||
|
||||
static int opus_decode_subpacket(OpusStreamContext *s,
|
||||
const uint8_t *buf, int buf_size,
|
||||
float **out, int out_size,
|
||||
int nb_samples)
|
||||
{
|
||||
int output_samples = 0;
|
||||
int flush_needed = 0;
|
||||
int i, j, ret;
|
||||
|
||||
s->out[0] = out[0];
|
||||
s->out[1] = out[1];
|
||||
s->out_size = out_size;
|
||||
|
||||
/* check if we need to flush the resampler */
|
||||
if (swr_is_initialized(s->swr)) {
|
||||
if (buf) {
|
||||
@@ -449,15 +454,17 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
int coded_samples = 0;
|
||||
int decoded_samples = 0;
|
||||
int i, ret;
|
||||
int decoded_samples = INT_MAX;
|
||||
int delayed_samples = 0;
|
||||
int i, ret;
|
||||
|
||||
/* calculate the number of delayed samples */
|
||||
for (i = 0; i < c->nb_streams; i++) {
|
||||
OpusStreamContext *s = &c->streams[i];
|
||||
s->out[0] =
|
||||
s->out[1] = NULL;
|
||||
delayed_samples = FFMAX(delayed_samples, s->delayed_samples);
|
||||
delayed_samples = FFMAX(delayed_samples,
|
||||
s->delayed_samples + av_audio_fifo_size(c->sync_buffers[i]));
|
||||
}
|
||||
|
||||
/* decode the header of the first sub-packet to find out the sample count */
|
||||
@@ -488,14 +495,43 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
frame->nb_samples = 0;
|
||||
|
||||
memset(c->out, 0, c->nb_streams * 2 * sizeof(*c->out));
|
||||
for (i = 0; i < avctx->channels; i++) {
|
||||
ChannelMap *map = &c->channel_maps[i];
|
||||
if (!map->copy)
|
||||
c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[i];
|
||||
c->out[2 * map->stream_idx + map->channel_idx] = (float*)frame->extended_data[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < c->nb_streams; i++)
|
||||
c->streams[i].out_size = frame->linesize[0];
|
||||
/* read the data from the sync buffers */
|
||||
for (i = 0; i < c->nb_streams; i++) {
|
||||
float **out = c->out + 2 * i;
|
||||
int sync_size = av_audio_fifo_size(c->sync_buffers[i]);
|
||||
|
||||
float sync_dummy[32];
|
||||
int out_dummy = (!out[0]) | ((!out[1]) << 1);
|
||||
|
||||
if (!out[0])
|
||||
out[0] = sync_dummy;
|
||||
if (!out[1])
|
||||
out[1] = sync_dummy;
|
||||
if (out_dummy && sync_size > FF_ARRAY_ELEMS(sync_dummy))
|
||||
return AVERROR_BUG;
|
||||
|
||||
ret = av_audio_fifo_read(c->sync_buffers[i], (void**)out, sync_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (out_dummy & 1)
|
||||
out[0] = NULL;
|
||||
else
|
||||
out[0] += ret;
|
||||
if (out_dummy & 2)
|
||||
out[1] = NULL;
|
||||
else
|
||||
out[1] += ret;
|
||||
|
||||
c->out_size[i] = frame->linesize[0] - ret * sizeof(float);
|
||||
}
|
||||
|
||||
/* decode each sub-packet */
|
||||
for (i = 0; i < c->nb_streams; i++) {
|
||||
@@ -516,20 +552,31 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
|
||||
s->silk_samplerate = get_silk_samplerate(s->packet.config);
|
||||
}
|
||||
|
||||
ret = opus_decode_subpacket(&c->streams[i], buf,
|
||||
s->packet.data_size, coded_samples);
|
||||
ret = opus_decode_subpacket(&c->streams[i], buf, s->packet.data_size,
|
||||
c->out + 2 * i, c->out_size[i], coded_samples);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (decoded_samples && ret != decoded_samples) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Different numbers of decoded samples "
|
||||
"in a multi-channel stream\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
decoded_samples = ret;
|
||||
c->decoded_samples[i] = ret;
|
||||
decoded_samples = FFMIN(decoded_samples, ret);
|
||||
|
||||
buf += s->packet.packet_size;
|
||||
buf_size -= s->packet.packet_size;
|
||||
}
|
||||
|
||||
/* buffer the extra samples */
|
||||
for (i = 0; i < c->nb_streams; i++) {
|
||||
int buffer_samples = c->decoded_samples[i] - decoded_samples;
|
||||
if (buffer_samples) {
|
||||
float *buf[2] = { c->out[2 * i + 0] ? c->out[2 * i + 0] : (float*)frame->extended_data[0],
|
||||
c->out[2 * i + 1] ? c->out[2 * i + 1] : (float*)frame->extended_data[0] };
|
||||
buf[0] += decoded_samples;
|
||||
buf[1] += decoded_samples;
|
||||
ret = av_audio_fifo_write(c->sync_buffers[i], (void**)buf, buffer_samples);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < avctx->channels; i++) {
|
||||
ChannelMap *map = &c->channel_maps[i];
|
||||
|
||||
@@ -542,7 +589,7 @@ static int opus_decode_packet(AVCodecContext *avctx, void *data,
|
||||
memset(frame->extended_data[i], 0, frame->linesize[0]);
|
||||
}
|
||||
|
||||
if (c->gain_i) {
|
||||
if (c->gain_i && decoded_samples > 0) {
|
||||
c->fdsp.vector_fmul_scalar((float*)frame->extended_data[i],
|
||||
(float*)frame->extended_data[i],
|
||||
c->gain, FFALIGN(decoded_samples, 8));
|
||||
@@ -570,6 +617,8 @@ static av_cold void opus_decode_flush(AVCodecContext *ctx)
|
||||
av_audio_fifo_drain(s->celt_delay, av_audio_fifo_size(s->celt_delay));
|
||||
swr_close(s->swr);
|
||||
|
||||
av_audio_fifo_drain(c->sync_buffers[i], av_audio_fifo_size(c->sync_buffers[i]));
|
||||
|
||||
ff_silk_flush(s->silk);
|
||||
ff_celt_flush(s->celt);
|
||||
}
|
||||
@@ -594,6 +643,16 @@ static av_cold int opus_decode_close(AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
av_freep(&c->streams);
|
||||
|
||||
if (c->sync_buffers) {
|
||||
for (i = 0; i < c->nb_streams; i++)
|
||||
av_audio_fifo_free(c->sync_buffers[i]);
|
||||
}
|
||||
av_freep(&c->sync_buffers);
|
||||
av_freep(&c->decoded_samples);
|
||||
av_freep(&c->out);
|
||||
av_freep(&c->out_size);
|
||||
|
||||
c->nb_streams = 0;
|
||||
|
||||
av_freep(&c->channel_maps);
|
||||
@@ -618,7 +677,11 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
|
||||
|
||||
/* allocate and init each independent decoder */
|
||||
c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams));
|
||||
if (!c->streams) {
|
||||
c->out = av_mallocz_array(c->nb_streams, 2 * sizeof(*c->out));
|
||||
c->out_size = av_mallocz_array(c->nb_streams, sizeof(*c->out_size));
|
||||
c->sync_buffers = av_mallocz_array(c->nb_streams, sizeof(*c->sync_buffers));
|
||||
c->decoded_samples = av_mallocz_array(c->nb_streams, sizeof(*c->decoded_samples));
|
||||
if (!c->streams || !c->sync_buffers || !c->decoded_samples || !c->out || !c->out_size) {
|
||||
c->nb_streams = 0;
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
@@ -666,6 +729,13 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
c->sync_buffers[i] = av_audio_fifo_alloc(avctx->sample_fmt,
|
||||
s->output_channels, 32);
|
||||
if (!c->sync_buffers[i]) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
#define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define RGBA(r,g,b,a) (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define MAX_EPOCH_PALETTES 8 // Max 8 allowed per PGS epoch
|
||||
#define MAX_EPOCH_OBJECTS 64 // Max 64 allowed per PGS epoch
|
||||
#define MAX_OBJECT_REFS 2 // Max objects per display set
|
||||
|
||||
@@ -588,6 +588,11 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (s->state & PNG_IHDR) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Multiple IHDR\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
s->width = bytestream2_get_be32(&s->gb);
|
||||
s->height = bytestream2_get_be32(&s->gb);
|
||||
if (av_image_check_size(s->width, s->height, 0, avctx)) {
|
||||
|
||||
@@ -573,7 +573,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
|
||||
pthread_join(p->thread, NULL);
|
||||
p->thread_init=0;
|
||||
|
||||
if (codec->close)
|
||||
if (codec->close && p->avctx)
|
||||
codec->close(p->avctx);
|
||||
|
||||
avctx->codec = NULL;
|
||||
@@ -593,12 +593,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
|
||||
av_packet_unref(&p->avpkt);
|
||||
av_freep(&p->released_buffers);
|
||||
|
||||
if (i) {
|
||||
if (i && p->avctx) {
|
||||
av_freep(&p->avctx->priv_data);
|
||||
av_freep(&p->avctx->slice_offset);
|
||||
}
|
||||
|
||||
av_freep(&p->avctx->internal);
|
||||
if (p->avctx)
|
||||
av_freep(&p->avctx->internal);
|
||||
av_freep(&p->avctx);
|
||||
}
|
||||
|
||||
@@ -670,6 +671,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
|
||||
|
||||
copy->internal = av_malloc(sizeof(AVCodecInternal));
|
||||
if (!copy->internal) {
|
||||
copy->priv_data = NULL;
|
||||
err = AVERROR(ENOMEM);
|
||||
goto error;
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = ff_alloc_packet2(avctx, pkt, ret)) < 0)
|
||||
if ((ret = ff_alloc_packet(pkt, ret)) < 0)
|
||||
return ret;
|
||||
if ((ret = avpicture_layout((const AVPicture *)frame, avctx->pix_fmt, avctx->width,
|
||||
avctx->height, pkt->data, pkt->size)) < 0)
|
||||
|
||||
@@ -1534,7 +1534,14 @@ int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
|
||||
|
||||
if (avctx->internal->is_copy) {
|
||||
r->tmp_b_block_base = NULL;
|
||||
r->cbp_chroma = NULL;
|
||||
r->cbp_luma = NULL;
|
||||
r->deblock_coefs = NULL;
|
||||
r->intra_types_hist = NULL;
|
||||
r->mb_type = NULL;
|
||||
|
||||
ff_mpv_idct_init(&r->s);
|
||||
|
||||
if ((err = ff_mpv_common_init(&r->s)) < 0)
|
||||
return err;
|
||||
if ((err = rv34_decoder_alloc(r)) < 0) {
|
||||
|
||||
+4
-5
@@ -79,11 +79,6 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
|
||||
case 8:
|
||||
avctx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK | AV_CH_LAYOUT_STEREO_DOWNMIX;
|
||||
}
|
||||
avctx->sample_rate = 48000;
|
||||
avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_raw_sample + 4) +
|
||||
32 * (48000 / (buf_size * 8 /
|
||||
(avctx->channels *
|
||||
(avctx->bits_per_raw_sample + 4))));
|
||||
|
||||
return frame_size;
|
||||
}
|
||||
@@ -109,6 +104,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_raw_sample + 4) +
|
||||
32 * 48000 / frame->nb_samples;
|
||||
buf_size = (frame->nb_samples * avctx->channels / 2) * block_size;
|
||||
|
||||
if (avctx->bits_per_raw_sample == 24) {
|
||||
@@ -146,6 +143,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
avctx->sample_rate = 48000;
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
|
||||
return avpkt->size;
|
||||
|
||||
@@ -457,6 +457,7 @@ static void destroy_buffers(SANMVideoContext *ctx)
|
||||
ctx->frm0_size =
|
||||
ctx->frm1_size =
|
||||
ctx->frm2_size = 0;
|
||||
init_sizes(ctx, 0, 0);
|
||||
}
|
||||
|
||||
static av_cold int init_buffers(SANMVideoContext *ctx)
|
||||
|
||||
@@ -137,6 +137,7 @@ typedef struct AACSBRContext {
|
||||
struct SpectralBandReplication {
|
||||
int sample_rate;
|
||||
int start;
|
||||
int id_aac;
|
||||
int reset;
|
||||
SpectrumParameters spectrum_params;
|
||||
int bs_amp_res_header;
|
||||
|
||||
@@ -667,6 +667,10 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
/* get output buffer */
|
||||
frame->nb_samples = unp_size / (avctx->channels * (bits + 1));
|
||||
if (unp_size % (avctx->channels * (bits + 1))) {
|
||||
av_log(avctx, AV_LOG_ERROR, "unp_size %d is odd\n", unp_size);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
samples = (int16_t *)frame->data[0];
|
||||
|
||||
+4
-2
@@ -296,6 +296,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
|
||||
BlockNode *lb= lt+b_stride;
|
||||
BlockNode *rb= lb+1;
|
||||
uint8_t *block[4];
|
||||
// When src_stride is large enough, it is possible to interleave the blocks.
|
||||
// Otherwise the blocks are written sequentially in the tmp buffer.
|
||||
int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;
|
||||
uint8_t *tmp = s->scratchbuf;
|
||||
uint8_t *ptmp;
|
||||
@@ -339,8 +341,6 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
|
||||
|
||||
if(b_w<=0 || b_h<=0) return;
|
||||
|
||||
av_assert2(src_stride > 2*MB_SIZE + 5);
|
||||
|
||||
if(!sliced && offset_dst)
|
||||
dst += src_x + src_y*dst_stride;
|
||||
dst8+= src_x + src_y*src_stride;
|
||||
@@ -555,6 +555,8 @@ static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
|
||||
e= 0;
|
||||
while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
|
||||
e++;
|
||||
if (e > 31)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
a= 1;
|
||||
|
||||
@@ -900,6 +900,7 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
|
||||
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avctx->channels = s->channels;
|
||||
|
||||
s->lossless = get_bits1(&gb);
|
||||
if (!s->lossless)
|
||||
|
||||
@@ -617,9 +617,12 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
uint8_t *current;
|
||||
int result, i, x, y, width, height;
|
||||
svq1_pmv *pmv;
|
||||
int ret;
|
||||
|
||||
/* initialize bit buffer */
|
||||
init_get_bits8(&s->gb, buf, buf_size);
|
||||
ret = init_get_bits8(&s->gb, buf, buf_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* decode frame header */
|
||||
s->frame_code = get_bits(&s->gb, 22);
|
||||
|
||||
@@ -514,6 +514,11 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
|
||||
SVQ1EncContext *const s = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
if (avctx->width >= 4096 || avctx->height >= 4096) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Dimensions too large, maximum is 4095x4095\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ff_hpeldsp_init(&s->hdsp, avctx->flags);
|
||||
ff_me_cmp_init(&s->mecc, avctx);
|
||||
ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx);
|
||||
|
||||
+8
-2
@@ -632,7 +632,7 @@ static int decorrelate(TAKDecContext *s, int c1, int c2, int length)
|
||||
for (; length2 > 0; length2 -= tmp) {
|
||||
tmp = FFMIN(length2, x);
|
||||
|
||||
for (i = 0; i < tmp; i++)
|
||||
for (i = 0; i < tmp - (tmp == length2); i++)
|
||||
s->residues[filter_order + i] = *p2++ >> dshift;
|
||||
|
||||
for (i = 0; i < tmp; i++) {
|
||||
@@ -656,7 +656,7 @@ static int decorrelate(TAKDecContext *s, int c1, int c2, int length)
|
||||
*p1++ = v;
|
||||
}
|
||||
|
||||
memcpy(s->residues, &s->residues[tmp], 2 * filter_order);
|
||||
memmove(s->residues, &s->residues[tmp], 2 * filter_order);
|
||||
}
|
||||
|
||||
emms_c();
|
||||
@@ -799,6 +799,12 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (s->mcdparams[i].present) {
|
||||
s->mcdparams[i].index = get_bits(gb, 2);
|
||||
s->mcdparams[i].chan2 = get_bits(gb, 4);
|
||||
if (s->mcdparams[i].chan2 >= avctx->channels) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"invalid channel 2 (%d) for %d channel(s)\n",
|
||||
s->mcdparams[i].chan2, avctx->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (s->mcdparams[i].index == 1) {
|
||||
if ((nbit == s->mcdparams[i].chan2) ||
|
||||
(ch_mask & 1 << s->mcdparams[i].chan2))
|
||||
|
||||
@@ -402,6 +402,10 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
|
||||
new_pix_fmt = AV_PIX_FMT_RGB555; // RGB565 is supported as well
|
||||
|
||||
s->w >>= width_shift;
|
||||
if (s->w & 1) {
|
||||
avpriv_request_sample(s->avctx, "Frame with odd width");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (s->w != s->avctx->width || s->h != s->avctx->height ||
|
||||
new_pix_fmt != s->avctx->pix_fmt) {
|
||||
|
||||
+5
-1
@@ -123,6 +123,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
|
||||
TTAContext *s = avctx->priv_data;
|
||||
GetBitContext gb;
|
||||
int total_frames;
|
||||
int ret;
|
||||
|
||||
s->avctx = avctx;
|
||||
|
||||
@@ -131,7 +132,10 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
s->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
|
||||
init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
|
||||
ret = init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (show_bits_long(&gb, 32) == AV_RL32("TTA1")) {
|
||||
/* signature */
|
||||
skip_bits_long(&gb, 32);
|
||||
|
||||
+11
-5
@@ -424,10 +424,12 @@ 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)
|
||||
if (s->codec_id == AV_CODEC_ID_H264 || s->lowres) {
|
||||
// some of the optimized chroma MC reads one line too much
|
||||
// which is also done in mpeg decoders with lowres > 0
|
||||
*height += 2;
|
||||
*width = FFMAX(*width, 32);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
linesize_align[i] = STRIDE_ALIGN;
|
||||
@@ -1036,8 +1038,10 @@ end:
|
||||
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
{
|
||||
int ret = get_buffer_internal(avctx, frame, flags);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
frame->width = frame->height = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2958,8 +2962,8 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
|
||||
enc->width, enc->height);
|
||||
if (enc->sample_aspect_ratio.num) {
|
||||
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
|
||||
enc->width * enc->sample_aspect_ratio.num,
|
||||
enc->height * enc->sample_aspect_ratio.den,
|
||||
enc->width * (int64_t)enc->sample_aspect_ratio.num,
|
||||
enc->height * (int64_t)enc->sample_aspect_ratio.den,
|
||||
1024 * 1024);
|
||||
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
||||
" [SAR %d:%d DAR %d:%d]",
|
||||
@@ -2968,6 +2972,8 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
|
||||
}
|
||||
if (av_log_get_level() >= AV_LOG_DEBUG) {
|
||||
int g = av_gcd(enc->time_base.num, enc->time_base.den);
|
||||
if (!g)
|
||||
g = 1;
|
||||
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
||||
", %d/%d",
|
||||
enc->time_base.num / g, enc->time_base.den / g);
|
||||
@@ -3259,7 +3265,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
|
||||
return frame_bytes * 8 / bps;
|
||||
}
|
||||
|
||||
if (ch > 0) {
|
||||
if (ch > 0 && ch < INT_MAX/16) {
|
||||
/* calc from frame_bytes and channels */
|
||||
switch (id) {
|
||||
case AV_CODEC_ID_ADPCM_AFC:
|
||||
|
||||
+1
-1
@@ -5669,7 +5669,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
|
||||
count = avctx->extradata_size*8 - get_bits_count(&gb);
|
||||
if (count > 0) {
|
||||
av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n",
|
||||
count, get_bits(&gb, count));
|
||||
count, get_bits_long(&gb, FFMIN(count, 32)));
|
||||
} else if (count < 0) {
|
||||
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
|
||||
}
|
||||
|
||||
+16
-8
@@ -131,7 +131,7 @@ static const uint8_t hilbert_offset[16][2] = {
|
||||
|
||||
typedef struct Vp3DecodeContext {
|
||||
AVCodecContext *avctx;
|
||||
int theora, theora_tables;
|
||||
int theora, theora_tables, theora_header;
|
||||
int version;
|
||||
int width, height;
|
||||
int chroma_x_shift, chroma_y_shift;
|
||||
@@ -206,8 +206,8 @@ typedef struct Vp3DecodeContext {
|
||||
int16_t *dct_tokens[3][64];
|
||||
int16_t *dct_tokens_base;
|
||||
#define TOKEN_EOB(eob_run) ((eob_run) << 2)
|
||||
#define TOKEN_ZERO_RUN(coeff, zero_run) (((coeff) << 9) + ((zero_run) << 2) + 1)
|
||||
#define TOKEN_COEFF(coeff) (((coeff) << 2) + 2)
|
||||
#define TOKEN_ZERO_RUN(coeff, zero_run) (((coeff) * 512) + ((zero_run) << 2) + 1)
|
||||
#define TOKEN_COEFF(coeff) (((coeff) * 4) + 2)
|
||||
|
||||
/**
|
||||
* number of blocks that contain DCT coefficients at
|
||||
@@ -2010,17 +2010,19 @@ static int vp3_decode_frame(AVCodecContext *avctx,
|
||||
vp3_decode_end(avctx);
|
||||
ret = theora_decode_header(avctx, &gb);
|
||||
|
||||
if (ret >= 0)
|
||||
ret = vp3_decode_init(avctx);
|
||||
if (ret < 0) {
|
||||
vp3_decode_end(avctx);
|
||||
} else
|
||||
ret = vp3_decode_init(avctx);
|
||||
}
|
||||
return ret;
|
||||
} else if (type == 2) {
|
||||
ret = theora_decode_tables(avctx, &gb);
|
||||
if (ret >= 0)
|
||||
ret = vp3_decode_init(avctx);
|
||||
if (ret < 0) {
|
||||
vp3_decode_end(avctx);
|
||||
} else
|
||||
ret = vp3_decode_init(avctx);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2238,6 +2240,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
|
||||
int ret;
|
||||
AVRational fps, aspect;
|
||||
|
||||
s->theora_header = 0;
|
||||
s->theora = get_bits_long(gb, 24);
|
||||
av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
|
||||
|
||||
@@ -2297,7 +2300,8 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
skip_bits(gb, 3); /* reserved */
|
||||
}
|
||||
} else
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
|
||||
// align_get_bits(gb);
|
||||
|
||||
@@ -2320,6 +2324,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
|
||||
avctx->color_trc = AVCOL_TRC_BT709;
|
||||
}
|
||||
|
||||
s->theora_header = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2328,6 +2333,9 @@ static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
|
||||
Vp3DecodeContext *s = avctx->priv_data;
|
||||
int i, n, matrices, inter, plane;
|
||||
|
||||
if (!s->theora_header)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (s->theora >= 0x030200) {
|
||||
n = get_bits(gb, 3);
|
||||
/* loop filter limit values table */
|
||||
|
||||
+13
-3
@@ -164,7 +164,7 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
|
||||
s->mb_height = (s->avctx->coded_height + 15) / 16;
|
||||
|
||||
s->mb_layout = is_vp7 || avctx->active_thread_type == FF_THREAD_SLICE &&
|
||||
FFMIN(s->num_coeff_partitions, avctx->thread_count) > 1;
|
||||
avctx->thread_count > 1;
|
||||
if (!s->mb_layout) { // Frame threading and one thread
|
||||
s->macroblocks_base = av_mallocz((s->mb_width + s->mb_height * 2 + 1) *
|
||||
sizeof(*s->macroblocks));
|
||||
@@ -633,6 +633,11 @@ static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
|
||||
int width = s->avctx->width;
|
||||
int height = s->avctx->height;
|
||||
|
||||
if (buf_size < 3) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Insufficent data (%d) for header\n", buf_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
s->keyframe = !(buf[0] & 1);
|
||||
s->profile = (buf[0]>>1) & 7;
|
||||
s->invisible = !(buf[0] & 0x10);
|
||||
@@ -750,8 +755,10 @@ static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
|
||||
static av_always_inline
|
||||
void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src)
|
||||
{
|
||||
dst->x = av_clip(src->x, s->mv_min.x, s->mv_max.x);
|
||||
dst->y = av_clip(src->y, s->mv_min.y, s->mv_max.y);
|
||||
dst->x = av_clip(src->x, av_clip(s->mv_min.x, INT16_MIN, INT16_MAX),
|
||||
av_clip(s->mv_max.x, INT16_MIN, INT16_MAX));
|
||||
dst->y = av_clip(src->y, av_clip(s->mv_min.y, INT16_MIN, INT16_MAX),
|
||||
av_clip(s->mv_max.y, INT16_MIN, INT16_MAX));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2673,6 +2680,9 @@ av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
|
||||
VP8Context *s = avctx->priv_data;
|
||||
int i;
|
||||
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
vp8_decode_flush_impl(avctx, 1);
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++)
|
||||
av_frame_free(&s->frames[i].tf.f);
|
||||
|
||||
+7
-2
@@ -134,6 +134,11 @@ typedef struct VP8Frame {
|
||||
AVBufferRef *seg_map;
|
||||
} VP8Frame;
|
||||
|
||||
typedef struct VP8intmv {
|
||||
int x;
|
||||
int y;
|
||||
} VP8intmv;
|
||||
|
||||
#define MAX_THREADS 8
|
||||
typedef struct VP8Context {
|
||||
VP8ThreadData *thread_data;
|
||||
@@ -152,8 +157,8 @@ typedef struct VP8Context {
|
||||
uint8_t deblock_filter;
|
||||
uint8_t mbskip_enabled;
|
||||
uint8_t profile;
|
||||
VP56mv mv_min;
|
||||
VP56mv mv_max;
|
||||
VP8intmv mv_min;
|
||||
VP8intmv mv_max;
|
||||
|
||||
int8_t sign_bias[4]; ///< one state [0, 1] per ref frame type
|
||||
int ref_count[3];
|
||||
|
||||
+164
-159
@@ -239,7 +239,7 @@ typedef struct VP9Context {
|
||||
// whole-frame cache
|
||||
uint8_t *intra_pred_data[3];
|
||||
struct VP9Filter *lflvl;
|
||||
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[71*80];
|
||||
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[135*144];
|
||||
|
||||
// block reconstruction intermediates
|
||||
int block_alloc_using_2pass;
|
||||
@@ -248,6 +248,8 @@ typedef struct VP9Context {
|
||||
struct { int x, y; } min_mv, max_mv;
|
||||
DECLARE_ALIGNED(32, uint8_t, tmp_y)[64*64];
|
||||
DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][32*32];
|
||||
uint16_t mvscale[3][2];
|
||||
uint8_t mvstep[3][2];
|
||||
} VP9Context;
|
||||
|
||||
static const uint8_t bwh_tab[2][N_BS_SIZES][2] = {
|
||||
@@ -409,7 +411,7 @@ static av_always_inline int inv_recenter_nonneg(int v, int m)
|
||||
// differential forward probability updates
|
||||
static int update_prob(VP56RangeCoder *c, int p)
|
||||
{
|
||||
static const int inv_map_table[254] = {
|
||||
static const int inv_map_table[255] = {
|
||||
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
|
||||
189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
|
||||
@@ -428,7 +430,7 @@ static int update_prob(VP56RangeCoder *c, int p)
|
||||
207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
|
||||
222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
|
||||
237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
|
||||
252, 253,
|
||||
252, 253, 253,
|
||||
};
|
||||
int d;
|
||||
|
||||
@@ -458,6 +460,7 @@ static int update_prob(VP56RangeCoder *c, int p)
|
||||
if (d >= 65)
|
||||
d = (d << 1) - 65 + vp8_rac_get(c);
|
||||
d += 64;
|
||||
av_assert2(d < FF_ARRAY_ELEMS(inv_map_table));
|
||||
}
|
||||
|
||||
return p <= 128 ? 1 + inv_recenter_nonneg(inv_map_table[d], p - 1) :
|
||||
@@ -581,6 +584,26 @@ static int decode_frame_header(AVCodecContext *ctx,
|
||||
s->varcompref[1] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
AVFrame *ref = s->refs[s->refidx[i]].f;
|
||||
int refw = ref->width, refh = ref->height;
|
||||
|
||||
if (refw == w && refh == h) {
|
||||
s->mvscale[i][0] = s->mvscale[i][1] = 0;
|
||||
} else {
|
||||
if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h > 16 * refh) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Invalid ref frame dimensions %dx%d for frame size %dx%d\n",
|
||||
refw, refh, w, h);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
s->mvscale[i][0] = (refw << 14) / w;
|
||||
s->mvscale[i][1] = (refh << 14) / h;
|
||||
s->mvstep[i][0] = 16 * s->mvscale[i][0] >> 14;
|
||||
s->mvstep[i][1] = 16 * s->mvscale[i][1] >> 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
s->refreshctx = s->errorres ? 0 : get_bits1(&s->gb);
|
||||
@@ -2523,12 +2546,118 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
|
||||
}
|
||||
}
|
||||
|
||||
static av_always_inline void mc_luma_dir(VP9Context *s, vp9_mc_func (*mc)[2],
|
||||
uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *ref, ptrdiff_t ref_stride,
|
||||
ThreadFrame *ref_frame,
|
||||
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
|
||||
int bw, int bh, int w, int h)
|
||||
static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
|
||||
uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *ref, ptrdiff_t ref_stride,
|
||||
ThreadFrame *ref_frame,
|
||||
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
|
||||
int bw, int bh, int w, int h,
|
||||
const uint16_t *scale, const uint8_t *step)
|
||||
{
|
||||
#define scale_mv(n, dim) (((int64_t)n * scale[dim]) >> 14)
|
||||
// BUG libvpx seems to scale the two components separately. This introduces
|
||||
// rounding errors but we have to reproduce them to be exactly compatible
|
||||
// with the output from libvpx...
|
||||
int mx = scale_mv(mv->x * 2, 0) + scale_mv(x * 16, 0);
|
||||
int my = scale_mv(mv->y * 2, 1) + scale_mv(y * 16, 1);
|
||||
int refbw_m1, refbh_m1;
|
||||
int th;
|
||||
|
||||
y = my >> 4;
|
||||
x = mx >> 4;
|
||||
ref += y * ref_stride + x;
|
||||
mx &= 15;
|
||||
my &= 15;
|
||||
refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
|
||||
refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
|
||||
// FIXME bilinear filter only needs 0/1 pixels, not 3/4
|
||||
// we use +7 because the last 7 pixels of each sbrow can be changed in
|
||||
// the longest loopfilter of the next sbrow
|
||||
th = (y + refbh_m1 + 4 + 7) >> 6;
|
||||
ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0);
|
||||
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
|
||||
ref - 3 * ref_stride - 3,
|
||||
144, ref_stride,
|
||||
refbw_m1 + 8, refbh_m1 + 8,
|
||||
x - 3, y - 3, w, h);
|
||||
ref = s->edge_emu_buffer + 3 * 144 + 3;
|
||||
ref_stride = 144;
|
||||
}
|
||||
smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
|
||||
}
|
||||
|
||||
static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
|
||||
uint8_t *dst_u, uint8_t *dst_v,
|
||||
ptrdiff_t dst_stride,
|
||||
const uint8_t *ref_u, ptrdiff_t src_stride_u,
|
||||
const uint8_t *ref_v, ptrdiff_t src_stride_v,
|
||||
ThreadFrame *ref_frame,
|
||||
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
|
||||
int bw, int bh, int w, int h,
|
||||
const uint16_t *scale, const uint8_t *step)
|
||||
{
|
||||
// BUG https://code.google.com/p/webm/issues/detail?id=820
|
||||
int mx = scale_mv(mv->x, 0) + (scale_mv(x * 16, 0) & ~15) + (scale_mv(x * 32, 0) & 15);
|
||||
int my = scale_mv(mv->y, 1) + (scale_mv(y * 16, 1) & ~15) + (scale_mv(y * 32, 1) & 15);
|
||||
#undef scale_mv
|
||||
int refbw_m1, refbh_m1;
|
||||
int th;
|
||||
|
||||
y = my >> 4;
|
||||
x = mx >> 4;
|
||||
ref_u += y * src_stride_u + x;
|
||||
ref_v += y * src_stride_v + x;
|
||||
mx &= 15;
|
||||
my &= 15;
|
||||
refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
|
||||
refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
|
||||
// FIXME bilinear filter only needs 0/1 pixels, not 3/4
|
||||
// we use +7 because the last 7 pixels of each sbrow can be changed in
|
||||
// the longest loopfilter of the next sbrow
|
||||
th = (y + refbh_m1 + 4 + 7) >> 5;
|
||||
ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0);
|
||||
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
|
||||
ref_u - 3 * src_stride_u - 3,
|
||||
144, src_stride_u,
|
||||
refbw_m1 + 8, refbh_m1 + 8,
|
||||
x - 3, y - 3, w, h);
|
||||
ref_u = s->edge_emu_buffer + 3 * 144 + 3;
|
||||
smc(dst_u, dst_stride, ref_u, 144, bh, mx, my, step[0], step[1]);
|
||||
|
||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
|
||||
ref_v - 3 * src_stride_v - 3,
|
||||
144, src_stride_v,
|
||||
refbw_m1 + 8, refbh_m1 + 8,
|
||||
x - 3, y - 3, w, h);
|
||||
ref_v = s->edge_emu_buffer + 3 * 144 + 3;
|
||||
smc(dst_v, dst_stride, ref_v, 144, bh, mx, my, step[0], step[1]);
|
||||
} else {
|
||||
smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
|
||||
smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
|
||||
}
|
||||
}
|
||||
|
||||
#define FN(x) x##_scaled
|
||||
#define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, bw, bh, w, h, i) \
|
||||
mc_luma_scaled(s, s->dsp.s##mc, dst, dst_ls, src, src_ls, tref, row, col, \
|
||||
mv, bw, bh, w, h, s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
|
||||
#define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
|
||||
row, col, mv, bw, bh, w, h, i) \
|
||||
mc_chroma_scaled(s, s->dsp.s##mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
|
||||
row, col, mv, bw, bh, w, h, s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
|
||||
#include "vp9_mc_template.c"
|
||||
#undef mc_luma_dir
|
||||
#undef mc_chroma_dir
|
||||
#undef FN
|
||||
|
||||
static av_always_inline void mc_luma_unscaled(VP9Context *s, vp9_mc_func (*mc)[2],
|
||||
uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *ref, ptrdiff_t ref_stride,
|
||||
ThreadFrame *ref_frame,
|
||||
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
|
||||
int bw, int bh, int w, int h)
|
||||
{
|
||||
int mx = mv->x, my = mv->y, th;
|
||||
|
||||
@@ -2555,14 +2684,14 @@ static av_always_inline void mc_luma_dir(VP9Context *s, vp9_mc_func (*mc)[2],
|
||||
mc[!!mx][!!my](dst, dst_stride, ref, ref_stride, bh, mx << 1, my << 1);
|
||||
}
|
||||
|
||||
static av_always_inline void mc_chroma_dir(VP9Context *s, vp9_mc_func (*mc)[2],
|
||||
uint8_t *dst_u, uint8_t *dst_v,
|
||||
ptrdiff_t dst_stride,
|
||||
const uint8_t *ref_u, ptrdiff_t src_stride_u,
|
||||
const uint8_t *ref_v, ptrdiff_t src_stride_v,
|
||||
ThreadFrame *ref_frame,
|
||||
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
|
||||
int bw, int bh, int w, int h)
|
||||
static av_always_inline void mc_chroma_unscaled(VP9Context *s, vp9_mc_func (*mc)[2],
|
||||
uint8_t *dst_u, uint8_t *dst_v,
|
||||
ptrdiff_t dst_stride,
|
||||
const uint8_t *ref_u, ptrdiff_t src_stride_u,
|
||||
const uint8_t *ref_v, ptrdiff_t src_stride_v,
|
||||
ThreadFrame *ref_frame,
|
||||
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
|
||||
int bw, int bh, int w, int h)
|
||||
{
|
||||
int mx = mv->x, my = mv->y, th;
|
||||
|
||||
@@ -2600,156 +2729,32 @@ static av_always_inline void mc_chroma_dir(VP9Context *s, vp9_mc_func (*mc)[2],
|
||||
}
|
||||
}
|
||||
|
||||
#define FN(x) x
|
||||
#define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, bw, bh, w, h, i) \
|
||||
mc_luma_unscaled(s, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
|
||||
mv, bw, bh, w, h)
|
||||
#define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
|
||||
row, col, mv, bw, bh, w, h, i) \
|
||||
mc_chroma_unscaled(s, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
|
||||
row, col, mv, bw, bh, w, h)
|
||||
#include "vp9_mc_template.c"
|
||||
#undef mc_luma_dir_dir
|
||||
#undef mc_chroma_dir_dir
|
||||
#undef FN
|
||||
|
||||
static void inter_recon(AVCodecContext *ctx)
|
||||
{
|
||||
static const uint8_t bwlog_tab[2][N_BS_SIZES] = {
|
||||
{ 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
|
||||
{ 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },
|
||||
};
|
||||
VP9Context *s = ctx->priv_data;
|
||||
VP9Block *b = s->b;
|
||||
int row = s->row, col = s->col;
|
||||
ThreadFrame *tref1 = &s->refs[s->refidx[b->ref[0]]], *tref2;
|
||||
AVFrame *ref1 = tref1->f, *ref2;
|
||||
int w1 = ref1->width, h1 = ref1->height, w2, h2;
|
||||
ptrdiff_t ls_y = s->y_stride, ls_uv = s->uv_stride;
|
||||
|
||||
if (b->comp) {
|
||||
tref2 = &s->refs[s->refidx[b->ref[1]]];
|
||||
ref2 = tref2->f;
|
||||
w2 = ref2->width;
|
||||
h2 = ref2->height;
|
||||
}
|
||||
|
||||
// y inter pred
|
||||
if (b->bs > BS_8x8) {
|
||||
if (b->bs == BS_8x4) {
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0], 8, 4, w1, h1);
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][0],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][0], 8, 4, w1, h1);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], 8, 4, w2, h2);
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][1],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][1], 8, 4, w2, h2);
|
||||
}
|
||||
} else if (b->bs == BS_4x8) {
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0], 4, 8, w1, h1);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0] + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][0], 4, 8, w1, h1);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], 4, 8, w2, h2);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0] + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][1], 4, 8, w2, h2);
|
||||
}
|
||||
} else {
|
||||
av_assert2(b->bs == BS_4x4);
|
||||
|
||||
// FIXME if two horizontally adjacent blocks have the same MV,
|
||||
// do a w8 instead of a w4 call
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0], 4, 4, w1, h1);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0] + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][0], 4, 4, w1, h1);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][0], 4, 4, w1, h1);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
|
||||
s->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
(row << 3) + 4, (col << 3) + 4, &b->mv[3][0], 4, 4, w1, h1);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], 4, 4, w2, h2);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0] + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][1], 4, 4, w2, h2);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][1], 4, 4, w2, h2);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
|
||||
s->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
(row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, w2, h2);
|
||||
}
|
||||
}
|
||||
if (s->mvscale[b->ref[0]][0] || (b->comp && s->mvscale[b->ref[1]][0])) {
|
||||
inter_pred_scaled(ctx);
|
||||
} else {
|
||||
int bwl = bwlog_tab[0][b->bs];
|
||||
int bw = bwh_tab[0][b->bs][0] * 4, bh = bwh_tab[0][b->bs][1] * 4;
|
||||
|
||||
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0],bw, bh, w1, h1);
|
||||
|
||||
if (b->comp)
|
||||
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], bw, bh, w2, h2);
|
||||
inter_pred(ctx);
|
||||
}
|
||||
|
||||
// uv inter pred
|
||||
{
|
||||
int bwl = bwlog_tab[1][b->bs];
|
||||
int bw = bwh_tab[1][b->bs][0] * 4, bh = bwh_tab[1][b->bs][1] * 4;
|
||||
VP56mv mvuv;
|
||||
|
||||
w1 = (w1 + 1) >> 1;
|
||||
h1 = (h1 + 1) >> 1;
|
||||
if (b->comp) {
|
||||
w2 = (w2 + 1) >> 1;
|
||||
h2 = (h2 + 1) >> 1;
|
||||
}
|
||||
if (b->bs > BS_8x8) {
|
||||
mvuv.x = ROUNDED_DIV(b->mv[0][0].x + b->mv[1][0].x + b->mv[2][0].x + b->mv[3][0].x, 4);
|
||||
mvuv.y = ROUNDED_DIV(b->mv[0][0].y + b->mv[1][0].y + b->mv[2][0].y + b->mv[3][0].y, 4);
|
||||
} else {
|
||||
mvuv = b->mv[0][0];
|
||||
}
|
||||
|
||||
mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][0],
|
||||
s->dst[1], s->dst[2], ls_uv,
|
||||
ref1->data[1], ref1->linesize[1],
|
||||
ref1->data[2], ref1->linesize[2], tref1,
|
||||
row << 2, col << 2, &mvuv, bw, bh, w1, h1);
|
||||
|
||||
if (b->comp) {
|
||||
if (b->bs > BS_8x8) {
|
||||
mvuv.x = ROUNDED_DIV(b->mv[0][1].x + b->mv[1][1].x + b->mv[2][1].x + b->mv[3][1].x, 4);
|
||||
mvuv.y = ROUNDED_DIV(b->mv[0][1].y + b->mv[1][1].y + b->mv[2][1].y + b->mv[3][1].y, 4);
|
||||
} else {
|
||||
mvuv = b->mv[0][1];
|
||||
}
|
||||
mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][1],
|
||||
s->dst[1], s->dst[2], ls_uv,
|
||||
ref2->data[1], ref2->linesize[1],
|
||||
ref2->data[2], ref2->linesize[2], tref2,
|
||||
row << 2, col << 2, &mvuv, bw, bh, w2, h2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!b->skip) {
|
||||
/* mostly copied intra_reconn() */
|
||||
/* mostly copied intra_recon() */
|
||||
|
||||
int w4 = bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;
|
||||
int h4 = bwh_tab[1][b->bs][1] << 1, x, y, step = 1 << (b->tx * 2);
|
||||
@@ -3841,7 +3846,7 @@ static int vp9_decode_frame(AVCodecContext *ctx, void *frame,
|
||||
tile_row, s->tiling.log2_tile_rows, s->sb_rows);
|
||||
if (s->pass != 2) {
|
||||
for (tile_col = 0; tile_col < s->tiling.tile_cols; tile_col++) {
|
||||
unsigned tile_size;
|
||||
int64_t tile_size;
|
||||
|
||||
if (tile_col == s->tiling.tile_cols - 1 &&
|
||||
tile_row == s->tiling.tile_rows - 1) {
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* VP9 compatible video decoder
|
||||
*
|
||||
* Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
|
||||
* Copyright (C) 2013 Clément Bœsch <u pkh me>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
static void FN(inter_pred)(AVCodecContext *ctx)
|
||||
{
|
||||
static const uint8_t bwlog_tab[2][N_BS_SIZES] = {
|
||||
{ 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
|
||||
{ 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },
|
||||
};
|
||||
VP9Context *s = ctx->priv_data;
|
||||
VP9Block *b = s->b;
|
||||
int row = s->row, col = s->col;
|
||||
ThreadFrame *tref1 = &s->refs[s->refidx[b->ref[0]]], *tref2;
|
||||
AVFrame *ref1 = tref1->f, *ref2;
|
||||
int w1 = ref1->width, h1 = ref1->height, w2, h2;
|
||||
ptrdiff_t ls_y = s->y_stride, ls_uv = s->uv_stride;
|
||||
|
||||
if (b->comp) {
|
||||
tref2 = &s->refs[s->refidx[b->ref[1]]];
|
||||
ref2 = tref2->f;
|
||||
w2 = ref2->width;
|
||||
h2 = ref2->height;
|
||||
}
|
||||
|
||||
// y inter pred
|
||||
if (b->bs > BS_8x8) {
|
||||
if (b->bs == BS_8x4) {
|
||||
mc_luma_dir(s, mc[3][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0], 8, 4, w1, h1, 0);
|
||||
mc_luma_dir(s, mc[3][b->filter][0],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][0], 8, 4, w1, h1, 0);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, mc[3][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], 8, 4, w2, h2, 1);
|
||||
mc_luma_dir(s, mc[3][b->filter][1],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][1], 8, 4, w2, h2, 1);
|
||||
}
|
||||
} else if (b->bs == BS_4x8) {
|
||||
mc_luma_dir(s, mc[4][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0], 4, 8, w1, h1, 0);
|
||||
mc_luma_dir(s, mc[4][b->filter][0], s->dst[0] + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][0], 4, 8, w1, h1, 0);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, mc[4][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], 4, 8, w2, h2, 1);
|
||||
mc_luma_dir(s, mc[4][b->filter][1], s->dst[0] + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][1], 4, 8, w2, h2, 1);
|
||||
}
|
||||
} else {
|
||||
av_assert2(b->bs == BS_4x4);
|
||||
|
||||
// FIXME if two horizontally adjacent blocks have the same MV,
|
||||
// do a w8 instead of a w4 call
|
||||
mc_luma_dir(s, mc[4][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0], 4, 4, w1, h1, 0);
|
||||
mc_luma_dir(s, mc[4][b->filter][0], s->dst[0] + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][0], 4, 4, w1, h1, 0);
|
||||
mc_luma_dir(s, mc[4][b->filter][0],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][0], 4, 4, w1, h1, 0);
|
||||
mc_luma_dir(s, mc[4][b->filter][0],
|
||||
s->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
(row << 3) + 4, (col << 3) + 4, &b->mv[3][0], 4, 4, w1, h1, 0);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, mc[4][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], 4, 4, w2, h2, 1);
|
||||
mc_luma_dir(s, mc[4][b->filter][1], s->dst[0] + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, (col << 3) + 4, &b->mv[1][1], 4, 4, w2, h2, 1);
|
||||
mc_luma_dir(s, mc[4][b->filter][1],
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
(row << 3) + 4, col << 3, &b->mv[2][1], 4, 4, w2, h2, 1);
|
||||
mc_luma_dir(s, mc[4][b->filter][1],
|
||||
s->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
(row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, w2, h2, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int bwl = bwlog_tab[0][b->bs];
|
||||
int bw = bwh_tab[0][b->bs][0] * 4, bh = bwh_tab[0][b->bs][1] * 4;
|
||||
|
||||
mc_luma_dir(s, mc[bwl][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0], tref1,
|
||||
row << 3, col << 3, &b->mv[0][0],bw, bh, w1, h1, 0);
|
||||
|
||||
if (b->comp)
|
||||
mc_luma_dir(s, mc[bwl][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0], tref2,
|
||||
row << 3, col << 3, &b->mv[0][1], bw, bh, w2, h2, 1);
|
||||
}
|
||||
|
||||
// uv inter pred
|
||||
{
|
||||
int bwl = bwlog_tab[1][b->bs];
|
||||
int bw = bwh_tab[1][b->bs][0] * 4, bh = bwh_tab[1][b->bs][1] * 4;
|
||||
VP56mv mvuv;
|
||||
|
||||
w1 = (w1 + 1) >> 1;
|
||||
h1 = (h1 + 1) >> 1;
|
||||
if (b->comp) {
|
||||
w2 = (w2 + 1) >> 1;
|
||||
h2 = (h2 + 1) >> 1;
|
||||
}
|
||||
if (b->bs > BS_8x8) {
|
||||
mvuv.x = ROUNDED_DIV(b->mv[0][0].x + b->mv[1][0].x + b->mv[2][0].x + b->mv[3][0].x, 4);
|
||||
mvuv.y = ROUNDED_DIV(b->mv[0][0].y + b->mv[1][0].y + b->mv[2][0].y + b->mv[3][0].y, 4);
|
||||
} else {
|
||||
mvuv = b->mv[0][0];
|
||||
}
|
||||
|
||||
mc_chroma_dir(s, mc[bwl][b->filter][0],
|
||||
s->dst[1], s->dst[2], ls_uv,
|
||||
ref1->data[1], ref1->linesize[1],
|
||||
ref1->data[2], ref1->linesize[2], tref1,
|
||||
row << 2, col << 2, &mvuv, bw, bh, w1, h1, 0);
|
||||
|
||||
if (b->comp) {
|
||||
if (b->bs > BS_8x8) {
|
||||
mvuv.x = ROUNDED_DIV(b->mv[0][1].x + b->mv[1][1].x + b->mv[2][1].x + b->mv[3][1].x, 4);
|
||||
mvuv.y = ROUNDED_DIV(b->mv[0][1].y + b->mv[1][1].y + b->mv[2][1].y + b->mv[3][1].y, 4);
|
||||
} else {
|
||||
mvuv = b->mv[0][1];
|
||||
}
|
||||
mc_chroma_dir(s, mc[bwl][b->filter][1],
|
||||
s->dst[1], s->dst[2], ls_uv,
|
||||
ref2->data[1], ref2->linesize[1],
|
||||
ref2->data[2], ref2->linesize[2], tref2,
|
||||
row << 2, col << 2, &mvuv, bw, bh, w2, h2, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Michael Niedermayer
|
||||
* VP9 compatible video decoder
|
||||
*
|
||||
* Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
|
||||
* Copyright (C) 2013 Clément Bœsch <u pkh me>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@@ -43,6 +46,7 @@ static int parse(AVCodecParserContext *ctx,
|
||||
const uint8_t *data, int size)
|
||||
{
|
||||
VP9ParseContext *s = ctx->priv_data;
|
||||
int full_size = size;
|
||||
int marker;
|
||||
|
||||
if (size <= 0) {
|
||||
@@ -77,12 +81,12 @@ static int parse(AVCodecParserContext *ctx,
|
||||
idx += a; \
|
||||
if (sz > size) { \
|
||||
s->n_frames = 0; \
|
||||
*out_size = 0; \
|
||||
*out_size = size; \
|
||||
*out_data = data; \
|
||||
av_log(avctx, AV_LOG_ERROR, \
|
||||
"Superframe packet size too big: %u > %d\n", \
|
||||
sz, size); \
|
||||
return size; \
|
||||
return full_size; \
|
||||
} \
|
||||
if (first) { \
|
||||
first = 0; \
|
||||
|
||||
+191
-14
@@ -1707,8 +1707,9 @@ copy_avg_fn(4)
|
||||
#undef fpel_fn
|
||||
#undef copy_avg_fn
|
||||
|
||||
static const int8_t vp9_subpel_filters[3][15][8] = {
|
||||
static const int16_t vp9_subpel_filters[3][16][8] = {
|
||||
[FILTER_8TAP_REGULAR] = {
|
||||
{ 0, 0, 0, 128, 0, 0, 0, 0 },
|
||||
{ 0, 1, -5, 126, 8, -3, 1, 0 },
|
||||
{ -1, 3, -10, 122, 18, -6, 2, 0 },
|
||||
{ -1, 4, -13, 118, 27, -9, 3, -1 },
|
||||
@@ -1725,6 +1726,7 @@ static const int8_t vp9_subpel_filters[3][15][8] = {
|
||||
{ 0, 2, -6, 18, 122, -10, 3, -1 },
|
||||
{ 0, 1, -3, 8, 126, -5, 1, 0 },
|
||||
}, [FILTER_8TAP_SHARP] = {
|
||||
{ 0, 0, 0, 128, 0, 0, 0, 0 },
|
||||
{ -1, 3, -7, 127, 8, -3, 1, 0 },
|
||||
{ -2, 5, -13, 125, 17, -6, 3, -1 },
|
||||
{ -3, 7, -17, 121, 27, -10, 5, -2 },
|
||||
@@ -1741,6 +1743,7 @@ static const int8_t vp9_subpel_filters[3][15][8] = {
|
||||
{ -1, 3, -6, 17, 125, -13, 5, -2 },
|
||||
{ 0, 1, -3, 8, 127, -7, 3, -1 },
|
||||
}, [FILTER_8TAP_SMOOTH] = {
|
||||
{ 0, 0, 0, 128, 0, 0, 0, 0 },
|
||||
{ -3, -1, 32, 64, 38, 1, -3, 0 },
|
||||
{ -2, -2, 29, 63, 41, 2, -3, 0 },
|
||||
{ -2, -2, 26, 63, 43, 4, -4, 0 },
|
||||
@@ -1772,7 +1775,7 @@ static const int8_t vp9_subpel_filters[3][15][8] = {
|
||||
static av_always_inline void do_8tap_1d_c(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *src, ptrdiff_t src_stride,
|
||||
int w, int h, ptrdiff_t ds,
|
||||
const int8_t *filter, int avg)
|
||||
const int16_t *filter, int avg)
|
||||
{
|
||||
do {
|
||||
int x;
|
||||
@@ -1792,7 +1795,7 @@ static av_always_inline void do_8tap_1d_c(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
#define filter_8tap_1d_fn(opn, opa, dir, ds) \
|
||||
static av_noinline void opn##_8tap_1d_##dir##_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int w, int h, const int8_t *filter) \
|
||||
int w, int h, const int16_t *filter) \
|
||||
{ \
|
||||
do_8tap_1d_c(dst, dst_stride, src, src_stride, w, h, ds, filter, opa); \
|
||||
}
|
||||
@@ -1806,8 +1809,8 @@ filter_8tap_1d_fn(avg, 1, h, 1)
|
||||
|
||||
static av_always_inline void do_8tap_2d_c(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *src, ptrdiff_t src_stride,
|
||||
int w, int h, const int8_t *filterx,
|
||||
const int8_t *filtery, int avg)
|
||||
int w, int h, const int16_t *filterx,
|
||||
const int16_t *filtery, int avg)
|
||||
{
|
||||
int tmp_h = h + 7;
|
||||
uint8_t tmp[64 * 71], *tmp_ptr = tmp;
|
||||
@@ -1842,8 +1845,8 @@ static av_always_inline void do_8tap_2d_c(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
#define filter_8tap_2d_fn(opn, opa) \
|
||||
static av_noinline void opn##_8tap_2d_hv_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int w, int h, const int8_t *filterx, \
|
||||
const int8_t *filtery) \
|
||||
int w, int h, const int16_t *filterx, \
|
||||
const int16_t *filtery) \
|
||||
{ \
|
||||
do_8tap_2d_c(dst, dst_stride, src, src_stride, w, h, filterx, filtery, opa); \
|
||||
}
|
||||
@@ -1853,15 +1856,13 @@ filter_8tap_2d_fn(avg, 1)
|
||||
|
||||
#undef filter_8tap_2d_fn
|
||||
|
||||
#undef FILTER_8TAP
|
||||
|
||||
#define filter_fn_1d(sz, dir, dir_m, type, type_idx, avg) \
|
||||
static void avg##_8tap_##type##_##sz##dir##_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int h, int mx, int my) \
|
||||
{ \
|
||||
avg##_8tap_1d_##dir##_c(dst, dst_stride, src, src_stride, sz, h, \
|
||||
vp9_subpel_filters[type_idx][dir_m - 1]); \
|
||||
vp9_subpel_filters[type_idx][dir_m]); \
|
||||
}
|
||||
|
||||
#define filter_fn_2d(sz, type, type_idx, avg) \
|
||||
@@ -1870,8 +1871,8 @@ static void avg##_8tap_##type##_##sz##hv_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
int h, int mx, int my) \
|
||||
{ \
|
||||
avg##_8tap_2d_hv_c(dst, dst_stride, src, src_stride, sz, h, \
|
||||
vp9_subpel_filters[type_idx][mx - 1], \
|
||||
vp9_subpel_filters[type_idx][my - 1]); \
|
||||
vp9_subpel_filters[type_idx][mx], \
|
||||
vp9_subpel_filters[type_idx][my]); \
|
||||
}
|
||||
|
||||
#define FILTER_BILIN(src, x, mxy, stride) \
|
||||
@@ -1957,8 +1958,6 @@ bilin_2d_fn(avg, 1)
|
||||
|
||||
#undef bilin_2d_fn
|
||||
|
||||
#undef FILTER_BILIN
|
||||
|
||||
#define bilinf_fn_1d(sz, dir, dir_m, avg) \
|
||||
static void avg##_bilin_##sz##dir##_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
@@ -2053,12 +2052,190 @@ static av_cold void vp9dsp_mc_init(VP9DSPContext *dsp)
|
||||
#undef init_subpel3
|
||||
}
|
||||
|
||||
static av_always_inline void do_scaled_8tap_c(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *src, ptrdiff_t src_stride,
|
||||
int w, int h, int mx, int my,
|
||||
int dx, int dy, int avg,
|
||||
const int16_t (*filters)[8])
|
||||
{
|
||||
int tmp_h = (((h - 1) * dy + my) >> 4) + 8;
|
||||
uint8_t tmp[64 * 135], *tmp_ptr = tmp;
|
||||
|
||||
src -= src_stride * 3;
|
||||
do {
|
||||
int x;
|
||||
int imx = mx, ioff = 0;
|
||||
|
||||
for (x = 0; x < w; x++) {
|
||||
tmp_ptr[x] = FILTER_8TAP(src, ioff, filters[imx], 1);
|
||||
imx += dx;
|
||||
ioff += imx >> 4;
|
||||
imx &= 0xf;
|
||||
}
|
||||
|
||||
tmp_ptr += 64;
|
||||
src += src_stride;
|
||||
} while (--tmp_h);
|
||||
|
||||
tmp_ptr = tmp + 64 * 3;
|
||||
do {
|
||||
int x;
|
||||
const int16_t *filter = filters[my];
|
||||
|
||||
for (x = 0; x < w; x++)
|
||||
if (avg) {
|
||||
dst[x] = (dst[x] + FILTER_8TAP(tmp_ptr, x, filter, 64) + 1) >> 1;
|
||||
} else {
|
||||
dst[x] = FILTER_8TAP(tmp_ptr, x, filter, 64);
|
||||
}
|
||||
|
||||
my += dy;
|
||||
tmp_ptr += (my >> 4) * 64;
|
||||
my &= 0xf;
|
||||
dst += dst_stride;
|
||||
} while (--h);
|
||||
}
|
||||
|
||||
#define scaled_filter_8tap_fn(opn, opa) \
|
||||
static av_noinline void opn##_scaled_8tap_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int w, int h, int mx, int my, int dx, int dy, \
|
||||
const int16_t (*filters)[8]) \
|
||||
{ \
|
||||
do_scaled_8tap_c(dst, dst_stride, src, src_stride, w, h, mx, my, dx, dy, \
|
||||
opa, filters); \
|
||||
}
|
||||
|
||||
scaled_filter_8tap_fn(put, 0)
|
||||
scaled_filter_8tap_fn(avg, 1)
|
||||
|
||||
#undef scaled_filter_8tap_fn
|
||||
|
||||
#undef FILTER_8TAP
|
||||
|
||||
#define scaled_filter_fn(sz, type, type_idx, avg) \
|
||||
static void avg##_scaled_##type##_##sz##_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int h, int mx, int my, int dx, int dy) \
|
||||
{ \
|
||||
avg##_scaled_8tap_c(dst, dst_stride, src, src_stride, sz, h, mx, my, dx, dy, \
|
||||
vp9_subpel_filters[type_idx]); \
|
||||
}
|
||||
|
||||
static av_always_inline void do_scaled_bilin_c(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *src, ptrdiff_t src_stride,
|
||||
int w, int h, int mx, int my,
|
||||
int dx, int dy, int avg)
|
||||
{
|
||||
uint8_t tmp[64 * 129], *tmp_ptr = tmp;
|
||||
int tmp_h = (((h - 1) * dy + my) >> 4) + 2;
|
||||
|
||||
do {
|
||||
int x;
|
||||
int imx = mx, ioff = 0;
|
||||
|
||||
for (x = 0; x < w; x++) {
|
||||
tmp_ptr[x] = FILTER_BILIN(src, ioff, imx, 1);
|
||||
imx += dx;
|
||||
ioff += imx >> 4;
|
||||
imx &= 0xf;
|
||||
}
|
||||
|
||||
tmp_ptr += 64;
|
||||
src += src_stride;
|
||||
} while (--tmp_h);
|
||||
|
||||
tmp_ptr = tmp;
|
||||
do {
|
||||
int x;
|
||||
|
||||
for (x = 0; x < w; x++)
|
||||
if (avg) {
|
||||
dst[x] = (dst[x] + FILTER_BILIN(tmp_ptr, x, my, 64) + 1) >> 1;
|
||||
} else {
|
||||
dst[x] = FILTER_BILIN(tmp_ptr, x, my, 64);
|
||||
}
|
||||
|
||||
my += dy;
|
||||
tmp_ptr += (my >> 4) * 64;
|
||||
my &= 0xf;
|
||||
dst += dst_stride;
|
||||
} while (--h);
|
||||
}
|
||||
|
||||
#define scaled_bilin_fn(opn, opa) \
|
||||
static av_noinline void opn##_scaled_bilin_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int w, int h, int mx, int my, int dx, int dy) \
|
||||
{ \
|
||||
do_scaled_bilin_c(dst, dst_stride, src, src_stride, w, h, mx, my, dx, dy, opa); \
|
||||
}
|
||||
|
||||
scaled_bilin_fn(put, 0)
|
||||
scaled_bilin_fn(avg, 1)
|
||||
|
||||
#undef scaled_bilin_fn
|
||||
|
||||
#undef FILTER_BILIN
|
||||
|
||||
#define scaled_bilinf_fn(sz, avg) \
|
||||
static void avg##_scaled_bilin_##sz##_c(uint8_t *dst, ptrdiff_t dst_stride, \
|
||||
const uint8_t *src, ptrdiff_t src_stride, \
|
||||
int h, int mx, int my, int dx, int dy) \
|
||||
{ \
|
||||
avg##_scaled_bilin_c(dst, dst_stride, src, src_stride, sz, h, mx, my, dx, dy); \
|
||||
}
|
||||
|
||||
#define scaled_filter_fns(sz, avg) \
|
||||
scaled_filter_fn(sz, regular, FILTER_8TAP_REGULAR, avg) \
|
||||
scaled_filter_fn(sz, smooth, FILTER_8TAP_SMOOTH, avg) \
|
||||
scaled_filter_fn(sz, sharp, FILTER_8TAP_SHARP, avg) \
|
||||
scaled_bilinf_fn(sz, avg)
|
||||
|
||||
#define scaled_filter_fn_set(avg) \
|
||||
scaled_filter_fns(64, avg) \
|
||||
scaled_filter_fns(32, avg) \
|
||||
scaled_filter_fns(16, avg) \
|
||||
scaled_filter_fns(8, avg) \
|
||||
scaled_filter_fns(4, avg)
|
||||
|
||||
scaled_filter_fn_set(put)
|
||||
scaled_filter_fn_set(avg)
|
||||
|
||||
#undef scaled_filter_fns
|
||||
#undef scaled_filter_fn_set
|
||||
#undef scaled_filter_fn
|
||||
#undef scaled_bilinf_fn
|
||||
|
||||
static av_cold void vp9dsp_scaled_mc_init(VP9DSPContext *dsp)
|
||||
{
|
||||
#define init_scaled(idx1, idx2, sz, type) \
|
||||
dsp->smc[idx1][FILTER_8TAP_SMOOTH ][idx2] = type##_scaled_smooth_##sz##_c; \
|
||||
dsp->smc[idx1][FILTER_8TAP_REGULAR][idx2] = type##_scaled_regular_##sz##_c; \
|
||||
dsp->smc[idx1][FILTER_8TAP_SHARP ][idx2] = type##_scaled_sharp_##sz##_c; \
|
||||
dsp->smc[idx1][FILTER_BILINEAR ][idx2] = type##_scaled_bilin_##sz##_c
|
||||
|
||||
#define init_scaled_put_avg(idx, sz) \
|
||||
init_scaled(idx, 0, sz, put); \
|
||||
init_scaled(idx, 1, sz, avg)
|
||||
|
||||
init_scaled_put_avg(0, 64);
|
||||
init_scaled_put_avg(1, 32);
|
||||
init_scaled_put_avg(2, 16);
|
||||
init_scaled_put_avg(3, 8);
|
||||
init_scaled_put_avg(4, 4);
|
||||
|
||||
#undef init_scaled_put_avg
|
||||
#undef init_scaled
|
||||
}
|
||||
|
||||
av_cold void ff_vp9dsp_init(VP9DSPContext *dsp)
|
||||
{
|
||||
vp9dsp_intrapred_init(dsp);
|
||||
vp9dsp_itxfm_init(dsp);
|
||||
vp9dsp_loopfilter_init(dsp);
|
||||
vp9dsp_mc_init(dsp);
|
||||
vp9dsp_scaled_mc_init(dsp);
|
||||
|
||||
if (ARCH_X86) ff_vp9dsp_init_x86(dsp);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
typedef void (*vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *ref, ptrdiff_t ref_stride,
|
||||
int h, int mx, int my);
|
||||
typedef void (*vp9_scaled_mc_func)(uint8_t *dst, ptrdiff_t dst_stride,
|
||||
const uint8_t *ref, ptrdiff_t ref_stride,
|
||||
int h, int mx, int my, int dx, int dy);
|
||||
|
||||
typedef struct VP9DSPContext {
|
||||
/*
|
||||
@@ -109,6 +112,12 @@ typedef struct VP9DSPContext {
|
||||
* dst/stride are aligned by hsize
|
||||
*/
|
||||
vp9_mc_func mc[5][4][2][2][2];
|
||||
|
||||
/*
|
||||
* for scalable MC, first 3 dimensions identical to above, the other two
|
||||
* don't exist since it changes per stepsize.
|
||||
*/
|
||||
vp9_scaled_mc_func smc[5][4][2];
|
||||
} VP9DSPContext;
|
||||
|
||||
void ff_vp9dsp_init(VP9DSPContext *dsp);
|
||||
|
||||
@@ -155,7 +155,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb,
|
||||
if (t >= 2) {
|
||||
if (get_bits_left(gb) < t - 1)
|
||||
goto error;
|
||||
t = get_bits(gb, t - 1) | (1 << (t - 1));
|
||||
t = get_bits_long(gb, t - 1) | (1 << (t - 1));
|
||||
} else {
|
||||
if (get_bits_left(gb) < 0)
|
||||
goto error;
|
||||
@@ -186,7 +186,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb,
|
||||
} else {
|
||||
if (get_bits_left(gb) < t2 - 1)
|
||||
goto error;
|
||||
t += get_bits(gb, t2 - 1) | (1 << (t2 - 1));
|
||||
t += get_bits_long(gb, t2 - 1) | (1 << (t2 - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc,
|
||||
|
||||
if (s->got_extra_bits &&
|
||||
get_bits_left(&s->gb_extra_bits) >= s->extra_bits) {
|
||||
S |= get_bits(&s->gb_extra_bits, s->extra_bits);
|
||||
S |= get_bits_long(&s->gb_extra_bits, s->extra_bits);
|
||||
*crc = *crc * 9 + (S & 0xffff) * 3 + ((unsigned)S >> 16);
|
||||
}
|
||||
}
|
||||
@@ -835,7 +835,11 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
|
||||
continue;
|
||||
}
|
||||
bytestream2_get_buffer(&gb, val, 4);
|
||||
if (val[0]) {
|
||||
if (val[0] > 32) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Invalid INT32INFO, extra_bits = %d (> 32)\n", val[0]);
|
||||
continue;
|
||||
} else if (val[0]) {
|
||||
s->extra_bits = val[0];
|
||||
} else if (val[1]) {
|
||||
s->shift = val[1];
|
||||
|
||||
@@ -487,7 +487,7 @@ static int decode_cdlms(WmallDecodeCtx *s)
|
||||
if ((1 << cbits) < s->cdlms[c][i].scaling + 1)
|
||||
cbits++;
|
||||
|
||||
s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2;
|
||||
s->cdlms[c][i].bitsend = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
|
||||
shift_l = 32 - s->cdlms[c][i].bitsend;
|
||||
shift_r = 32 - s->cdlms[c][i].scaling - 2;
|
||||
for (j = 0; j < s->cdlms[c][i].coefsend; j++)
|
||||
@@ -1029,6 +1029,7 @@ static int decode_frame(WmallDecodeCtx *s)
|
||||
if ((ret = ff_get_buffer(s->avctx, s->frame, 0)) < 0) {
|
||||
/* return an error if no frame could be decoded at all */
|
||||
s->packet_loss = 1;
|
||||
s->frame->nb_samples = 0;
|
||||
return ret;
|
||||
}
|
||||
for (i = 0; i < s->num_channels; i++) {
|
||||
|
||||
+12
-1
@@ -296,6 +296,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
s->decode_flags = AV_RL16(edata_ptr+14);
|
||||
channel_mask = AV_RL32(edata_ptr+2);
|
||||
s->bits_per_sample = AV_RL16(edata_ptr);
|
||||
|
||||
if (s->bits_per_sample > 32 || s->bits_per_sample < 1) {
|
||||
avpriv_request_sample(avctx, "bits per sample is %d", s->bits_per_sample);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
/** dump the extradata */
|
||||
for (i = 0; i < avctx->extradata_size; i++)
|
||||
av_dlog(avctx, "[%x] ", avctx->extradata[i]);
|
||||
@@ -473,7 +479,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
/** calculate subwoofer cutoff values */
|
||||
for (i = 0; i < num_possible_block_sizes; i++) {
|
||||
int block_size = s->samples_per_frame >> i;
|
||||
int cutoff = (440*block_size + 3 * (s->avctx->sample_rate >> 1) - 1)
|
||||
int cutoff = (440*block_size + 3LL * (s->avctx->sample_rate >> 1) - 1)
|
||||
/ s->avctx->sample_rate;
|
||||
s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size);
|
||||
}
|
||||
@@ -1619,6 +1625,11 @@ static int decode_packet(AVCodecContext *avctx, void *data,
|
||||
s->packet_done = 1;
|
||||
}
|
||||
|
||||
if (remaining_bits(s, gb) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Overread %d\n", -remaining_bits(s, gb));
|
||||
s->packet_loss = 1;
|
||||
}
|
||||
|
||||
if (s->packet_done && !s->packet_loss &&
|
||||
remaining_bits(s, gb) > 0) {
|
||||
/** save the rest of the data so that it can be decoded
|
||||
|
||||
+16
-2
@@ -1982,7 +1982,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
|
||||
*got_frame_ptr) {
|
||||
cnt += s->spillover_nbits;
|
||||
s->skip_bits_next = cnt & 7;
|
||||
return cnt >> 3;
|
||||
res = cnt >> 3;
|
||||
if (res > avpkt->size) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Trying to skip %d bytes in packet of size %d\n",
|
||||
res, avpkt->size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
return res;
|
||||
} else
|
||||
skip_bits_long (gb, s->spillover_nbits - cnt +
|
||||
get_bits_count(gb)); // resync
|
||||
@@ -2001,7 +2008,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
|
||||
} else if (*got_frame_ptr) {
|
||||
int cnt = get_bits_count(gb);
|
||||
s->skip_bits_next = cnt & 7;
|
||||
return cnt >> 3;
|
||||
res = cnt >> 3;
|
||||
if (res > avpkt->size) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Trying to skip %d bytes in packet of size %d\n",
|
||||
res, avpkt->size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
return res;
|
||||
} else if ((s->sframe_cache_size = pos) > 0) {
|
||||
/* rewind bit reader to start of last (incomplete) superframe... */
|
||||
init_get_bits(gb, avpkt->data, size << 3);
|
||||
|
||||
@@ -135,8 +135,11 @@ WEIGHT_FUNC_HALF_MM 8, 8
|
||||
add off_regd, 1
|
||||
or off_regd, 1
|
||||
add r4, 1
|
||||
cmp r6d, 128
|
||||
je .nonnormal
|
||||
cmp r5, 128
|
||||
jne .normal
|
||||
.nonnormal
|
||||
sar r5, 1
|
||||
sar r6, 1
|
||||
sar off_regd, 1
|
||||
|
||||
@@ -381,6 +381,7 @@ apply_noise_main:
|
||||
%else
|
||||
%define count m_maxq
|
||||
%endif
|
||||
movsxdifnidn noiseq, noised
|
||||
dec noiseq
|
||||
shl count, 2
|
||||
%ifdef PIC
|
||||
|
||||
@@ -185,8 +185,12 @@ hvar_fn
|
||||
%elif (%2-%%off) == 2
|
||||
mov valw, [srcq+%2-2]
|
||||
%elifidn %1, body
|
||||
mov vald, [srcq+%2-3]
|
||||
%else
|
||||
mov valb, [srcq+%2-1]
|
||||
sal vald, 16
|
||||
mov valw, [srcq+%2-3]
|
||||
%elifidn %1, bottom
|
||||
movd mm %+ %%mmx_idx, [srcq+%2-4]
|
||||
%else ; top
|
||||
movd mm %+ %%mmx_idx, [srcq+%2-3]
|
||||
%endif
|
||||
%endif ; (%2-%%off) >= 1
|
||||
@@ -242,12 +246,15 @@ hvar_fn
|
||||
mov [dstq+%2-2], valw
|
||||
%elifidn %1, body
|
||||
mov [dstq+%2-3], valw
|
||||
shr vald, 16
|
||||
sar vald, 16
|
||||
mov [dstq+%2-1], valb
|
||||
%else
|
||||
movd vald, mm %+ %%mmx_idx
|
||||
%ifidn %1, bottom
|
||||
sar vald, 8
|
||||
%endif
|
||||
mov [dstq+%2-3], valw
|
||||
shr vald, 16
|
||||
sar vald, 16
|
||||
mov [dstq+%2-1], valb
|
||||
%endif
|
||||
%endif ; (%2-%%off) >= 1
|
||||
|
||||
+1
-1
@@ -339,7 +339,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
|
||||
continue;
|
||||
} else if (ret < 0)
|
||||
return ret;
|
||||
d = av_rescale_q(frame->pts, tb, AV_TIME_BASE_Q);
|
||||
d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
av_dlog(avctx, "sink_idx:%d time:%f\n", i, d);
|
||||
av_frame_unref(frame);
|
||||
|
||||
|
||||
@@ -86,15 +86,24 @@ static int query_formats(AVFilterContext *ctx)
|
||||
AVFilterLink *inlink = ctx->inputs[0];
|
||||
AVFilterLink *outlink = ctx->outputs[0];
|
||||
|
||||
AVFilterFormats *in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
|
||||
AVFilterFormats *out_formats;
|
||||
AVFilterFormats *in_samplerates = ff_all_samplerates();
|
||||
AVFilterFormats *out_samplerates;
|
||||
AVFilterChannelLayouts *in_layouts = ff_all_channel_counts();
|
||||
AVFilterChannelLayouts *out_layouts;
|
||||
AVFilterFormats *in_formats, *out_formats;
|
||||
AVFilterFormats *in_samplerates, *out_samplerates;
|
||||
AVFilterChannelLayouts *in_layouts, *out_layouts;
|
||||
|
||||
|
||||
in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
|
||||
if (!in_formats)
|
||||
return AVERROR(ENOMEM);
|
||||
ff_formats_ref (in_formats, &inlink->out_formats);
|
||||
|
||||
in_samplerates = ff_all_samplerates();
|
||||
if (!in_samplerates)
|
||||
return AVERROR(ENOMEM);
|
||||
ff_formats_ref (in_samplerates, &inlink->out_samplerates);
|
||||
|
||||
in_layouts = ff_all_channel_counts();
|
||||
if (!in_layouts)
|
||||
return AVERROR(ENOMEM);
|
||||
ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts);
|
||||
|
||||
if(out_rate > 0) {
|
||||
|
||||
@@ -205,7 +205,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
|
||||
delta = pts - s->pts - get_delay(s);
|
||||
out_size = avresample_available(s->avr);
|
||||
|
||||
if (labs(delta) > s->min_delta ||
|
||||
if (llabs(delta) > s->min_delta ||
|
||||
(s->first_frame && delta && s->first_pts != AV_NOPTS_VALUE)) {
|
||||
av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta);
|
||||
out_size = av_clipl_int32((int64_t)out_size + delta);
|
||||
|
||||
@@ -152,7 +152,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
|
||||
int hsub = plane == 1 || plane == 2 ? trans->hsub : 0;
|
||||
int vsub = plane == 1 || plane == 2 ? trans->vsub : 0;
|
||||
int pixstep = trans->pixsteps[plane];
|
||||
int inh = in->height >> vsub;
|
||||
int inh = FF_CEIL_RSHIFT(in->height, vsub);
|
||||
int outw = FF_CEIL_RSHIFT(out->width, hsub);
|
||||
int outh = FF_CEIL_RSHIFT(out->height, vsub);
|
||||
int start = (outh * jobnr ) / nb_jobs;
|
||||
|
||||
@@ -27,8 +27,8 @@ SECTION .text
|
||||
%if lut_bits != 8
|
||||
sar %1q, 8-lut_bits
|
||||
%endif
|
||||
movsx %1d, word [%3q+%1q*2]
|
||||
add %1d, %2d
|
||||
movsx %1q, word [%3q+%1q*2]
|
||||
add %1q, %2q
|
||||
%endmacro
|
||||
|
||||
%macro LOAD 3 ; dstreg, x, bitdepth
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ static int read_header(AVFormatContext *s)
|
||||
|
||||
avio_skip(pb, 16);
|
||||
size=avio_rl32(pb);
|
||||
ff_get_wav_header(pb, st->codec, size);
|
||||
ff_get_wav_header(s, pb, st->codec, size);
|
||||
|
||||
/*
|
||||
8000Hz (Fine-rec) file format has 10 bytes long
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user