Compare commits

...

86 Commits

Author SHA1 Message Date
Michael Niedermayer fd26b07e8b Bump versions after 5.1 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-13 00:29:05 +02:00
Michael Niedermayer 6f1b144358 Bump Versions for 5.1 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-13 00:27:37 +02:00
Michael Niedermayer 3421476eb5 doc/APIchanges: Add 5.1 branch cutpoint
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-13 00:04:15 +02:00
Michael Niedermayer 510cd7d11b doc/APIchanges: Fill in missing things
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 23:58:55 +02:00
Michael Niedermayer eafe641d13 doc/APIchanges: Extend hash which has become ambiguous
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 23:58:31 +02:00
Michael Niedermayer f7dd408d64 avcodec/h264dec: Skip late SEI
Fixes: Race condition
Fixes: clusterfuzz-testcase-minimized-mediasource_MP2T_AVC_pipeline_integration_fuzzer-6282675434094592

Found-by: google ClusterFuzz
Tested-by: Dan Sanders <sandersd@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 1537f40516 avcodec/sbrdsp_fixed: Fix integer overflows in sbr_qmf_deint_neg_c()
Fixes: signed integer overflow: 2147483645 + 16 cannot be represented in type 'int'
Fixes: 46993/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-4759025234870272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 4f9ee4bf43 avcodec/pixlet: consider minimum plane header in the minimal packet size
Fixes: Timeout
Fixes: 46956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-5698161106092032

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer dd6040675e avfilter/vf_signature: Fix integer overflow in filter_frame()
Fixes: CID1403233

The second of the 2 changes may be unneeded but will help coverity

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 73c0fd27c5 avformat/rtsp: break on unknown protocols
This function needs more cleanup and it lacks error handling

Fixes: use of uninitialized memory
Fixes: CID700776

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 9c5250a561 avcodec/hevcdsp_template: stay within tables in sao_band_filter()
Fixes: out of array read
Fixes: 47875/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5719393113341952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer a5625fecd7 tools/target_dec_fuzzer: adjust threshold for flic
Fixes: Timeout
Fixes: 48017/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLIC_fuzzer-5920256150863872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer f20295cd81 tools/target_dec_fuzzer: Adjust threshold for AASC
Fixes: Timeout
Fixes: 47919/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AASC_fuzzer-5176435830030336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 75f3d1b822 avcodec/tiff: Check pixel format types for dng
Fixes: out of array access
Fixes: 48271/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6149705769287680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 675e18e0fb tools/target_dec_fuzzer: adjust threshold for cinepak
Fixes: Timeout
Fixes: 48158/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CINEPAK_fuzzer-5986526573494272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer e690d4edf5 avcodec/qpeldsp: copy less for the mc0x cases
Fixes: out of array access
Fixes: 47936/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5745039940124672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer db31b3ea86 avformat/aaxdec: Check for empty segments
Fixes: Timeout
Fixes: 48154/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-5149094353436672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 78b95530f0 avcodec/ffv1dec: Check for min packet size
Fixes: Timeout
Fixes: 48619/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5793597923917824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer ba0c3d1db4 avformat/avienc: Check video dimensions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer b4431399ec avcodec/ffv1dec: Limit golomb rice coded slices to width 8M
This limit is possibly not reachable due to other restrictions on buffers but
the decoder run table is too small beyond this, so explicitly check for it.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 248d981071 tools/target_dec_fuzzer: Adjust threshold for LOCO
Fixes: Timeout
Fixes: 48584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LOCO_fuzzer-5741269015461888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 6003fe6344 tools/target_dec_fuzzer: Adjust threshold for ylc
Fixes: timeout
Fixes: 48523/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_YLC_fuzzer-5779666425741312

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 35ea9590ff tools/target_dec_fuzzer: Adjust threshold for WCMV
Fixes: Timeout
Fixes: 48377/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5053331682230272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 5bfa59b2de tools/target_dec_fuzzer: Adjust threshold for CDTOONS
Fixes: Timeout
Fixes: 48730/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDTOONS_fuzzer-5124342899408896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 0740641e93 avformat/iff: simplify duration calculation
Fixes: signed integer overflow: 315680096256 * 134215943 cannot be represented in type 'long long'
Fixes: 48713/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5886272312311808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer bb6679a58b tools/target_dec_fuzzer: Adjust threshold for MVC2
Fixes: Timeout
Fixes: 48689/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVC2_fuzzer-6436301427048448

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 2ebd2a6eb5 tools/target_dec_fuzzer: Adjust threshold for CFHD
Fixes: Timeout
Fixes: 46504/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6376835606249472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer d98d5a436a avcodec/wnv1: Check for width =1
The decoder only outputs pixels for width >1 images, fail early

Fixes: Timeout
Fixes: 48298/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WNV1_fuzzer-6198626319204352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer eee7364c90 avcodec/ffv1dec_template: fix indention
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer 21938ce739 tools/target_dec_fuzzer: Adjust threshold for ANM
Fixes: Timeout
Fixes: 48923/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ANM_fuzzer-6391662321991680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
ShuangxiLi 046b05082d avformat/mov: fix possible crash in cenc_scheme_decrypt
Data does not have to be decrypted in 16-byte blocks for AES-CTR mode, so
existing buggy code can be hugely simplified.

Fixes ticket #9829.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-12 18:48:54 +02:00
George Floarea 9222965fdd avfilter/vf_xfade: fix zx and zy comparison for slide*
This resulted in the wrong column/row being chosen.
This can be seen best when using xfade on streams with transparency.

For example: in case of a slideleft transition, the first column from
the first input will overwrite the first column of the second stream
throught the transition.
2022-07-12 16:32:30 +02:00
Hubert Mazur eb7ab3928f lavc/aarch64: Hook up the existing ff_pix_abs16_neon to the sad[0] function pointer
Signed-off-by: Hubert Mazur <hum@semihalf.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-07-11 23:58:28 +03:00
Marton Balint 846488cca8 avfilter/vf_zscale: enable AVX512 zimg functions
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-10 22:35:20 +02:00
Marton Balint a6f0e641bc avfilter/vf_zscale: simplify and fix slice_params calculations
Do not insist on a fixed slice height, because that can still cause overflows
in corner cases as described in this comment:

https://github.com/sekrit-twc/zimg/issues/177#issuecomment-1157734233

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-10 22:35:20 +02:00
Marton Balint 68fdc9de84 avfilter/vf_zscale: remove some unneeded initializations
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-10 22:35:20 +02:00
Timo Rothenpieler be983d2354 configure: add missing deps for chromakey_cuda filter
Not sure how those went missing at some point during the review process,
but it went unnoticed since all my test machines obviously have the
deps.
2022-07-10 17:42:58 +02:00
Mohamed Khaled Mohamed b1648150b2 avfilter: add chromakey_cuda filter
GSoC'22

libavfilter/vf_chromakey_cuda.cu:the CUDA kernel for the filter
libavfilter/vf_chromakey_cuda.c: the C side that calls the kernel and gets user input
libavfilter/allfilters.c: added the filter to it
libavfilter/Makefile: added the filter to it
cuda/cuda_runtime.h: added two math CUDA functions that are used in the filter

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-07-10 17:20:15 +02:00
Andreas Rheinhardt 538cbaf18e fate/pcm: Add pcm_dvd transcode tests
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-10 16:58:58 +02:00
Andreas Rheinhardt d0b050562a avcodec/pcm-dvdenc: Fix encoding 24bit samples
The earlier code ignored the lower 16 bits and instead used
the highest 8 bits twice.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-10 16:58:43 +02:00
Andreas Rheinhardt 7259eef711 avcodec/pcm-dvdenc: Remove unused extra_sample(s|_count)
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-10 16:58:07 +02:00
dvhh c6fdbe26ef configure: fix SDL2 version check for pkg_config fallback
pkg_config fallback for SDL2 use 2.1.0 as max (excluded) version
where the pkg_config specify 3.0.0
Correcting fallback version to be in line with the pkg_config version

Signed-off-by: dvhh <dvhh@yahoo.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-09 21:33:38 +02:00
Wenbin Chen bd7dae7daf avcodec/mpegvideo_enc: Unify the code style
Change whitespace and add newline to unify the code style.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-09 21:05:02 +02:00
Wenbin Chen 76b33704b6 avcodec/mpegvideo_enc: Fix a chroma mb size error in sse_mb()
For 422 frames we should not use hard coded 8 to calculate mb size for
uv plane. Chroma shift should be taken into consideration to be
compatiple with different sampling format.

The error is reported by fate test when av_cpu_max_align() return 64
on the platform supporting AVX512. This is a hidden error and it is
exposed after commit 17a59a634c.

mpeg2enc has a mechanism to reuse frames. When it computes SSE (sum of
squared error) on current mb, reconstructed mb will be wrote to the
previous mb space, so that the memory can be saved. However if the align
is 64, the frame is shared in somewhere else, so the frame cannot be
reused and a new frame to store reconstrued data is created. Because the
height of mb is wrong when compute sse on 422 frame, starting from the
second line of macro block, changed data is read when frame is reused
(we need to read row 16 rather than row 8 if frame is 422), and unchanged
data is read when frame is not reused (a new frame is created so the
original frame will not be changed).

That is why commit 17a59a634c exposes this
issue, because it add av_cpu_max_align() and this function return 64 on
platform supporting AVX512 which lead to creating a frame in mpeg2enc,
and this lead to the different outputs.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-09 21:05:02 +02:00
Andreas Rheinhardt 8393c0721a avcodec/hevc_cabac: Don't cast const away unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:29:26 +02:00
Andreas Rheinhardt c34e3920f2 avcodec/hevc_refs: Constify ff_hevc_get_ref_list()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:28:02 +02:00
Andreas Rheinhardt 5f176bbc9a fate/h264: Add Active Format Descriptor test
Some samples contain Active Format Descriptors, yet the output
of no test depends upon them, so that they are de-facto untested.
So add a dedicated test for them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:24:31 +02:00
Andreas Rheinhardt c6134ce65f fftools/ffprobe: Improve description of AFD side data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:21:31 +02:00
Andreas Rheinhardt aba0cc4465 avcodec/hevc_sei: Use proper type for NALU type
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:19:29 +02:00
Andreas Rheinhardt 6f5e0a7294 avformat/flvenc: Add deinit function
Fixes memleaks when the trailer is never written or when shift_data()
fails when writing the trailer.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:16:39 +02:00
Andreas Rheinhardt 75a2d25a6f avcodec/h26[45]_metadata_bsf: Fix range of chroma_sample_loc_type
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:10:21 +02:00
Andreas Rheinhardt 12392ffee5 avcodec/hevc_ps: Fix wrong copyright years
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:10:11 +02:00
Andreas Rheinhardt 3524e82a08 avcodec/dv: Remove unnecessary header
Forgotten in 6d484671ec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:06:47 +02:00
Andreas Rheinhardt ad5040a442 avcodec/cbs: Mark init and close functions as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:05:14 +02:00
Andreas Rheinhardt e4f7a2b003 avcodec/encode: Avoid check whose result is known in advance
encode_send_frame_internal() is always only called if
the buffer packet is empty and except when we are dealing
with an audio codec that does not allow variable frame size
it stays that way until a call to av_frame_ref() at the end
of encode_send_frame_internal(). In case we are dealing
with the small last frame of an audio encoder requiring
constant frame size the frame will be allocated by pad_last_frame()
and this the only case where this is so. So by returning directly
after pad_last_frame(), we can avoid having to recheck
whether the frame is still empty before av_frame_ref().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:03:37 +02:00
Andreas Rheinhardt a256426411 avformat/movenc: Ensure packet is writable before modifying it
Fixes e.g.

ffmpeg -i fate-suite/h264/bbc2.sample.h264 -c:v rawvideo -map 0:v -frames:v 10 -pix_fmt gray8 -f tee "first.mov|second.mov"

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt dc977f94d5 fftools/ffprobe: Add const to AVPacket data pointers
These packets need not be writable (and are not modified by us),
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt 4ad686269d avcodec: Add const to decoder packet data pointers
The packets given to decoder need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt d5a0eba8a2 av(format|device): Add const to muxer packet data pointers
The packets given to muxers need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt 417554bdd6 avformat/apngenc: Add const where possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt 05e96e6933 avformat/apngenc: Don't modify input packet
It might not be writable at this point.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt f89446eaff avformat/apngenc: Check fcTL size
The remaining code relies on it having the value it should have.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt 3204572a1a avformat/apngenc: Check for incomplete chunks
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:52 +02:00
Andreas Rheinhardt e4a10dd637 avcodec/apng: Add APNG_FCTL_CHUNK_SIZE define
Also use it where appropriate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:52 +02:00
Brion Vibber 66a251e836 Support for 16:9 DV in QuickTime
Some files I have from circa year 2000 are 16:9 NTSC DV video
encoded as QuickTime with Radius SoftDV. This marked 4:3 videos
with the box 'dvc ' for NTSC or 'dvcp' for PAL, which are already
supported, but 16:9 videos as 'dvl ' or 'dvlp', which were not.

Adding these to the list for DV codec processing gives the
expected metadata and playback.

I have not tested PAL as I have no sample data, only NTSC.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-09 19:03:28 +02:00
Paul B Mahol fc1ca18fcf avfilter/vf_xfade: add two more transitions 2022-07-09 16:55:50 +02:00
James Almer f9785a78da avcodec/aacdec: fix parsing of dual mono files
Dual mono files report a channel count of 2 with each individual channel in its
own SCE, instead of both in a single CPE as is the case with standard stereo.
This commit handles this non default channel configuration scenario.

Fixes ticket #1614

Signed-off-by: James Almer <jamrial@gmail.com>
2022-07-08 10:05:24 -03:00
Nicolas Gaullier d3cf7be5a4 fftools: Fix preset search pathes
regression since 13350e81fd

Fix looking for .ffmpeg subfolder in FFMPEG_DATADIR and inversely not in HOME.
Fix search order (documentation).

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-07-08 13:58:49 +02:00
Andreas Schneider 59018254c7 avcodec/openh264: return (DE|EN)CODER_NOT_FOUND if version check fails
A cosmetic change only, it basically just changes the user facing error message
to clients that interpret the errors to something that makes sense.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-08 00:49:37 +02:00
Michael Niedermayer c9a2996544 avformat/sctp: close socket on errors
This is untested as i have no testcase

Fixes: CID1302709

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer b418ad75c2 avcodec/flashsv: Clear pointers
Fixes: Use after free
Fixes: 47399/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLASHSV2_fuzzer-5718646686613504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer 4ff654e030 tools/target_dec_fuzzer: Adjust threshold for SIMBIOSIS_IMX
Fixes: Timeout
Fixes: 47892/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SIMBIOSIS_IMX_fuzzer-5160609278197760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer 884a108121 avformat/cinedec: Check size and pos more
Fixes: signed integer overflow: 9223372036848019263 + 134232320 cannot be represented in type 'long'
Fixes: 48155/clusterfuzz-testcase-minimized-ffmpeg_dem_CINE_fuzzer-5751429207293952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer 9f77af177a tools/target_dec_fuzzer: Adjust threshold for ARGO
Fixes: Timeout
Fixes: 48002/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-6187041768996864

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer af2ed09220 avcodec/aasc: Fix indention
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer 8f6432cd77 avcodec/flashsv: Check inflate() for failure
Fixes: CID1047223

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer 7796d740bd avcodec/smacker: fix indention after previous commit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer 08e82e5b57 avcodec/smacker: Optimize constant 16bit audio output
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer 5c2fa59f32 tools/target_dec_fuzzer: Adjust threshold for smacker audio
Fixes: Timeout
Fixes: 47043/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-4824799337119744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Marton Balint b54f3e32fa avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern
Also warn the user that for single images -update should be used, for sequences
a proper pattern should be specified.

Fixes ticket #9748.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-07 20:23:06 +02:00
Marton Balint 3f2de562c3 avformat/img2enc: fix first image check
Start image number was hardcoded to 1 for the first image check.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-07 20:23:06 +02:00
Paul B Mahol 6ed9eaf664 avfilter: add remap opencl filter 2022-07-07 17:52:32 +02:00
Marton Balint 03d81a044a avformat/mov: disallow a zero sample size in trun atoms
In order to not generate 0 sized packets or create a huge index table
needlessly.

Fixes: Timeout
Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304
Fixes: 45738/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6142535657979904

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-06 23:37:29 +02:00
Marton Balint 7acc124121 Revert "avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) on stuck empty input parser"
Hides the underlying real problem with a demuxer returning 0 sized packets.

This reverts commit 02699490c1.
2022-07-06 23:37:29 +02:00
Marton Balint dbc3b5a902 Revert "avformat/demux: Count EAGAIN as 100 bytes in relation to read limit in avformat_find_stream_info()"
Modifying avformat_find_stream_info() behaviour based on the number of EAGAINs
it encounters is a hack which usually only hides the real issue if such thing
happen.

This reverts commit b0cac7082d.
2022-07-06 23:37:29 +02:00
Andreas Rheinhardt aca09ed7d4 avutil/mem: Handle fast allocations near UINT_MAX properly
av_fast_realloc and av_fast_mallocz? store the size of
the objects they allocate in an unsigned. Yet they overallocate
and currently they can allocate more than UINT_MAX bytes
in case a user has requested a size of about UINT_MAX * 16 / 17
or more if SIZE_MAX > UINT_MAX (and if the user increased
max_alloc_size via av_max_alloc). In this case it is impossible
to store the true size of the buffer via the unsigned*;
future requests are likely to use the (re)allocation codepath
even if the buffer is actually large enough because of
the incorrect size.

Fix this by ensuring that the actually allocated size
always fits into an unsigned. (This entails erroring out
in case the user requested more than UINT_MAX.)

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-06 22:53:15 +02:00
115 changed files with 2477 additions and 319 deletions
+2
View File
@@ -23,6 +23,8 @@ version 5.1:
- virtualbass audio filter
- VDPAU AV1 hwaccel
- PHM image format support
- remap_opencl filter
- added chromakey_cuda filter
version 5.0:
+2
View File
@@ -181,7 +181,9 @@ static inline __device__ double trunc(double a) { return __builtin_trunc(a); }
static inline __device__ float fabsf(float a) { return __builtin_fabsf(a); }
static inline __device__ float fabs(float a) { return __builtin_fabsf(a); }
static inline __device__ double fabs(double a) { return __builtin_fabs(a); }
static inline __device__ float sqrtf(float a) { return __builtin_sqrtf(a); }
static inline __device__ float __saturatef(float a) { return __nvvm_saturate_f(a); }
static inline __device__ float __sinf(float a) { return __nvvm_sin_approx_f(a); }
static inline __device__ float __cosf(float a) { return __nvvm_cos_approx_f(a); }
static inline __device__ float __expf(float a) { return __nvvm_ex2_approx_f(a * (float)__builtin_log2(__builtin_exp(1))); }
Vendored
+4 -1
View File
@@ -3142,6 +3142,8 @@ qsvvpp_select="qsv"
vaapi_encode_deps="vaapi"
v4l2_m2m_deps="linux_videodev2_h sem_timedwait"
chromakey_cuda_filter_deps="ffnvcodec"
chromakey_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
hwupload_cuda_filter_deps="ffnvcodec"
scale_npp_filter_deps="ffnvcodec libnpp"
scale2ref_npp_filter_deps="ffnvcodec libnpp"
@@ -3706,6 +3708,7 @@ prewitt_opencl_filter_deps="opencl"
procamp_vaapi_filter_deps="vaapi"
program_opencl_filter_deps="opencl"
pullup_filter_deps="gpl"
remap_opencl_filter_deps="opencl"
removelogo_filter_deps="avcodec avformat swscale"
repeatfields_filter_deps="gpl"
roberts_opencl_filter_deps="opencl"
@@ -6755,7 +6758,7 @@ if enabled sdl2; then
sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags &&
test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x030000" $sdl2_cflags &&
check_func_headers SDL_events.h SDL_PollEvent $sdl2_extralibs $sdl2_cflags &&
enable sdl2
fi
+11 -9
View File
@@ -14,24 +14,26 @@ libavutil: 2021-04-27
API changes, most recent first:
2022-06-12 - xxxxxxxxxx - lavf 59.25.100 - avio.h
-------- 8< --------- FFmpeg 5.1 was cut here -------- 8< ---------
2022-06-12 - 7cae3d8b76 - lavf 59.25.100 - avio.h
Add avio_vprintf(), similar to avio_printf() but allow to use it
from within a function taking a variable argument list as input.
2022-06-12 - xxxxxxxxx - lavu 57.27.100 - uuid.h
2022-06-12 - ff59ecc4de - lavu 57.27.100 - uuid.h
Add UUID handling functions.
Add av_uuid_parse(), av_uuid_urn_parse(), av_uuid_parse_range(),
av_uuid_parse_range(), av_uuid_equal(), av_uuid_copy(), and av_uuid_nil().
2022-06-01 - xxxxxxxxx - lavu 57.26.100 - csp.h
2022-06-01 - d42b410e05 - lavu 57.26.100 - csp.h
Add public API for colorspace structs.
Add av_csp_luma_coeffs_from_avcsp(), av_csp_primaries_desc_from_id(),
and av_csp_primaries_id_from_desc().
2022-05-23 - xxxxxxxxx - lavu 57.25.100 - avutil.h
2022-05-23 - 4cdc14aa95 - lavu 57.25.100 - avutil.h
Deprecate av_fopen_utf8() without replacement.
2022-03-16 - xxxxxxxxxx - all libraries - version_major.h
2022-03-16 - f3a0e2ee2b - all libraries - version_major.h
Add lib<name>/version_major.h as new installed headers, which only
contain the major version number (and corresponding API deprecation
defines).
@@ -73,10 +75,10 @@ API changes, most recent first:
Update AVFrame for the new channel layout API: add ch_layout, deprecate
channels/channel_layout.
2022-03-10 - xxxxxxxxxx - lavu 57.23.100 - cpu.h
2022-03-10 - f629ea2e18 - lavu 57.23.100 - cpu.h
Add AV_CPU_FLAG_AVX512ICL.
2022-02-07 - xxxxxxxxxx - lavu 57.21.100 - fifo.h
2022-02-07 - a10f1aec1f - lavu 57.21.100 - fifo.h
Deprecate AVFifoBuffer and the API around it, namely av_fifo_alloc(),
av_fifo_alloc_array(), av_fifo_free(), av_fifo_freep(), av_fifo_reset(),
av_fifo_size(), av_fifo_space(), av_fifo_generic_peek_at(),
@@ -84,7 +86,7 @@ API changes, most recent first:
av_fifo_realloc2(), av_fifo_grow(), av_fifo_drain() and av_fifo_peek2().
Users should switch to the AVFifo-API.
2022-02-07 - xxxxxxxxxx - lavu 57.20.100 - fifo.h
2022-02-07 - 7329b22c05 - lavu 57.20.100 - fifo.h
Add a new FIFO API, which allows setting a FIFO element size.
This API operates on these elements rather than on bytes.
Add av_fifo_alloc2(), av_fifo_elem_size(), av_fifo_can_read(),
@@ -1687,7 +1689,7 @@ API changes, most recent first:
2014-04-15 - ef818d8 - lavf 55.37.101 - avformat.h
Add av_format_inject_global_side_data()
2014-04-12 - 4f698be - lavu 52.76.100 - log.h
2014-04-12 - 4f698be8f - lavu 52.76.100 - log.h
Add av_log_get_flags()
2014-04-11 - 6db42a2b - lavd 55.12.100 - avdevice.h
+69
View File
@@ -8599,6 +8599,7 @@ The command accepts the same syntax of the corresponding option.
If the specified expression is not valid, it is kept at its current
value.
@anchor{chromakey}
@section chromakey
YUV colorspace color/chroma keying.
@@ -8651,6 +8652,48 @@ ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 -shortest -filter_compl
@end example
@end itemize
@section chromakey_cuda
CUDA accelerated YUV colorspace color/chroma keying.
This filter works like normal chromakey filter but operates on CUDA frames.
for more details and parameters see @ref{chromakey}.
@subsection Examples
@itemize
@item
Make all the green pixels in the input video transparent and use it as an overlay for another video:
@example
./ffmpeg \
-hwaccel cuda -hwaccel_output_format cuda -i input_green.mp4 \
-hwaccel cuda -hwaccel_output_format cuda -i base_video.mp4 \
-init_hw_device cuda \
-filter_complex \
" \
[0:v]chromakey_cuda=0x25302D:0.1:0.12:1[overlay_video]; \
[1:v]scale_cuda=format=yuv420p[base]; \
[base][overlay_video]overlay_cuda" \
-an -sn -c:v h264_nvenc -cq 20 output.mp4
@end example
@item
Process two software sources, explicitly uploading the frames:
@example
./ffmpeg -init_hw_device cuda=cuda -filter_hw_device cuda \
-f lavfi -i color=size=800x600:color=white,format=yuv420p \
-f lavfi -i yuvtestsrc=size=200x200,format=yuv420p \
-filter_complex \
" \
[0]hwupload[under]; \
[1]hwupload,chromakey_cuda=green:0.1:0.12[over]; \
[under][over]overlay_cuda" \
-c:v hevc_nvenc -cq 18 -preset slow output.mp4
@end example
@end itemize
@section chromanr
Reduce chrominance noise.
@@ -24265,6 +24308,8 @@ Set one of available transition effects:
@item squeezeh
@item squeezev
@item zoomin
@item fadefast
@item fadeslow
@end table
Default transition effect is fade.
@@ -25701,6 +25746,30 @@ __kernel void blend_images(__write_only image2d_t dst,
@end itemize
@section remap_opencl
Remap pixels using 2nd: Xmap and 3rd: Ymap input video stream.
Destination pixel at position (X, Y) will be picked from source (x, y) position
where x = Xmap(X, Y) and y = Ymap(X, Y). If mapping values are out of range, zero
value for pixel will be used for destination pixel.
Xmap and Ymap input video streams must be of same dimensions. Output video stream
will have Xmap/Ymap video stream dimensions.
Xmap and Ymap input video streams are 32bit float pixel format, single channel.
@table @option
@item interp
Specify interpolation used for remapping of pixels.
Allowed values are @code{near} and @code{linear}.
Default value is @code{linear}.
@item fill
Specify the color of the unmapped pixels. For the syntax of this option,
check the @ref{color syntax,,"Color" section in the ffmpeg-utils
manual,ffmpeg-utils}. Default color is @code{black}.
@end table
@section roberts_opencl
Apply the Roberts cross operator (@url{https://en.wikipedia.org/wiki/Roberts_cross}) to input video stream.
+2 -2
View File
@@ -822,8 +822,8 @@ FILE *get_preset_file(char *filename, size_t filename_size,
#endif
char *env_home = getenv_utf8("HOME");
char *env_ffmpeg_datadir = getenv_utf8("FFMPEG_DATADIR");
const char *base[3] = { env_home,
env_ffmpeg_datadir,
const char *base[3] = { env_ffmpeg_datadir,
env_home, /* index=1(HOME) is special: search in a .ffmpeg subfolder */
FFMPEG_DATADIR, };
if (is_path) {
+6 -2
View File
@@ -901,7 +901,7 @@ static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, in
}
static void writer_print_data(WriterContext *wctx, const char *name,
uint8_t *data, int size)
const uint8_t *data, int size)
{
AVBPrint bp;
int offset = 0, l, i;
@@ -929,7 +929,7 @@ static void writer_print_data(WriterContext *wctx, const char *name,
}
static void writer_print_data_hash(WriterContext *wctx, const char *name,
uint8_t *data, int size)
const uint8_t *data, int size)
{
char *p, buf[AV_HASH_MAX_SIZE * 2 + 64] = { 0 };
@@ -2361,6 +2361,8 @@ static void print_pkt_side_data(WriterContext *w,
if (do_show_data)
writer_print_data(w, "data", sd->data, sd->size);
writer_print_data_hash(w, "data_hash", sd->data, sd->size);
} else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
print_int("active_format", *sd->data);
}
writer_print_section_footer(w);
}
@@ -2633,6 +2635,8 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
} else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
print_int("active_format", *sd->data);
} else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
char tcbuf[AV_TIMECODE_STR_SIZE];
av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
+9 -6
View File
@@ -701,14 +701,15 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n");
if (set_default_channel_config(ac, ac->avctx, layout_map,
&layout_map_tags, 1) < 0)
return NULL;
layout_map_tags = 2;
layout_map[0][0] = layout_map[1][0] = TYPE_SCE;
layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT;
layout_map[0][1] = 0;
layout_map[1][1] = 1;
if (output_configure(ac, layout_map, layout_map_tags,
OC_TRIAL_FRAME, 1) < 0)
return NULL;
ac->oc[1].m4ac.chan_config = 1;
if (ac->oc[1].m4ac.sbr)
ac->oc[1].m4ac.ps = -1;
}
@@ -786,8 +787,10 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
type == TYPE_CPE) {
ac->tags_mapped++;
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
} else if (ac->oc[1].m4ac.chan_config == 2) {
return NULL;
} else if (ac->tags_mapped == 1 && ac->oc[1].m4ac.chan_config == 2 &&
type == TYPE_SCE) {
ac->tags_mapped++;
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
}
case 1:
if (!ac->tags_mapped && type == TYPE_SCE) {
+2
View File
@@ -35,5 +35,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx)
if (have_neon(cpu_flags)) {
c->pix_abs[0][0] = ff_pix_abs16_neon;
c->pix_abs[0][3] = ff_pix_abs16_xy2_neon;
c->sad[0] = ff_pix_abs16_neon;
}
}
+17 -17
View File
@@ -104,26 +104,26 @@ static int aasc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
break;
case MKTAG('A', 'A', 'S', 'C'):
switch (compr) {
case 0:
stride = (avctx->width * psize + psize) & ~psize;
if (buf_size < stride * avctx->height)
switch (compr) {
case 0:
stride = (avctx->width * psize + psize) & ~psize;
if (buf_size < stride * avctx->height)
return AVERROR_INVALIDDATA;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * psize);
buf += stride;
buf_size -= stride;
}
break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return AVERROR_INVALIDDATA;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * psize);
buf += stride;
buf_size -= stride;
}
break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return AVERROR_INVALIDDATA;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag);
return -1;
+3
View File
@@ -38,4 +38,7 @@ enum {
APNG_BLEND_OP_OVER = 1,
};
/* Only the payload data, not including length, fourcc and CRC-32. */
#define APNG_FCTL_CHUNK_SIZE 26
#endif /* AVCODEC_APNG_H */
+5 -5
View File
@@ -73,8 +73,8 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {
AV_CODEC_ID_NONE
};
int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
enum AVCodecID codec_id, void *log_ctx)
av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
enum AVCodecID codec_id, void *log_ctx)
{
CodedBitstreamContext *ctx;
const CodedBitstreamType *type;
@@ -118,13 +118,13 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
return 0;
}
void ff_cbs_flush(CodedBitstreamContext *ctx)
av_cold void ff_cbs_flush(CodedBitstreamContext *ctx)
{
if (ctx->codec->flush)
ctx->codec->flush(ctx);
}
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
{
CodedBitstreamContext *ctx = *ctx_ptr;
@@ -168,7 +168,7 @@ void ff_cbs_fragment_reset(CodedBitstreamFragment *frag)
frag->data_bit_padding = 0;
}
void ff_cbs_fragment_free(CodedBitstreamFragment *frag)
av_cold void ff_cbs_fragment_free(CodedBitstreamFragment *frag)
{
ff_cbs_fragment_reset(frag);
+2 -2
View File
@@ -54,8 +54,8 @@ static int cpia_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
CpiaContext* const cpia = avctx->priv_data;
int i,j,ret;
uint8_t* const header = avpkt->data;
uint8_t* src;
const uint8_t *const header = avpkt->data;
const uint8_t *src;
int src_size;
uint16_t linelength;
uint8_t skip;
+2 -1
View File
@@ -38,7 +38,8 @@ typedef struct {
// DFPWM codec from https://github.com/ChenThread/dfpwm/blob/master/1a/
// Licensed in the public domain
static void au_decompress(DFPWMState *state, int fs, int len, uint8_t *outbuf, uint8_t *inbuf)
static void au_decompress(DFPWMState *state, int fs, int len,
uint8_t *outbuf, const uint8_t *inbuf)
{
unsigned d;
for (int i = 0; i < len; i++) {
-1
View File
@@ -30,7 +30,6 @@
#include "avcodec.h"
#include "dv_profile.h"
#include "me_cmp.h"
#include "vlc.h"
#include "idctdsp.h"
typedef struct DVwork_chunk {
+4 -5
View File
@@ -339,6 +339,7 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
return ret;
avctx->internal->last_audio_frame = 1;
return 0;
} else if (src->nb_samples > avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d)\n", src->nb_samples, avctx->frame_size);
return AVERROR(EINVAL);
@@ -346,11 +347,9 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
}
}
if (!dst->data[0]) {
ret = av_frame_ref(dst, src);
if (ret < 0)
return ret;
}
ret = av_frame_ref(dst, src);
if (ret < 0)
return ret;
return 0;
}
+11
View File
@@ -187,6 +187,9 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs)
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
return -1;
if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23))
return AVERROR_INVALIDDATA;
for (i = 0; i < f->plane_count; i++) {
PlaneContext * const p = &fs->plane[i];
int idx = get_symbol(c, state, 0);
@@ -876,6 +879,14 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
p->key_frame = 0;
}
if (f->ac != AC_GOLOMB_RICE) {
if (buf_size < avctx->width * avctx->height / (128*8))
return AVERROR_INVALIDDATA;
} else {
if (buf_size < avctx->height / 8)
return AVERROR_INVALIDDATA;
}
ret = ff_thread_get_ext_buffer(avctx, &f->picture, AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
return ret;
+5 -5
View File
@@ -93,11 +93,11 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
run_count--;
}
} else {
while (run_count > 1 && w-x > 1) {
sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
x++;
run_count--;
}
while (run_count > 1 && w-x > 1) {
sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
x++;
run_count--;
}
}
run_count--;
if (run_count < 0) {
+10 -2
View File
@@ -149,7 +149,9 @@ static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size)
zstream->avail_in = size;
zstream->next_out = data;
zstream->avail_out = s->block_size * 3;
inflate(zstream, Z_SYNC_FLUSH);
zret = inflate(zstream, Z_SYNC_FLUSH);
if (zret != Z_OK && zret != Z_STREAM_END)
return AVERROR_UNKNOWN;
remaining = s->block_size * 3 - zstream->avail_out;
if ((zret = inflateReset(zstream)) != Z_OK) {
@@ -165,7 +167,9 @@ static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size)
* out of the output from above. See section 3.2.4 of RFC 1951. */
zstream->next_in = zlib_header;
zstream->avail_in = sizeof(zlib_header);
inflate(zstream, Z_SYNC_FLUSH);
zret = inflate(zstream, Z_SYNC_FLUSH);
if (zret != Z_OK)
return AVERROR_UNKNOWN;
while (remaining > 0) {
unsigned block_size = FFMIN(UINT16_MAX, remaining);
uint8_t header[5];
@@ -346,6 +350,9 @@ static int flashsv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (err < 0)
return err;
s->keyframedata = avpkt->data;
if (s->blocks)
memset(s->blocks, 0, (v_blocks + !!v_part) * (h_blocks + !!h_part) *
sizeof(s->blocks[0]));
}
if(s->ver == 2 && !s->blocks)
s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) *
@@ -554,6 +561,7 @@ static av_cold int flashsv2_decode_end(AVCodecContext *avctx)
FlashSVContext *s = avctx->priv_data;
av_buffer_unref(&s->keyframedata_buf);
s->keyframedata = NULL;
av_freep(&s->blocks);
av_freep(&s->keyframe);
flashsv_decode_end(avctx);
+1 -1
View File
@@ -625,7 +625,7 @@ static const AVOption h264_metadata_options[] = {
{ "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT,
{ .i64 = -1 }, -1, 6, FLAGS },
{ .i64 = -1 }, -1, 5, FLAGS },
{ "tick_rate", "Set VUI tick rate (time_scale / num_units_in_tick)",
OFFSET(tick_rate), AV_OPT_TYPE_RATIONAL,
+4
View File
@@ -672,6 +672,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
avpriv_request_sample(avctx, "data partitioning");
break;
case H264_NAL_SEI:
if (h->setup_finished) {
avpriv_request_sample(avctx, "Late SEI");
break;
}
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1;
if (avctx->debug & FF_DEBUG_GREEN_MD)
+1 -1
View File
@@ -437,7 +437,7 @@ static const AVOption h265_metadata_options[] = {
{ "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT,
{ .i64 = -1 }, -1, 6, FLAGS },
{ .i64 = -1 }, -1, 5, FLAGS },
{ "tick_rate",
"Set VPS and VUI tick rate (time_scale / num_units_in_tick)",
+3 -3
View File
@@ -1282,7 +1282,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
int scf_offset = 0;
if (s->ps.sps->transform_skip_context_enabled_flag &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
ctx_idx_map_p = (uint8_t*) &ctx_idx_map[4 * 16];
ctx_idx_map_p = &ctx_idx_map[4 * 16];
if (c_idx == 0) {
scf_offset = 40;
} else {
@@ -1292,9 +1292,9 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
if (c_idx != 0)
scf_offset = 27;
if (log2_trafo_size == 2) {
ctx_idx_map_p = (uint8_t*) &ctx_idx_map[0];
ctx_idx_map_p = &ctx_idx_map[0];
} else {
ctx_idx_map_p = (uint8_t*) &ctx_idx_map[(prev_sig + 1) << 4];
ctx_idx_map_p = &ctx_idx_map[(prev_sig + 1) << 4];
if (c_idx == 0) {
if ((x_cg > 0 || y_cg > 0))
scf_offset += 3;
+8 -8
View File
@@ -645,8 +645,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
}
}
static int boundary_strength(HEVCContext *s, MvField *curr, MvField *neigh,
RefPicList *neigh_refPicList)
static int boundary_strength(const HEVCContext *s, const MvField *curr, const MvField *neigh,
const RefPicList *neigh_refPicList)
{
if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) {
// same L0 and L1
@@ -734,9 +734,9 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
boundary_upper = 0;
if (boundary_upper) {
RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ?
ff_hevc_get_ref_list(s, s->ref, x0, y0 - 1) :
s->ref->refPicList;
const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ?
ff_hevc_get_ref_list(s, s->ref, x0, y0 - 1) :
s->ref->refPicList;
int yp_pu = (y0 - 1) >> log2_min_pu_size;
int yq_pu = y0 >> log2_min_pu_size;
int yp_tu = (y0 - 1) >> log2_min_tu_size;
@@ -772,9 +772,9 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
boundary_left = 0;
if (boundary_left) {
RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ?
ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0) :
s->ref->refPicList;
const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ?
ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0) :
s->ref->refPicList;
int xp_pu = (x0 - 1) >> log2_min_pu_size;
int xq_pu = x0 >> log2_min_pu_size;
int xp_tu = (x0 - 1) >> log2_min_tu_size;
+5 -5
View File
@@ -113,7 +113,7 @@ static av_always_inline int compare_mv_ref_idx(struct MvField A, struct MvField
return 0;
}
static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb)
static av_always_inline void mv_scale(Mv *dst, const Mv *src, int td, int tb)
{
int tx, scale_factor;
@@ -127,10 +127,10 @@ static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb)
(scale_factor * src->y < 0)) >> 8);
}
static int check_mvset(Mv *mvLXCol, Mv *mvCol,
static int check_mvset(Mv *mvLXCol, const Mv *mvCol,
int colPic, int poc,
RefPicList *refPicList, int X, int refIdxLx,
RefPicList *refPicList_col, int listCol, int refidxCol)
const RefPicList *refPicList, int X, int refIdxLx,
const RefPicList *refPicList_col, int listCol, int refidxCol)
{
int cur_lt = refPicList[X].isLongTerm[refIdxLx];
int col_lt = refPicList_col[listCol].isLongTerm[refidxCol];
@@ -163,7 +163,7 @@ static int check_mvset(Mv *mvLXCol, Mv *mvCol,
// derive the motion vectors section 8.5.3.1.8
static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
int refIdxLx, Mv *mvLXCol, int X,
int colPic, RefPicList *refPicList_col)
int colPic, const RefPicList *refPicList_col)
{
RefPicList *refPicList = s->ref->refPicList;
+2 -2
View File
@@ -1,8 +1,8 @@
/*
* HEVC Parameter Set decoding
*
* Copyright (C) 2012 - 2103 Guillaume Martres
* Copyright (C) 2012 - 2103 Mickael Raulet
* Copyright (C) 2012 - 2013 Guillaume Martres
* Copyright (C) 2012 - 2013 Mickael Raulet
* Copyright (C) 2012 - 2013 Gildas Cocherel
* Copyright (C) 2013 Vittorio Giovara
*
+3 -2
View File
@@ -55,13 +55,14 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
}
}
RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *ref, int x0, int y0)
const RefPicList *ff_hevc_get_ref_list(const HEVCContext *s,
const HEVCFrame *ref, int x0, int y0)
{
int x_cb = x0 >> s->ps.sps->log2_ctb_size;
int y_cb = y0 >> s->ps.sps->log2_ctb_size;
int pic_width_cb = s->ps.sps->ctb_width;
int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];
return (RefPicList *)ref->rpl_tab[ctb_addr_ts];
return &ref->rpl_tab[ctb_addr_ts]->refPicList[0];
}
void ff_hevc_clear_refs(HEVCContext *s)
+1 -1
View File
@@ -550,7 +550,7 @@ static int decode_nal_sei_message(GetByteContext *gb, void *logctx, HEVCSEI *s,
}
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
const HEVCParamSets *ps, int type)
const HEVCParamSets *ps, enum HEVCNALUnitType type)
{
GetByteContext gbyte;
int ret;
+2 -1
View File
@@ -26,6 +26,7 @@
#include "libavutil/buffer.h"
#include "get_bits.h"
#include "hevc.h"
#include "sei.h"
@@ -154,7 +155,7 @@ typedef struct HEVCSEI {
struct HEVCParamSets;
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
const struct HEVCParamSets *ps, int type);
const struct HEVCParamSets *ps, enum HEVCNALUnitType type);
/**
* Reset SEI values that are stored on the Context.
+2 -2
View File
@@ -584,8 +584,8 @@ void ff_hevc_clear_refs(HEVCContext *s);
*/
void ff_hevc_flush_dpb(HEVCContext *s);
RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame,
int x0, int y0);
const RefPicList *ff_hevc_get_ref_list(const HEVCContext *s, const HEVCFrame *frame,
int x0, int y0);
/**
* Construct the reference picture sets for the current frame.
+1 -1
View File
@@ -313,7 +313,7 @@ static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
dst[x] = av_clip_pixel(src[x] + offset_table[(src[x] >> shift) & 31]);
dst += stride_dst;
src += stride_src;
}
+4 -4
View File
@@ -64,7 +64,7 @@ static int getbit(GetByteContext *gb, uint32_t *bitbuf, int *bits)
return ret;
}
static void unpack_intraframe(AVCodecContext *avctx, uint8_t *src,
static void unpack_intraframe(AVCodecContext *avctx, const uint8_t *src,
uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;
@@ -147,7 +147,7 @@ static void copy_processed_frame(AVCodecContext *avctx, AVFrame *frame)
}
}
static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t size)
static int decode_interframe_v4(AVCodecContext *avctx, const uint8_t *src, uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;
GetByteContext gb;
@@ -276,7 +276,7 @@ static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t si
return 0;
}
static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
static void decode_interframe_v4a(AVCodecContext *avctx, const uint8_t *src,
uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;
@@ -355,7 +355,7 @@ static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
}
}
static void hnm_update_palette(AVCodecContext *avctx, uint8_t *src,
static void hnm_update_palette(AVCodecContext *avctx, const uint8_t *src,
uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;
+1 -1
View File
@@ -135,7 +135,7 @@ static int libcodec2_decode(AVCodecContext *avctx, AVFrame *frame,
{
LibCodec2Context *c2 = avctx->priv_data;
int ret, nframes, i;
uint8_t *input;
const uint8_t *input;
int16_t *output;
nframes = pkt->size / avctx->block_align;
+1 -1
View File
@@ -57,7 +57,7 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
WelsTraceCallback callback_function;
if ((err = ff_libopenh264_check_version(avctx)) < 0)
return err;
return AVERROR_DECODER_NOT_FOUND;
if (WelsCreateDecoder(&s->decoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create decoder\n");
+1 -1
View File
@@ -138,7 +138,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
AVCPBProperties *props;
if ((err = ff_libopenh264_check_version(avctx)) < 0)
return err;
return AVERROR_ENCODER_NOT_FOUND;
if (WelsCreateSVCEncoder(&s->encoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
+1 -1
View File
@@ -199,7 +199,7 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img,
}
static int decode_frame(AVCodecContext *avctx, vpx_codec_ctx_t *decoder,
uint8_t *data, uint32_t data_sz)
const uint8_t *data, uint32_t data_sz)
{
if (vpx_codec_decode(decoder, data, data_sz, NULL, 0) != VPX_CODEC_OK) {
const char *error = vpx_codec_error(decoder);
+1 -1
View File
@@ -581,7 +581,7 @@ static void handler(vbi_event *ev, void *user_data)
vbi_unref_page(&page);
}
static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size)
static int slice_to_vbi_lines(TeletextContext *ctx, const uint8_t *buf, int size)
{
int lines = 0;
while (size >= 2 && lines < MAX_SLICES) {
+20 -9
View File
@@ -2558,24 +2558,35 @@ static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, in
static int sse_mb(MpegEncContext *s){
int w= 16;
int h= 16;
int chroma_mb_w = w >> s->chroma_x_shift;
int chroma_mb_h = h >> s->chroma_y_shift;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
if(w==16 && h==16)
if(s->avctx->mb_cmp == FF_CMP_NSSE){
return s->mecc.nsse[0](s, s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) +
s->mecc.nsse[1](s, s->new_picture->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) +
s->mecc.nsse[1](s, s->new_picture->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8);
return s->mecc.nsse[0](s, s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16,
s->dest[0], s->linesize, 16) +
s->mecc.nsse[1](s, s->new_picture->data[1] + s->mb_x * chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[1], s->uvlinesize, chroma_mb_h) +
s->mecc.nsse[1](s, s->new_picture->data[2] + s->mb_x * chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[2], s->uvlinesize, chroma_mb_h);
}else{
return s->mecc.sse[0](NULL, s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) +
s->mecc.sse[1](NULL, s->new_picture->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) +
s->mecc.sse[1](NULL, s->new_picture->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8);
return s->mecc.sse[0](NULL, s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16,
s->dest[0], s->linesize, 16) +
s->mecc.sse[1](NULL, s->new_picture->data[1] + s->mb_x * chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[1], s->uvlinesize, chroma_mb_h) +
s->mecc.sse[1](NULL, s->new_picture->data[2] + s->mb_x * chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[2], s->uvlinesize, chroma_mb_h);
}
else
return sse(s, s->new_picture->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
+sse(s, s->new_picture->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
+sse(s, s->new_picture->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
return sse(s, s->new_picture->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16,
s->dest[0], w, h, s->linesize) +
sse(s, s->new_picture->data[1] + s->mb_x * chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[1], w >> s->chroma_x_shift, h >> s->chroma_y_shift, s->uvlinesize) +
sse(s, s->new_picture->data[2] + s->mb_x * chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h,
s->dest[2], w >> s->chroma_x_shift, h >> s->chroma_y_shift, s->uvlinesize);
}
static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
+1 -1
View File
@@ -159,7 +159,7 @@ static void set_src_position(PAFVideoDecContext *c,
*pend = c->frame[page] + c->frame_size;
}
static int decode_0(PAFVideoDecContext *c, uint8_t *pkt, uint8_t code)
static int decode_0(PAFVideoDecContext *c, const uint8_t *pkt, uint8_t code)
{
uint32_t opcode_size, offset;
uint8_t *dst, *dend, mask = 0, color = 0;
+6 -8
View File
@@ -31,8 +31,6 @@ typedef struct PCMDVDContext {
int block_size; // Size of a block of samples in bytes
int samples_per_block; // Number of samples per channel per block
int groups_per_block; // Number of 20/24-bit sample groups per block
uint8_t *extra_samples; // Pointer to leftover samples from a frame
int extra_sample_count; // Number of leftover samples in the buffer
} PCMDVDContext;
static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx)
@@ -148,8 +146,8 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
for (int i = 2; i; i--) {
bytestream2_put_be16(&pb, src32[0] >> 16);
bytestream2_put_be16(&pb, src32[1] >> 16);
bytestream2_put_byte(&pb, (*src32++) >> 24);
bytestream2_put_byte(&pb, (*src32++) >> 24);
bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
}
} while (--blocks);
} else {
@@ -159,10 +157,10 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
bytestream2_put_be16(&pb, src32[1] >> 16);
bytestream2_put_be16(&pb, src32[2] >> 16);
bytestream2_put_be16(&pb, src32[3] >> 16);
bytestream2_put_byte(&pb, (*src32++) >> 24);
bytestream2_put_byte(&pb, (*src32++) >> 24);
bytestream2_put_byte(&pb, (*src32++) >> 24);
bytestream2_put_byte(&pb, (*src32++) >> 24);
bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
}
} while (--blocks);
}
+3 -3
View File
@@ -198,7 +198,7 @@ static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size,
return get_bits_count(bc) >> 3;
}
static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
static int read_high_coeffs(AVCodecContext *avctx, const uint8_t *src, int16_t *dst,
int size, int c, int a, int d,
int width, ptrdiff_t stride)
{
@@ -313,7 +313,7 @@ static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
return get_bits_count(bc) >> 3;
}
static int read_highpass(AVCodecContext *avctx, uint8_t *ptr,
static int read_highpass(AVCodecContext *avctx, const uint8_t *ptr,
int plane, AVFrame *frame)
{
PixletContext *ctx = avctx->priv_data;
@@ -611,7 +611,7 @@ static int pixlet_decode_frame(AVCodecContext *avctx, AVFrame *p,
bytestream2_init(&ctx->gb, avpkt->data, avpkt->size);
pktsize = bytestream2_get_be32(&ctx->gb);
if (pktsize <= 44 || pktsize - 4 > bytestream2_get_bytes_left(&ctx->gb)) {
if (pktsize <= 44 + (NB_LEVELS * 8 + 6) * 3 || pktsize - 4 > bytestream2_get_bytes_left(&ctx->gb)) {
av_log(avctx, AV_LOG_ERROR, "Invalid packet size %"PRIu32"\n", pktsize);
return AVERROR_INVALIDDATA;
}
+1 -1
View File
@@ -972,7 +972,7 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
uint32_t sequence_number;
int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op;
if (bytestream2_get_bytes_left(gb) != 26)
if (bytestream2_get_bytes_left(gb) != APNG_FCTL_CHUNK_SIZE)
return AVERROR_INVALIDDATA;
if (!(s->hdr_state & PNG_IHDR)) {
+3 -3
View File
@@ -988,7 +988,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
// to have the image data write to the correct place in the buffer
fctl_chunk.sequence_number = s->sequence_number;
++s->sequence_number;
s->bytestream += 26 + 12;
s->bytestream += APNG_FCTL_CHUNK_SIZE + 12;
ret = apng_encode_frame(avctx, pict, &fctl_chunk, &s->last_frame_fctl);
if (ret < 0)
@@ -1002,7 +1002,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
if (s->last_frame) {
uint8_t* last_fctl_chunk_start = pkt->data;
uint8_t buf[26];
uint8_t buf[APNG_FCTL_CHUNK_SIZE];
if (!s->extra_data_updated) {
uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, s->extra_data_size);
if (!side_data)
@@ -1020,7 +1020,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
AV_WB16(buf + 22, s->last_frame_fctl.delay_den);
buf[24] = s->last_frame_fctl.dispose_op;
buf[25] = s->last_frame_fctl.blend_op;
png_write_chunk(&last_fctl_chunk_start, MKTAG('f', 'c', 'T', 'L'), buf, 26);
png_write_chunk(&last_fctl_chunk_start, MKTAG('f', 'c', 'T', 'L'), buf, sizeof(buf));
*got_packet = 1;
}
+6 -6
View File
@@ -199,7 +199,7 @@ static void OPNAME ## qpel8_mc01_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[16 * 9]; \
uint8_t half[64]; \
\
copy_block9(full, src, 16, stride, 9); \
copy_block8(full, src, 16, stride, 9); \
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \
} \
@@ -209,7 +209,7 @@ static void OPNAME ## qpel8_mc02_c(uint8_t *dst, const uint8_t *src, \
{ \
uint8_t full[16 * 9]; \
\
copy_block9(full, src, 16, stride, 9); \
copy_block8(full, src, 16, stride, 9); \
OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
} \
\
@@ -219,7 +219,7 @@ static void OPNAME ## qpel8_mc03_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[16 * 9]; \
uint8_t half[64]; \
\
copy_block9(full, src, 16, stride, 9); \
copy_block8(full, src, 16, stride, 9); \
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \
} \
@@ -459,7 +459,7 @@ static void OPNAME ## qpel16_mc01_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[24 * 17]; \
uint8_t half[256]; \
\
copy_block17(full, src, 24, stride, 17); \
copy_block16(full, src, 24, stride, 17); \
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \
} \
@@ -469,7 +469,7 @@ static void OPNAME ## qpel16_mc02_c(uint8_t *dst, const uint8_t *src, \
{ \
uint8_t full[24 * 17]; \
\
copy_block17(full, src, 24, stride, 17); \
copy_block16(full, src, 24, stride, 17); \
OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
} \
\
@@ -479,7 +479,7 @@ static void OPNAME ## qpel16_mc03_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[24 * 17]; \
uint8_t half[256]; \
\
copy_block17(full, src, 24, stride, 17); \
copy_block16(full, src, 24, stride, 17); \
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \
} \
+2 -2
View File
@@ -114,8 +114,8 @@ static void sbr_qmf_deint_neg_c(int *v, const int *src)
{
int i;
for (i = 0; i < 32; i++) {
v[ i] = ( src[63 - 2*i ] + 0x10) >> 5;
v[63 - i] = (-src[63 - 2*i - 1] + 0x10) >> 5;
v[ i] = (int)(0x10U + src[63 - 2*i ]) >> 5;
v[63 - i] = (int)(0x10U - src[63 - 2*i - 1]) >> 5;
}
}
+38 -18
View File
@@ -601,7 +601,7 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame,
int i, res, ret;
int unp_size;
int bits, stereo;
unsigned pred[2], val;
unsigned pred[2], val, val2;
if (buf_size <= 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
@@ -672,24 +672,44 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame,
pred[i] = av_bswap16(get_bits(&gb, 16));
for(i = 0; i <= stereo; i++)
*samples++ = pred[i];
for(; i < unp_size / 2; i++) {
unsigned idx = 2 * (i & stereo);
if (get_bits_left(&gb) < 0) {
ret = AVERROR_INVALIDDATA;
goto error;
unp_size /= 2;
if (vlc[0 ].table || vlc[ 1].table ||
vlc[2*stereo].table || vlc[2*stereo+1].table) {
for(; i < unp_size ; i++) {
unsigned idx = 2 * (i & stereo);
if (get_bits_left(&gb) < 0) {
ret = AVERROR_INVALIDDATA;
goto error;
}
if (vlc[idx].table)
res = get_vlc2(&gb, vlc[idx].table, SMKTREE_BITS, 3);
else
res = values[idx];
val = res;
if (vlc[++idx].table)
res = get_vlc2(&gb, vlc[idx].table, SMKTREE_BITS, 3);
else
res = values[idx];
val |= res << 8;
pred[idx / 2] += val;
*samples++ = pred[idx / 2];
}
} else if (stereo) {
val = 256*values[1] + values[0];
val2 = 256*values[3] + values[2];
for(; i < unp_size; i+=2) {
pred[0] += val;
pred[1] += val2;
*samples++ = pred[0];
*samples++ = pred[1];
}
} else {
val = 256*values[1] + values[0];
for(; i < unp_size; i++) {
pred[0] += val;
*samples++ = pred[0];
}
if (vlc[idx].table)
res = get_vlc2(&gb, vlc[idx].table, SMKTREE_BITS, 3);
else
res = values[idx];
val = res;
if (vlc[++idx].table)
res = get_vlc2(&gb, vlc[idx].table, SMKTREE_BITS, 3);
else
res = values[idx];
val |= res << 8;
pred[idx / 2] += val;
*samples++ = pred[idx / 2];
}
} else { //8-bit data
for(i = stereo; i >= 0; i--)
+3
View File
@@ -761,6 +761,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
if (s->is_bayer) {
av_assert0(width == (s->bpp * s->width + 7) >> 3);
}
av_assert0(!(s->is_bayer && is_yuv));
if (p->format == AV_PIX_FMT_GRAY12) {
av_fast_padded_malloc(&s->yuv_line, &s->yuv_line_size, width);
if (s->yuv_line == NULL) {
@@ -844,6 +845,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
av_log(s->avctx, AV_LOG_ERROR, "More than one DNG JPEG strips unsupported\n");
return AVERROR_PATCHWELCOME;
}
if (!s->is_bayer)
return AVERROR_PATCHWELCOME;
if ((ret = dng_decode_jpeg(s->avctx, p, s->stripsize, 0, 0, s->width, s->height)) < 0)
return ret;
return 0;
+1 -1
View File
@@ -29,7 +29,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 36
#define LIBAVCODEC_VERSION_MINOR 38
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
+3 -3
View File
@@ -200,7 +200,7 @@ typedef struct WebPContext {
int has_alpha; /* has a separate alpha chunk */
enum AlphaCompression alpha_compression; /* compression type for alpha chunk */
enum AlphaFilter alpha_filter; /* filtering method for alpha chunk */
uint8_t *alpha_data; /* alpha chunk data */
const uint8_t *alpha_data; /* alpha chunk data */
int alpha_data_size; /* alpha chunk data size */
int has_exif; /* set after an EXIF chunk has been processed */
int has_iccp; /* set after an ICCP chunk has been processed */
@@ -1084,7 +1084,7 @@ static void update_canvas_size(AVCodecContext *avctx, int w, int h)
}
static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
int *got_frame, uint8_t *data_start,
int *got_frame, const uint8_t *data_start,
unsigned int data_size, int is_alpha_chunk)
{
WebPContext *s = avctx->priv_data;
@@ -1240,7 +1240,7 @@ static void alpha_inverse_prediction(AVFrame *frame, enum AlphaFilter m)
}
static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p,
uint8_t *data_start,
const uint8_t *data_start,
unsigned int data_size)
{
WebPContext *s = avctx->priv_data;
+3
View File
@@ -125,6 +125,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
{
static AVOnce init_static_once = AV_ONCE_INIT;
if (avctx->width <= 1)
return AVERROR_INVALIDDATA;
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
ff_thread_once(&init_static_once, wnv1_init_static);
+3 -3
View File
@@ -40,9 +40,9 @@ typedef struct YopDecContext {
int first_color[2];
int frame_data_length;
uint8_t *low_nibble;
uint8_t *srcptr;
uint8_t *src_end;
const uint8_t *low_nibble;
const uint8_t *srcptr;
const uint8_t *src_end;
uint8_t *dstptr;
uint8_t *dstbuf;
} YopDecContext;
+1 -1
View File
@@ -86,7 +86,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
AlsaData *s = s1->priv_data;
int res;
int size = pkt->size;
uint8_t *buf = pkt->data;
const uint8_t *buf = pkt->data;
size /= s->frame_size;
if (pkt->dts != AV_NOPTS_VALUE)
+2 -1
View File
@@ -100,7 +100,8 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
{
FBDevContext *fbdev = h->priv_data;
uint8_t *pin, *pout;
const uint8_t *pin;
uint8_t *pout;
enum AVPixelFormat fb_pix_fmt;
int disp_height;
int bytes_to_copy;
+1 -1
View File
@@ -55,9 +55,9 @@ static int audio_write_header(AVFormatContext *s1)
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
{
OSSAudioData *s = s1->priv_data;
const uint8_t *buf = pkt->data;
int len, ret;
int size= pkt->size;
uint8_t *buf= pkt->data;
while (size > 0) {
len = FFMIN(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size);
+1 -1
View File
@@ -46,7 +46,7 @@ static av_cold int audio_write_header(AVFormatContext *s1)
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
{
SndioData *s = s1->priv_data;
uint8_t *buf= pkt->data;
const uint8_t *buf = pkt->data;
int size = pkt->size;
int len, ret;
+1 -1
View File
@@ -29,7 +29,7 @@
#include "version_major.h"
#define LIBAVDEVICE_VERSION_MINOR 6
#define LIBAVDEVICE_VERSION_MINOR 8
#define LIBAVDEVICE_VERSION_MICRO 100
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
+4
View File
@@ -210,6 +210,8 @@ OBJS-$(CONFIG_CAS_FILTER) += vf_cas.o
OBJS-$(CONFIG_CHROMABER_VULKAN_FILTER) += vf_chromaber_vulkan.o vulkan.o vulkan_filter.o
OBJS-$(CONFIG_CHROMAHOLD_FILTER) += vf_chromakey.o
OBJS-$(CONFIG_CHROMAKEY_FILTER) += vf_chromakey.o
OBJS-$(CONFIG_CHROMAKEY_CUDA_FILTER) += vf_chromakey_cuda.o vf_chromakey_cuda.ptx.o
OBJS-$(CONFIG_CHROMANR_FILTER) += vf_chromanr.o
OBJS-$(CONFIG_CHROMASHIFT_FILTER) += vf_chromashift.o
OBJS-$(CONFIG_CIESCOPE_FILTER) += vf_ciescope.o
@@ -420,6 +422,8 @@ OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o
OBJS-$(CONFIG_READVITC_FILTER) += vf_readvitc.o
OBJS-$(CONFIG_REALTIME_FILTER) += f_realtime.o
OBJS-$(CONFIG_REMAP_FILTER) += vf_remap.o framesync.o
OBJS-$(CONFIG_REMAP_OPENCL_FILTER) += vf_remap_opencl.o framesync.o opencl.o \
opencl/remap.o
OBJS-$(CONFIG_REMOVEGRAIN_FILTER) += vf_removegrain.o
OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o
OBJS-$(CONFIG_REPEATFIELDS_FILTER) += vf_repeatfields.o
+2
View File
@@ -195,6 +195,7 @@ extern const AVFilter ff_vf_cas;
extern const AVFilter ff_vf_chromaber_vulkan;
extern const AVFilter ff_vf_chromahold;
extern const AVFilter ff_vf_chromakey;
extern const AVFilter ff_vf_chromakey_cuda;
extern const AVFilter ff_vf_chromanr;
extern const AVFilter ff_vf_chromashift;
extern const AVFilter ff_vf_ciescope;
@@ -399,6 +400,7 @@ extern const AVFilter ff_vf_readeia608;
extern const AVFilter ff_vf_readvitc;
extern const AVFilter ff_vf_realtime;
extern const AVFilter ff_vf_remap;
extern const AVFilter ff_vf_remap_opencl;
extern const AVFilter ff_vf_removegrain;
extern const AVFilter ff_vf_removelogo;
extern const AVFilter ff_vf_repeatfields;
+73
View File
@@ -0,0 +1,73 @@
/*
* 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
*/
const sampler_t linear_sampler = (CLK_NORMALIZED_COORDS_FALSE |
CLK_FILTER_LINEAR);
const sampler_t nearest_sampler = (CLK_NORMALIZED_COORDS_FALSE |
CLK_FILTER_NEAREST);
__kernel void remap_near(__write_only image2d_t dst,
__read_only image2d_t src,
__read_only image2d_t xmapi,
__read_only image2d_t ymapi,
float4 fill_color)
{
int2 p = (int2)(get_global_id(0), get_global_id(1));
int2 dimi = get_image_dim(src);
float2 dimf = (float2)(dimi.x, dimi.y);
float4 val;
int2 mi;
float m;
float4 xmap = read_imagef(xmapi, nearest_sampler, p);
float4 ymap = read_imagef(ymapi, nearest_sampler, p);
float2 pos = (float2)(xmap.x, ymap.x);
pos.xy = pos.xy * 65535.f;
mi = ((pos >= (float2)(0.f, 0.f)) * (pos < dimf) * (p <= dimi));
m = mi.x && mi.y;
val = mix(fill_color, read_imagef(src, nearest_sampler, pos), m);
write_imagef(dst, p, val);
}
__kernel void remap_linear(__write_only image2d_t dst,
__read_only image2d_t src,
__read_only image2d_t xmapi,
__read_only image2d_t ymapi,
float4 fill_color)
{
int2 p = (int2)(get_global_id(0), get_global_id(1));
int2 dimi = get_image_dim(src);
float2 dimf = (float2)(dimi.x, dimi.y);
float4 val;
int2 mi;
float m;
float4 xmap = read_imagef(xmapi, nearest_sampler, p);
float4 ymap = read_imagef(ymapi, nearest_sampler, p);
float2 pos = (float2)(xmap.x, ymap.x);
pos.xy = pos.xy * 65535.f;
mi = ((pos >= (float2)(0.f, 0.f)) * (pos < dimf) * (p <= dimi));
m = mi.x && mi.y;
val = mix(fill_color, read_imagef(src, linear_sampler, pos), m);
write_imagef(dst, p, val);
}
+1
View File
@@ -28,6 +28,7 @@ extern const char *ff_opencl_source_neighbor;
extern const char *ff_opencl_source_nlmeans;
extern const char *ff_opencl_source_overlay;
extern const char *ff_opencl_source_pad;
extern const char *ff_opencl_source_remap;
extern const char *ff_opencl_source_tonemap;
extern const char *ff_opencl_source_transpose;
extern const char *ff_opencl_source_unsharp;
+1 -1
View File
@@ -31,7 +31,7 @@
#include "version_major.h"
#define LIBAVFILTER_VERSION_MINOR 41
#define LIBAVFILTER_VERSION_MINOR 45
#define LIBAVFILTER_VERSION_MICRO 100
+498
View File
@@ -0,0 +1,498 @@
/*
* Copyright (c) 2022 Mohamed Khaled <Mohamed_Khaled_Kamal@outlook.com>
*
* 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
*/
#include <float.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "cuda/load_helper.h"
static const enum AVPixelFormat supported_formats[] = {
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NV12,
AV_PIX_FMT_YUVA420P
};
#define DIV_UP(a, b) (((a) + (b)-1) / (b))
#define BLOCKX 32
#define BLOCKY 16
#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
typedef struct ChromakeyCUDAContext {
const AVClass *class;
AVCUDADeviceContext *hwctx;
enum AVPixelFormat in_fmt, out_fmt;
const AVPixFmtDescriptor *in_desc, *out_desc;
int in_planes, out_planes;
int in_plane_depths[4];
int in_plane_channels[4];
uint8_t chromakey_rgba[4];
uint16_t chromakey_uv[2];
int is_yuv;
float similarity;
float blend;
AVBufferRef *frames_ctx;
AVFrame *frame;
AVFrame *tmp_frame;
CUcontext cu_ctx;
CUmodule cu_module;
CUfunction cu_func;
CUfunction cu_func_uv;
CUstream cu_stream;
} ChromakeyCUDAContext;
static av_cold int cudachromakey_init(AVFilterContext *ctx)
{
ChromakeyCUDAContext *s = ctx->priv;
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
s->tmp_frame = av_frame_alloc();
if (!s->tmp_frame)
return AVERROR(ENOMEM);
return 0;
}
static av_cold void cudachromakey_uninit(AVFilterContext *ctx)
{
ChromakeyCUDAContext *s = ctx->priv;
if (s->hwctx && s->cu_module)
{
CudaFunctions *cu = s->hwctx->internal->cuda_dl;
CUcontext context;
CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
CHECK_CU(cu->cuModuleUnload(s->cu_module));
s->cu_module = NULL;
CHECK_CU(cu->cuCtxPopCurrent(&context));
}
av_frame_free(&s->frame);
av_buffer_unref(&s->frames_ctx);
av_frame_free(&s->tmp_frame);
}
static av_cold int init_hwframe_ctx(ChromakeyCUDAContext *s, AVBufferRef *device_ctx, int width, int height)
{
AVBufferRef *out_ref = NULL;
AVHWFramesContext *out_ctx;
int ret;
out_ref = av_hwframe_ctx_alloc(device_ctx);
if (!out_ref)
return AVERROR(ENOMEM);
out_ctx = (AVHWFramesContext *)out_ref->data;
out_ctx->format = AV_PIX_FMT_CUDA;
out_ctx->sw_format = s->out_fmt;
out_ctx->width = width;
out_ctx->height = height;
ret = av_hwframe_ctx_init(out_ref);
if (ret < 0)
goto fail;
av_frame_unref(s->frame);
ret = av_hwframe_get_buffer(out_ref, s->frame, 0);
if (ret < 0)
goto fail;
av_buffer_unref(&s->frames_ctx);
s->frames_ctx = out_ref;
return 0;
fail:
av_buffer_unref(&out_ref);
return ret;
}
static int format_is_supported(enum AVPixelFormat fmt)
{
int i;
for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
if (supported_formats[i] == fmt)
return 1;
return 0;
}
static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_format, enum AVPixelFormat out_format)
{
ChromakeyCUDAContext *s = ctx->priv;
int i, p, d;
s->in_fmt = in_format;
s->out_fmt = out_format;
s->in_desc = av_pix_fmt_desc_get(s->in_fmt);
s->out_desc = av_pix_fmt_desc_get(s->out_fmt);
s->in_planes = av_pix_fmt_count_planes(s->in_fmt);
s->out_planes = av_pix_fmt_count_planes(s->out_fmt);
// find maximum step of each component of each plane
// For our subset of formats, this should accurately tell us how many channels CUDA needs
// i.e. 1 for Y plane, 2 for UV plane of NV12, 4 for single plane of RGB0 formats
for (i = 0; i < s->in_desc->nb_components; i++)
{
d = (s->in_desc->comp[i].depth + 7) / 8;
p = s->in_desc->comp[i].plane;
s->in_plane_channels[p] = FFMAX(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
s->in_plane_depths[p] = s->in_desc->comp[i].depth;
}
}
static av_cold int init_processing_chain(AVFilterContext *ctx, int width, int height)
{
ChromakeyCUDAContext *s = ctx->priv;
AVHWFramesContext *in_frames_ctx;
int ret;
/* check that we have a hw context */
if (!ctx->inputs[0]->hw_frames_ctx)
{
av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
return AVERROR(EINVAL);
}
in_frames_ctx = (AVHWFramesContext *)ctx->inputs[0]->hw_frames_ctx->data;
if (!format_is_supported(in_frames_ctx->sw_format))
{
av_log(ctx, AV_LOG_ERROR, "Unsupported format: %s\n", av_get_pix_fmt_name(in_frames_ctx->sw_format));
return AVERROR(ENOSYS);
}
set_format_info(ctx, in_frames_ctx->sw_format, AV_PIX_FMT_YUVA420P);
ret = init_hwframe_ctx(s, in_frames_ctx->device_ref, width, height);
if (ret < 0)
return ret;
ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->frames_ctx);
if (!ctx->outputs[0]->hw_frames_ctx)
return AVERROR(ENOMEM);
return 0;
}
static av_cold int cudachromakey_load_functions(AVFilterContext *ctx)
{
ChromakeyCUDAContext *s = ctx->priv;
CUcontext context, cuda_ctx = s->hwctx->cuda_ctx;
CudaFunctions *cu = s->hwctx->internal->cuda_dl;
int ret;
extern const unsigned char ff_vf_chromakey_cuda_ptx_data[];
extern const unsigned int ff_vf_chromakey_cuda_ptx_len;
ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
if (ret < 0)
return ret;
ret = ff_cuda_load_module(ctx, s->hwctx, &s->cu_module,
ff_vf_chromakey_cuda_ptx_data, ff_vf_chromakey_cuda_ptx_len);
if (ret < 0)
goto fail;
ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func, s->cu_module, "Process_uchar"));
if (ret < 0)
{
av_log(ctx, AV_LOG_FATAL, "Failed loading Process_uchar\n");
goto fail;
}
ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uv, s->cu_module, "Process_uchar2"));
if (ret < 0)
{
av_log(ctx, AV_LOG_FATAL, "Failed loading Process_uchar2\n");
goto fail;
}
fail:
CHECK_CU(cu->cuCtxPopCurrent(&context));
return ret;
}
#define FIXNUM(x) lrint((x) * (1 << 10))
#define RGB_TO_U(rgb) (((-FIXNUM(0.16874) * rgb[0] - FIXNUM(0.33126) * rgb[1] + FIXNUM(0.50000) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
#define RGB_TO_V(rgb) (((FIXNUM(0.50000) * rgb[0] - FIXNUM(0.41869) * rgb[1] - FIXNUM(0.08131) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
static av_cold int cudachromakey_config_props(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = outlink->src->inputs[0];
ChromakeyCUDAContext *s = ctx->priv;
AVHWFramesContext *frames_ctx = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
int ret;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
if (s->is_yuv) {
s->chromakey_uv[0] = s->chromakey_rgba[1];
s->chromakey_uv[1] = s->chromakey_rgba[2];
} else {
s->chromakey_uv[0] = RGB_TO_U(s->chromakey_rgba);
s->chromakey_uv[1] = RGB_TO_V(s->chromakey_rgba);
}
ret = init_processing_chain(ctx, inlink->w, inlink->h);
if (ret < 0)
return ret;
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
ret = cudachromakey_load_functions(ctx);
if (ret < 0)
return ret;
return 0;
}
static int call_cuda_kernel(AVFilterContext *ctx, CUfunction func,
CUtexObject src_tex[3], AVFrame *out_frame,
int width, int height, int pitch,
int width_uv, int height_uv, int pitch_uv,
float u_key, float v_key, float similarity,
float blend)
{
ChromakeyCUDAContext *s = ctx->priv;
CudaFunctions *cu = s->hwctx->internal->cuda_dl;
CUdeviceptr dst_devptr[4] = {
(CUdeviceptr)out_frame->data[0], (CUdeviceptr)out_frame->data[1],
(CUdeviceptr)out_frame->data[2], (CUdeviceptr)out_frame->data[3]
};
void *args_uchar[] = {
&src_tex[0], &src_tex[1], &src_tex[2],
&dst_devptr[0], &dst_devptr[1], &dst_devptr[2], &dst_devptr[3],
&width, &height, &pitch,
&width_uv, &height_uv, &pitch_uv,
&u_key, &v_key, &similarity, &blend
};
return CHECK_CU(cu->cuLaunchKernel(func,
DIV_UP(width, BLOCKX), DIV_UP(height, BLOCKY), 1,
BLOCKX, BLOCKY, 1, 0, s->cu_stream, args_uchar, NULL));
}
static int cudachromakey_process_internal(AVFilterContext *ctx,
AVFrame *out, AVFrame *in)
{
ChromakeyCUDAContext *s = ctx->priv;
CudaFunctions *cu = s->hwctx->internal->cuda_dl;
CUcontext context, cuda_ctx = s->hwctx->cuda_ctx;
int i, ret;
CUtexObject tex[3] = {0, 0, 0};
ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
if (ret < 0)
return ret;
for (i = 0; i < s->in_planes; i++)
{
CUDA_TEXTURE_DESC tex_desc = {
.filterMode = CU_TR_FILTER_MODE_LINEAR,
.flags = 0, // CU_TRSF_READ_AS_INTEGER to get raw ints instead of normalized floats from tex2D
};
CUDA_RESOURCE_DESC res_desc = {
.resType = CU_RESOURCE_TYPE_PITCH2D,
.res.pitch2D.format = CU_AD_FORMAT_UNSIGNED_INT8,
.res.pitch2D.numChannels = s->in_plane_channels[i],
.res.pitch2D.pitchInBytes = in->linesize[i],
.res.pitch2D.devPtr = (CUdeviceptr)in->data[i],
};
if (i == 1 || i == 2)
{
res_desc.res.pitch2D.width = AV_CEIL_RSHIFT(in->width, s->in_desc->log2_chroma_w);
res_desc.res.pitch2D.height = AV_CEIL_RSHIFT(in->height, s->in_desc->log2_chroma_h);
}
else
{
res_desc.res.pitch2D.width = in->width;
res_desc.res.pitch2D.height = in->height;
}
ret = CHECK_CU(cu->cuTexObjectCreate(&tex[i], &res_desc, &tex_desc, NULL));
if (ret < 0)
goto exit;
}
ret = call_cuda_kernel(ctx, (s->in_plane_channels[1] > 1) ? s->cu_func_uv : s->cu_func,
tex, out,
out->width, out->height, out->linesize[0],
AV_CEIL_RSHIFT(out->width, s->out_desc->log2_chroma_w),
AV_CEIL_RSHIFT(out->height, s->out_desc->log2_chroma_h),
out->linesize[1],
s->chromakey_uv[0], s->chromakey_uv[1],
s->similarity, s->blend);
if (ret < 0)
goto exit;
exit:
for (i = 0; i < s->in_planes; i++)
if (tex[i])
CHECK_CU(cu->cuTexObjectDestroy(tex[i]));
CHECK_CU(cu->cuCtxPopCurrent(&context));
return ret;
}
static int cudachromakey_process(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
{
ChromakeyCUDAContext *s = ctx->priv;
AVFrame *src = in;
int ret;
ret = cudachromakey_process_internal(ctx, s->frame, src);
if (ret < 0)
return ret;
src = s->frame;
ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0);
if (ret < 0)
return ret;
av_frame_move_ref(out, s->frame);
av_frame_move_ref(s->frame, s->tmp_frame);
ret = av_frame_copy_props(out, in);
if (ret < 0)
return ret;
return 0;
}
static int cudachromakey_filter_frame(AVFilterLink *link, AVFrame *in)
{
AVFilterContext *ctx = link->dst;
ChromakeyCUDAContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
CudaFunctions *cu = s->hwctx->internal->cuda_dl;
AVFrame *out = NULL;
CUcontext context;
int ret = 0;
out = av_frame_alloc();
if (!out)
{
ret = AVERROR(ENOMEM);
goto fail;
}
ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
if (ret < 0)
goto fail;
ret = cudachromakey_process(ctx, out, in);
CHECK_CU(cu->cuCtxPopCurrent(&context));
if (ret < 0)
goto fail;
av_frame_free(&in);
return ff_filter_frame(outlink, out);
fail:
av_frame_free(&in);
av_frame_free(&out);
return ret;
}
#define OFFSET(x) offsetof(ChromakeyCUDAContext, x)
#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
static const AVOption options[] = {
{"color", "set the chromakey key color", OFFSET(chromakey_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGS},
{"similarity", "set the chromakey similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, {.dbl = 0.01}, 0.01, 1.0, FLAGS},
{"blend", "set the chromakey key blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, FLAGS},
{"yuv", "color parameter is in yuv instead of rgb", OFFSET(is_yuv), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
{NULL},
};
static const AVClass cudachromakey_class = {
.class_name = "cudachromakey",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
static const AVFilterPad cudachromakey_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.filter_frame = cudachromakey_filter_frame,
},
};
static const AVFilterPad cudachromakey_outputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = cudachromakey_config_props,
},
};
const AVFilter ff_vf_chromakey_cuda = {
.name = "chromakey_cuda",
.description = NULL_IF_CONFIG_SMALL("GPU accelerated chromakey filter"),
.init = cudachromakey_init,
.uninit = cudachromakey_uninit,
.priv_size = sizeof(ChromakeyCUDAContext),
.priv_class = &cudachromakey_class,
FILTER_INPUTS(cudachromakey_inputs),
FILTER_OUTPUTS(cudachromakey_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_CUDA),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
+174
View File
@@ -0,0 +1,174 @@
/*
* Copyright (c) 2022 Mohamed Khaled <Mohamed_Khaled_Kamal@outlook.com>
*
* 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
*/
#include "cuda/vector_helpers.cuh"
extern "C"
{
/**
* @brief function contains the main logic of chroma keying, and changes the alpahc channel with the suitable value
*
* @param src_tex texture U or texture UV , decided based on the passed is_uchar2 flag
* @param src_tex_V texture V , used only if is_uchar2 flag is false
* @param dst_A alpha channel destination
* @param width_uv width of uv channels
* @param height_uv height of uv channels
* @param width width of alpha channel
* @param height height of alpha channel
* @param pitch pitch of alpha channel
* @param x current x coordinate of pixel
* @param y current y coordinate of pixel
* @param chromakey_uv uv values for chroma keying
* @param similarity similarity of keying
* @param blend blend of keying
*/
__device__ static inline void change_alpha_channel(
cudaTextureObject_t src_tex, cudaTextureObject_t src_tex_V, uchar *dst_A,
int width_uv, int height_uv,
int width, int height, int pitch,
int x, int y,
float2 chromakey_uv, float similarity, float blend)
{
int window_size = 3;
int start_r = x - window_size / 2;
int start_c = y - window_size / 2;
int resize_ratio = width / width_uv;
int counter = 0;
float diff = 0.0f;
float du, dv;
uchar alpha_value;
// loop over the eight neighbourhood of the current pixel(x,y)
for (uchar i = 0; i < window_size; i++)
{
for (uchar j = 0; j < window_size; j++)
{
float u_value, v_value;
int r = start_r + i;
int c = start_c + j;
if (r < 0 || r >= width_uv || c < 0 || c >= height_uv)
continue;
if (!src_tex_V) {
float2 temp_uv = tex2D<float2>(src_tex, r, c);
u_value = temp_uv.x;
v_value = temp_uv.y;
} else {
u_value = tex2D<float>(src_tex, r, c);
v_value = tex2D<float>(src_tex_V, r, c);
}
du = (u_value * 255.0f) - chromakey_uv.x;
dv = (v_value * 255.0f) - chromakey_uv.y;
diff += sqrtf((du * du + dv * dv) / (255.0f * 255.0f * 2.f));
counter++;
}
}
if (counter > 0)
diff = diff / counter;
else
diff /= 9.0f;
if (blend>0.0001f)
alpha_value = __saturatef((diff - similarity) / blend) * 255;
else
alpha_value = (diff < similarity) ? 0 : 255;
//write the value in the alpha channel with regarding the ratio of (alpha_size : uv_size)
for (uchar k = 0; k < resize_ratio; k++)
{
for (uchar l = 0; l < resize_ratio; l++)
{
int x_resize = x * resize_ratio + k;
int y_resize = y * resize_ratio + l;
int a_channel_resize = y_resize * pitch + x_resize;
if (y_resize >= height || x_resize >= width)
continue;
dst_A[a_channel_resize] = alpha_value;
}
}
}
__global__ void Process_uchar(
cudaTextureObject_t src_tex_Y, cudaTextureObject_t src_tex_U, cudaTextureObject_t src_tex_V,
uchar *dst_Y, uchar *dst_U, uchar *dst_V, uchar *dst_A,
int width, int height, int pitch,
int width_uv, int height_uv, int pitch_uv,
float u_key, float v_key, float similarity, float blend)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if (y >= height || x >= width)
return;
dst_Y[y * pitch + x] = tex2D<float>(src_tex_Y, x, y)*255;
if (y >= height_uv || x >= width_uv)
return;
int uv_index = y * pitch_uv + x;
dst_U[uv_index] = tex2D<float>(src_tex_U, x, y) * 255;
dst_V[uv_index] = tex2D<float>(src_tex_V, x, y) * 255;
change_alpha_channel(src_tex_U, src_tex_V, dst_A,
width_uv, height_uv,
width, height, pitch,
x, y,
make_float2(u_key, v_key), similarity, blend);
}
__global__ void Process_uchar2(
cudaTextureObject_t src_tex_Y, cudaTextureObject_t src_tex_UV, cudaTextureObject_t unused1,
uchar *dst_Y, uchar *dst_U, uchar *dst_V, uchar *dst_A,
int width, int height, int pitch,
int width_uv, int height_uv,int pitch_uv,
float u_key, float v_key, float similarity, float blend)
{
int x = blockIdx.x * blockDim.x + threadIdx.x; // x coordinate of current pixel
int y = blockIdx.y * blockDim.y + threadIdx.y; // y coordinate of current pixel
if (y >= height || x >= width)
return;
dst_Y[y * pitch + x] = tex2D<float>(src_tex_Y, x, y) * 255;
if (y >= height_uv || x >= width_uv)
return;
int uv_index = y * pitch_uv + x;
float2 uv_temp = tex2D<float2>(src_tex_UV, x, y);
dst_U[uv_index] = uv_temp.x * 255;
dst_V[uv_index] = uv_temp.y * 255;
change_alpha_channel(src_tex_UV, (cudaTextureObject_t)nullptr,
dst_A, width_uv, height_uv,
width, height, pitch,
x, y,
make_float2(u_key, v_key), similarity, blend);
}
}
+354
View File
@@ -0,0 +1,354 @@
/*
* Copyright (c) 2022 Paul B Mahol
*
* 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
*/
#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "framesync.h"
#include "internal.h"
#include "opencl.h"
#include "opencl_source.h"
#include "video.h"
typedef struct RemapOpenCLContext {
OpenCLFilterContext ocf;
int nb_planes;
int interp;
uint8_t fill_rgba[4];
cl_float4 cl_fill_color;
int initialised;
cl_kernel kernel;
cl_command_queue command_queue;
FFFrameSync fs;
} RemapOpenCLContext;
#define OFFSET(x) offsetof(RemapOpenCLContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
static const AVOption remap_opencl_options[] = {
{ "interp", "set interpolation method", OFFSET(interp), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "interp" },
{ "near", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "interp" },
{ "linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "interp" },
{ "fill", "set the color of the unmapped pixels", OFFSET(fill_rgba), AV_OPT_TYPE_COLOR, {.str="black"}, .flags = FLAGS },
{ NULL }
};
AVFILTER_DEFINE_CLASS(remap_opencl);
static av_cold int remap_opencl_init(AVFilterContext *avctx)
{
return ff_opencl_filter_init(avctx);
}
static const char *kernels[] = { "remap_near", "remap_linear" };
static int remap_opencl_load(AVFilterContext *avctx,
enum AVPixelFormat main_format,
enum AVPixelFormat xmap_format,
enum AVPixelFormat ymap_format)
{
RemapOpenCLContext *ctx = avctx->priv;
cl_int cle;
const char *source = ff_opencl_source_remap;
const char *kernel = kernels[ctx->interp];
const AVPixFmtDescriptor *main_desc;
int err, main_planes;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(main_format);
int is_rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
const float scale = 1.f / 255.f;
uint8_t rgba_map[4];
ff_fill_rgba_map(rgba_map, main_format);
if (is_rgb) {
ctx->cl_fill_color.s[rgba_map[0]] = ctx->fill_rgba[0] * scale;
ctx->cl_fill_color.s[rgba_map[1]] = ctx->fill_rgba[1] * scale;
ctx->cl_fill_color.s[rgba_map[2]] = ctx->fill_rgba[2] * scale;
ctx->cl_fill_color.s[rgba_map[3]] = ctx->fill_rgba[3] * scale;
} else {
ctx->cl_fill_color.s[0] = RGB_TO_Y_BT709(ctx->fill_rgba[0], ctx->fill_rgba[1], ctx->fill_rgba[2]) * scale;
ctx->cl_fill_color.s[1] = RGB_TO_U_BT709(ctx->fill_rgba[0], ctx->fill_rgba[1], ctx->fill_rgba[2], 0) * scale;
ctx->cl_fill_color.s[2] = RGB_TO_V_BT709(ctx->fill_rgba[0], ctx->fill_rgba[1], ctx->fill_rgba[2], 0) * scale;
ctx->cl_fill_color.s[3] = ctx->fill_rgba[3] * scale;
}
main_desc = av_pix_fmt_desc_get(main_format);
main_planes = 0;
for (int i = 0; i < main_desc->nb_components; i++)
main_planes = FFMAX(main_planes,
main_desc->comp[i].plane + 1);
ctx->nb_planes = main_planes;
err = ff_opencl_filter_load_program(avctx, &source, 1);
if (err < 0)
goto fail;
ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context,
ctx->ocf.hwctx->device_id,
0, &cle);
CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create OpenCL "
"command queue %d.\n", cle);
ctx->kernel = clCreateKernel(ctx->ocf.program, kernel, &cle);
CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create kernel %d.\n", cle);
ctx->initialised = 1;
return 0;
fail:
if (ctx->command_queue)
clReleaseCommandQueue(ctx->command_queue);
if (ctx->kernel)
clReleaseKernel(ctx->kernel);
return err;
}
static int remap_opencl_process_frame(FFFrameSync *fs)
{
AVFilterContext *avctx = fs->parent;
AVFilterLink *outlink = avctx->outputs[0];
RemapOpenCLContext *ctx = avctx->priv;
AVFrame *input_main, *input_xmap, *input_ymap;
AVFrame *output;
cl_mem mem;
cl_int cle;
size_t global_work[2];
int kernel_arg = 0;
int err, plane;
err = ff_framesync_get_frame(fs, 0, &input_main, 0);
if (err < 0)
return err;
err = ff_framesync_get_frame(fs, 1, &input_xmap, 0);
if (err < 0)
return err;
err = ff_framesync_get_frame(fs, 2, &input_ymap, 0);
if (err < 0)
return err;
if (!ctx->initialised) {
AVHWFramesContext *main_fc =
(AVHWFramesContext*)input_main->hw_frames_ctx->data;
AVHWFramesContext *xmap_fc =
(AVHWFramesContext*)input_xmap->hw_frames_ctx->data;
AVHWFramesContext *ymap_fc =
(AVHWFramesContext*)input_ymap->hw_frames_ctx->data;
err = remap_opencl_load(avctx, main_fc->sw_format,
xmap_fc->sw_format,
ymap_fc->sw_format);
if (err < 0)
return err;
}
output = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!output) {
err = AVERROR(ENOMEM);
goto fail;
}
for (plane = 0; plane < ctx->nb_planes; plane++) {
cl_float4 cl_fill_color;
kernel_arg = 0;
if (ctx->nb_planes == 1)
cl_fill_color = ctx->cl_fill_color;
else
cl_fill_color.s[0] = ctx->cl_fill_color.s[plane];
mem = (cl_mem)output->data[plane];
CL_SET_KERNEL_ARG(ctx->kernel, kernel_arg, cl_mem, &mem);
kernel_arg++;
mem = (cl_mem)input_main->data[plane];
CL_SET_KERNEL_ARG(ctx->kernel, kernel_arg, cl_mem, &mem);
kernel_arg++;
mem = (cl_mem)input_xmap->data[0];
CL_SET_KERNEL_ARG(ctx->kernel, kernel_arg, cl_mem, &mem);
kernel_arg++;
mem = (cl_mem)input_ymap->data[0];
CL_SET_KERNEL_ARG(ctx->kernel, kernel_arg, cl_mem, &mem);
kernel_arg++;
CL_SET_KERNEL_ARG(ctx->kernel, kernel_arg, cl_float4, &cl_fill_color);
kernel_arg++;
err = ff_opencl_filter_work_size_from_image(avctx, global_work,
output, plane, 0);
if (err < 0)
goto fail;
cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL,
global_work, NULL, 0, NULL, NULL);
CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue remap kernel "
"for plane %d: %d.\n", plane, cle);
}
cle = clFinish(ctx->command_queue);
CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to finish command queue: %d.\n", cle);
err = av_frame_copy_props(output, input_main);
av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
av_get_pix_fmt_name(output->format),
output->width, output->height, output->pts);
return ff_filter_frame(outlink, output);
fail:
av_frame_free(&output);
return err;
}
static int config_output(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
RemapOpenCLContext *s = ctx->priv;
AVFilterLink *srclink = ctx->inputs[0];
AVFilterLink *xlink = ctx->inputs[1];
AVFilterLink *ylink = ctx->inputs[2];
FFFrameSyncIn *in;
int ret;
if (xlink->w != ylink->w || xlink->h != ylink->h) {
av_log(ctx, AV_LOG_ERROR, "Second input link %s parameters "
"(size %dx%d) do not match the corresponding "
"third input link %s parameters (%dx%d)\n",
ctx->input_pads[1].name, xlink->w, xlink->h,
ctx->input_pads[2].name, ylink->w, ylink->h);
return AVERROR(EINVAL);
}
outlink->w = xlink->w;
outlink->h = xlink->h;
outlink->sample_aspect_ratio = srclink->sample_aspect_ratio;
outlink->frame_rate = srclink->frame_rate;
ret = ff_framesync_init(&s->fs, ctx, 3);
if (ret < 0)
return ret;
in = s->fs.in;
in[0].time_base = srclink->time_base;
in[1].time_base = xlink->time_base;
in[2].time_base = ylink->time_base;
in[0].sync = 2;
in[0].before = EXT_STOP;
in[0].after = EXT_STOP;
in[1].sync = 1;
in[1].before = EXT_NULL;
in[1].after = EXT_INFINITY;
in[2].sync = 1;
in[2].before = EXT_NULL;
in[2].after = EXT_INFINITY;
s->fs.opaque = s;
s->fs.on_event = remap_opencl_process_frame;
ret = ff_framesync_configure(&s->fs);
outlink->time_base = s->fs.time_base;
if (ret < 0)
return ret;
s->ocf.output_width = outlink->w;
s->ocf.output_height = outlink->h;
return ff_opencl_filter_config_output(outlink);
}
static int activate(AVFilterContext *ctx)
{
RemapOpenCLContext *s = ctx->priv;
return ff_framesync_activate(&s->fs);
}
static av_cold void remap_opencl_uninit(AVFilterContext *avctx)
{
RemapOpenCLContext *ctx = avctx->priv;
cl_int cle;
if (ctx->kernel) {
cle = clReleaseKernel(ctx->kernel);
if (cle != CL_SUCCESS)
av_log(avctx, AV_LOG_ERROR, "Failed to release "
"kernel: %d.\n", cle);
}
if (ctx->command_queue) {
cle = clReleaseCommandQueue(ctx->command_queue);
if (cle != CL_SUCCESS)
av_log(avctx, AV_LOG_ERROR, "Failed to release "
"command queue: %d.\n", cle);
}
ff_opencl_filter_uninit(avctx);
ff_framesync_uninit(&ctx->fs);
}
static const AVFilterPad remap_opencl_inputs[] = {
{
.name = "source",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = &ff_opencl_filter_config_input,
},
{
.name = "xmap",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = &ff_opencl_filter_config_input,
},
{
.name = "ymap",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = &ff_opencl_filter_config_input,
},
};
static const AVFilterPad remap_opencl_outputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_output,
},
};
const AVFilter ff_vf_remap_opencl = {
.name = "remap_opencl",
.description = NULL_IF_CONFIG_SMALL("Remap pixels using OpenCL."),
.priv_size = sizeof(RemapOpenCLContext),
.init = remap_opencl_init,
.uninit = remap_opencl_uninit,
.activate = activate,
FILTER_INPUTS(remap_opencl_inputs),
FILTER_OUTPUTS(remap_opencl_outputs),
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_OPENCL),
.priv_class = &remap_opencl_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
+2 -2
View File
@@ -219,7 +219,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
dw1 = inlink->w / 32;
if (inlink->w % 32)
dw2 = dw1 + 1;
denom = (sc->divide) ? dh1 * dh2 * dw1 * dw2 : 1;
denom = (sc->divide) ? dh1 * (int64_t)dh2 * dw1 * dw2 : 1;
for (i = 0; i < 32; i++) {
rowcount = 0;
@@ -245,7 +245,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
}
}
denom = (sc->divide) ? 1 : dh1 * dh2 * dw1 * dw2;
denom = (sc->divide) ? 1 : dh1 * (int64_t)dh2 * dw1 * dw2;
for (i = 0; i < ELEMENT_COUNT; i++) {
const ElemCat* elemcat = elements[i];
+74 -4
View File
@@ -74,6 +74,8 @@ enum XFadeTransitions {
SQUEEZEH,
SQUEEZEV,
ZOOMIN,
FADEFAST,
FADESLOW,
NB_TRANSITIONS,
};
@@ -193,6 +195,8 @@ static const AVOption xfade_options[] = {
{ "squeezeh", "squeeze h transition", 0, AV_OPT_TYPE_CONST, {.i64=SQUEEZEH}, 0, 0, FLAGS, "transition" },
{ "squeezev", "squeeze v transition", 0, AV_OPT_TYPE_CONST, {.i64=SQUEEZEV}, 0, 0, FLAGS, "transition" },
{ "zoomin", "zoom in transition", 0, AV_OPT_TYPE_CONST, {.i64=ZOOMIN}, 0, 0, FLAGS, "transition" },
{ "fadefast", "fast fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADEFAST}, 0, 0, FLAGS, "transition" },
{ "fadeslow", "slow fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADESLOW}, 0, 0, FLAGS, "transition" },
{ "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS },
{ "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
{ "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
@@ -429,7 +433,7 @@ static void slideleft##name##_transition(AVFilterContext *ctx,
for (int x = 0; x < width; x++) { \
const int zx = z + x; \
const int zz = zx % width + width * (zx < 0); \
dst[x] = (zx > 0) && (zx < width) ? xf1[zz] : xf0[zz]; \
dst[x] = (zx >= 0) && (zx < width) ? xf1[zz] : xf0[zz]; \
} \
\
dst += out->linesize[p] / div; \
@@ -462,7 +466,7 @@ static void slideright##name##_transition(AVFilterContext *ctx,
for (int x = 0; x < out->width; x++) { \
const int zx = z + x; \
const int zz = zx % width + width * (zx < 0); \
dst[x] = (zx > 0) && (zx < width) ? xf1[zz] : xf0[zz]; \
dst[x] = (zx >= 0) && (zx < width) ? xf1[zz] : xf0[zz]; \
} \
\
dst += out->linesize[p] / div; \
@@ -495,7 +499,7 @@ static void slideup##name##_transition(AVFilterContext *ctx,
const type *xf1 = (const type *)(b->data[p] + zz * b->linesize[p]); \
\
for (int x = 0; x < out->width; x++) { \
dst[x] = (zy > 0) && (zy < height) ? xf1[x] : xf0[x]; \
dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; \
} \
\
dst += out->linesize[p] / div; \
@@ -526,7 +530,7 @@ static void slidedown##name##_transition(AVFilterContext *ctx,
const type *xf1 = (const type *)(b->data[p] + zz * b->linesize[p]); \
\
for (int x = 0; x < out->width; x++) { \
dst[x] = (zy > 0) && (zy < height) ? xf1[x] : xf0[x]; \
dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; \
} \
\
dst += out->linesize[p] / div; \
@@ -1670,6 +1674,70 @@ static void zoomin##name##_transition(AVFilterContext *ctx,
ZOOMIN_TRANSITION(8, uint8_t, 1)
ZOOMIN_TRANSITION(16, uint16_t, 2)
#define FADEFAST_TRANSITION(name, type, div) \
static void fadefast##name##_transition(AVFilterContext *ctx, \
const AVFrame *a, const AVFrame *b, AVFrame *out, \
float progress, \
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const float imax = 1.f / s->max_value; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
dst[x] = mix(xf0[x], xf1[x], powf(progress, 1.f + \
logf(1.f+FFABS(xf0[x]-xf1[x])*imax)\
)); \
} \
\
dst += out->linesize[p] / div; \
xf0 += a->linesize[p] / div; \
xf1 += b->linesize[p] / div; \
} \
} \
}
FADEFAST_TRANSITION(8, uint8_t, 1)
FADEFAST_TRANSITION(16, uint16_t, 2)
#define FADESLOW_TRANSITION(name, type, div) \
static void fadeslow##name##_transition(AVFilterContext *ctx, \
const AVFrame *a, const AVFrame *b, AVFrame *out, \
float progress, \
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const float imax = 1.f / s->max_value; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
dst[x] = mix(xf0[x], xf1[x], powf(progress, 1.f + \
logf(2.f-FFABS(xf0[x]-xf1[x])*imax)\
)); \
} \
\
dst += out->linesize[p] / div; \
xf0 += a->linesize[p] / div; \
xf1 += b->linesize[p] / div; \
} \
} \
}
FADESLOW_TRANSITION(8, uint8_t, 1)
FADESLOW_TRANSITION(16, uint16_t, 2)
static inline double getpix(void *priv, double x, double y, int plane, int nb)
{
XFadeContext *s = priv;
@@ -1816,6 +1884,8 @@ static int config_output(AVFilterLink *outlink)
case SQUEEZEH: s->transitionf = s->depth <= 8 ? squeezeh8_transition : squeezeh16_transition; break;
case SQUEEZEV: s->transitionf = s->depth <= 8 ? squeezev8_transition : squeezev16_transition; break;
case ZOOMIN: s->transitionf = s->depth <= 8 ? zoomin8_transition : zoomin16_transition; break;
case FADEFAST: s->transitionf = s->depth <= 8 ? fadefast8_transition : fadefast16_transition; break;
case FADESLOW: s->transitionf = s->depth <= 8 ? fadeslow8_transition : fadeslow16_transition; break;
default: return AVERROR_BUG;
}
+6 -22
View File
@@ -149,12 +149,6 @@ static av_cold int init(AVFilterContext *ctx)
{
ZScaleContext *s = ctx->priv;
int ret;
int i;
for (i = 0; i < MAX_THREADS; i++) {
s->tmp[i] = NULL;
s->graph[i] = NULL;
s->alpha_graph[i] = NULL;
}
zimg_image_format_default(&s->src_format, ZIMG_API_VERSION);
zimg_image_format_default(&s->dst_format, ZIMG_API_VERSION);
zimg_image_format_default(&s->src_format_tmp, ZIMG_API_VERSION);
@@ -233,22 +227,12 @@ static int query_formats(AVFilterContext *ctx)
static void slice_params(ZScaleContext *s, int out_h, int in_h)
{
int slice_size;
slice_size = (out_h + (s->nb_threads / 2)) / s->nb_threads;
if (slice_size % 2)
slice_size += 1;
s->out_slice_start[0] = 0;
s->out_slice_end[0] = FFMIN(out_h, slice_size);
for (int i = 1; i < s->nb_threads - 1; i++) {
s->out_slice_start[i] = s->out_slice_end[i-1];
s->out_slice_end[i] = s->out_slice_start[i] + slice_size;
}
if (s->nb_threads > 1) {
s->out_slice_start[s->nb_threads - 1] = s->out_slice_end[s->nb_threads - 2];
s->out_slice_end[s->nb_threads - 1] = out_h;
for (int i = 1; i < s->nb_threads; i++) {
int slice_end = out_h * i / s->nb_threads;
s->out_slice_end[i - 1] = s->out_slice_start[i] = FFALIGN(slice_end, 2);
}
s->out_slice_end[s->nb_threads - 1] = out_h;
for (int i = 0; i < s->nb_threads; i++) {
s->in_slice_start[i] = s->out_slice_start[i] * in_h / (double)out_h;
@@ -853,7 +837,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
s->first_time = 0;
s->params.dither_type = s->dither;
s->params.cpu_type = ZIMG_CPU_AUTO;
s->params.cpu_type = ZIMG_CPU_AUTO_64B;
s->params.resample_filter = s->filter;
s->params.resample_filter_uv = s->filter;
s->params.nominal_peak_luminance = s->nominal_peak_luminance;
@@ -867,7 +851,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
zimg_graph_builder_params_default(&s->alpha_params, ZIMG_API_VERSION);
s->alpha_params.dither_type = s->dither;
s->alpha_params.cpu_type = ZIMG_CPU_AUTO;
s->alpha_params.cpu_type = ZIMG_CPU_AUTO_64B;
s->alpha_params.resample_filter = s->filter;
s->alpha_src_format.width = in->width;
+2
View File
@@ -250,6 +250,8 @@ static int aax_read_header(AVFormatContext *s)
start = avio_rb32(pb);
size = avio_rb32(pb);
if (!size)
return AVERROR_INVALIDDATA;
a->segments[r].start = start + a->data_offset;
a->segments[r].end = a->segments[r].start + size;
if (r &&
+2 -2
View File
@@ -222,7 +222,7 @@ static int apng_read_header(AVFormatContext *s)
ctx->num_frames, ctx->num_play);
break;
case MKTAG('f', 'c', 'T', 'L'):
if (!acTL_found || len != 26) {
if (!acTL_found || len != APNG_FCTL_CHUNK_SIZE) {
return AVERROR_INVALIDDATA;
}
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0)
@@ -336,7 +336,7 @@ static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
switch (tag) {
case MKTAG('f', 'c', 'T', 'L'):
if (len != 26)
if (len != APNG_FCTL_CHUNK_SIZE)
return AVERROR_INVALIDDATA;
if ((ret = decode_fctl_chunk(s, ctx, pkt)) < 0)
+26 -12
View File
@@ -27,6 +27,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavcodec/apng.h"
#include "libavcodec/png.h"
typedef struct APNGMuxContext {
@@ -47,10 +48,11 @@ typedef struct APNGMuxContext {
int extra_data_size;
} APNGMuxContext;
static uint8_t *apng_find_chunk(uint32_t tag, uint8_t *buf, size_t length)
static const uint8_t *apng_find_chunk(uint32_t tag, const uint8_t *buf,
size_t length)
{
size_t b;
for (b = 0; b < length; b += AV_RB32(buf + b) + 12)
for (b = 0; AV_RB32(buf + b) + 12ULL <= length - b; b += AV_RB32(buf + b) + 12ULL)
if (AV_RB32(&buf[b + 4]) == tag)
return &buf[b];
return NULL;
@@ -133,15 +135,15 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
}
if (apng->frame_number == 0 && !packet) {
uint8_t *existing_acTL_chunk;
uint8_t *existing_fcTL_chunk;
const uint8_t *existing_acTL_chunk;
const uint8_t *existing_fcTL_chunk;
av_log(format_context, AV_LOG_INFO, "Only a single frame so saving as a normal PNG.\n");
// Write normal PNG headers without acTL chunk
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), apng->extra_data, apng->extra_data_size);
if (existing_acTL_chunk) {
uint8_t *chunk_after_acTL = existing_acTL_chunk + AV_RB32(existing_acTL_chunk) + 12;
const uint8_t *chunk_after_acTL = existing_acTL_chunk + AV_RB32(existing_acTL_chunk) + 12;
avio_write(io_context, apng->extra_data, existing_acTL_chunk - apng->extra_data);
avio_write(io_context, chunk_after_acTL, apng->extra_data + apng->extra_data_size - chunk_after_acTL);
} else {
@@ -151,17 +153,18 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
// Write frame data without fcTL chunk
existing_fcTL_chunk = apng_find_chunk(MKBETAG('f', 'c', 'T', 'L'), apng->prev_packet->data, apng->prev_packet->size);
if (existing_fcTL_chunk) {
uint8_t *chunk_after_fcTL = existing_fcTL_chunk + AV_RB32(existing_fcTL_chunk) + 12;
const uint8_t *chunk_after_fcTL = existing_fcTL_chunk + AV_RB32(existing_fcTL_chunk) + 12;
avio_write(io_context, apng->prev_packet->data, existing_fcTL_chunk - apng->prev_packet->data);
avio_write(io_context, chunk_after_fcTL, apng->prev_packet->data + apng->prev_packet->size - chunk_after_fcTL);
} else {
avio_write(io_context, apng->prev_packet->data, apng->prev_packet->size);
}
} else {
uint8_t *existing_fcTL_chunk;
const uint8_t *data, *data_end;
const uint8_t *existing_fcTL_chunk;
if (apng->frame_number == 0) {
uint8_t *existing_acTL_chunk;
const uint8_t *existing_acTL_chunk;
// Write normal PNG headers
avio_write(io_context, apng->extra_data, apng->extra_data_size);
@@ -177,15 +180,22 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
}
}
data = apng->prev_packet->data;
data_end = data + apng->prev_packet->size;
existing_fcTL_chunk = apng_find_chunk(MKBETAG('f', 'c', 'T', 'L'), apng->prev_packet->data, apng->prev_packet->size);
if (existing_fcTL_chunk) {
AVRational delay;
if (AV_RB32(existing_fcTL_chunk) != APNG_FCTL_CHUNK_SIZE)
return AVERROR_INVALIDDATA;
existing_fcTL_chunk += 8;
delay.num = AV_RB16(existing_fcTL_chunk + 20);
delay.den = AV_RB16(existing_fcTL_chunk + 22);
if (delay.num == 0 && delay.den == 0) {
uint8_t new_fcTL_chunk[APNG_FCTL_CHUNK_SIZE];
if (packet) {
int64_t delay_num_raw = (packet->dts - apng->prev_packet->dts) * codec_stream->time_base.num;
int64_t delay_den_raw = codec_stream->time_base.den;
@@ -201,16 +211,20 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
delay = apng->prev_delay;
}
avio_write(io_context, data, (existing_fcTL_chunk - 8) - data);
data = existing_fcTL_chunk + APNG_FCTL_CHUNK_SIZE + 4 /* CRC-32 */;
// Update frame control header with new delay
AV_WB16(existing_fcTL_chunk + 20, delay.num);
AV_WB16(existing_fcTL_chunk + 22, delay.den);
AV_WB32(existing_fcTL_chunk + 26, ~av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), ~0U, existing_fcTL_chunk - 4, 26 + 4));
memcpy(new_fcTL_chunk, existing_fcTL_chunk, sizeof(new_fcTL_chunk));
AV_WB16(new_fcTL_chunk + 20, delay.num);
AV_WB16(new_fcTL_chunk + 22, delay.den);
apng_write_chunk(io_context, MKBETAG('f', 'c', 'T', 'L'),
new_fcTL_chunk, sizeof(new_fcTL_chunk));
}
apng->prev_delay = delay;
}
// Write frame data
avio_write(io_context, apng->prev_packet->data, apng->prev_packet->size);
avio_write(io_context, data, data_end - data);
}
++apng->frame_number;
+4
View File
@@ -426,6 +426,10 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, -1); /* quality */
avio_wl32(pb, au_ssize); /* sample size */
avio_wl32(pb, 0);
if (par->width > 65535 || par->height > 65535) {
av_log(s, AV_LOG_ERROR, "%dx%d dimensions are too big\n", par->width, par->height);
return AVERROR(EINVAL);
}
avio_wl16(pb, par->width);
avio_wl16(pb, par->height);
ff_end_tag(pb, strh);
+6 -5
View File
@@ -273,10 +273,11 @@ static int cine_read_header(AVFormatContext *avctx)
/* parse image offsets */
avio_seek(pb, offImageOffsets, SEEK_SET);
for (i = 0; i < st->duration; i++) {
if (avio_feof(pb))
int64_t pos = avio_rl64(pb);
if (avio_feof(pb) || pos < 0)
return AVERROR_INVALIDDATA;
av_add_index_entry(st, avio_rl64(pb), i, 0, 0, AVINDEX_KEYFRAME);
av_add_index_entry(st, pos, i, 0, 0, AVINDEX_KEYFRAME);
}
return 0;
@@ -302,10 +303,10 @@ static int cine_read_packet(AVFormatContext *avctx, AVPacket *pkt)
return AVERROR_INVALIDDATA;
avio_skip(pb, n - 8);
size = avio_rl32(pb);
if (avio_feof(pb))
if (avio_feof(pb) || size < 0)
return AVERROR_INVALIDDATA;
if (cine->maxsize && sti->index_entries[cine->pts].pos + size + n > cine->maxsize)
if (cine->maxsize && (uint64_t)sti->index_entries[cine->pts].pos + size + n > cine->maxsize)
size = cine->maxsize - sti->index_entries[cine->pts].pos - n;
ret = av_get_packet(pb, pkt, size);
@@ -313,7 +314,7 @@ static int cine_read_packet(AVFormatContext *avctx, AVPacket *pkt)
return ret;
if (ret != size)
cine->maxsize = sti->index_entries[cine->pts].pos + n + ret;
cine->maxsize = (uint64_t)sti->index_entries[cine->pts].pos + n + ret;
pkt->pts = cine->pts++;
pkt->stream_index = 0;
+1 -9
View File
@@ -1235,15 +1235,11 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
FFFormatContext *const si = ffformatcontext(s);
int ret, got_packet = 0;
AVDictionary *metadata = NULL;
int empty = 0;
while (!got_packet && !si->parse_queue.head) {
AVStream *st;
FFStream *sti;
if (empty > 1)
return AVERROR(EAGAIN);
/* read next packet */
ret = ff_read_packet(s, pkt);
if (ret < 0) {
@@ -1334,8 +1330,6 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
}
got_packet = 1;
} else if (st->discard < AVDISCARD_ALL) {
if (pkt->size == 0)
empty ++;
if ((ret = parse_packet(s, pkt, pkt->stream_index, 0)) < 0)
return ret;
st->codecpar->sample_rate = sti->avctx->sample_rate;
@@ -2615,10 +2609,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
/* NOTE: A new stream can be added there if no header in file
* (AVFMTCTX_NOHEADER). */
ret = read_frame_internal(ic, pkt1);
if (ret == AVERROR(EAGAIN)) {
read_size += 100;
if (ret == AVERROR(EAGAIN))
continue;
}
if (ret < 0) {
/* EOF or error*/
+1 -1
View File
@@ -245,7 +245,7 @@ static void dv_inject_metadata(DVMuxContext *c, uint8_t* frame)
static int dv_assemble_frame(AVFormatContext *s,
DVMuxContext *c, AVStream* st,
uint8_t* data, int data_size, uint8_t** frame)
const uint8_t *data, int data_size, uint8_t **frame)
{
int i, reqasize;
+16 -14
View File
@@ -733,7 +733,7 @@ static int flv_write_trailer(AVFormatContext *s)
int64_t cur_pos = avio_tell(s->pb);
if (build_keyframes_idx) {
FLVFileposition *newflv_posinfo, *p;
const FLVFileposition *newflv_posinfo;
avio_seek(pb, flv->videosize_offset, SEEK_SET);
put_amf_double(pb, flv->videosize);
@@ -768,19 +768,6 @@ static int flv_write_trailer(AVFormatContext *s)
put_amf_double(pb, newflv_posinfo->keyframe_timestamp);
}
newflv_posinfo = flv->head_filepositions;
while (newflv_posinfo) {
p = newflv_posinfo->next;
if (p) {
newflv_posinfo->next = p->next;
av_free(p);
p = NULL;
} else {
av_free(newflv_posinfo);
newflv_posinfo = NULL;
}
}
put_amf_string(pb, "");
avio_w8(pb, AMF_END_OF_OBJECT);
@@ -1047,6 +1034,20 @@ static int flv_check_bitstream(AVFormatContext *s, AVStream *st,
return ret;
}
static void flv_deinit(AVFormatContext *s)
{
FLVContext *flv = s->priv_data;
FLVFileposition *filepos = flv->head_filepositions;
while (filepos) {
FLVFileposition *next = filepos->next;
av_free(filepos);
filepos = next;
}
flv->filepositions = flv->head_filepositions = NULL;
flv->filepositions_count = 0;
}
static const AVOption options[] = {
{ "flvflags", "FLV muxer flags", offsetof(FLVContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
{ "aac_seq_header_detect", "Put AAC sequence header based on stream data", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_AAC_SEQ_HEADER_DETECT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
@@ -1076,6 +1077,7 @@ const AVOutputFormat ff_flv_muxer = {
.write_header = flv_write_header,
.write_packet = flv_write_packet,
.write_trailer = flv_write_trailer,
.deinit = flv_deinit,
.check_bitstream= flv_check_bitstream,
.codec_tag = (const AVCodecTag* const []) {
flv_video_codec_ids, flv_audio_codec_ids, 0
+1 -1
View File
@@ -54,7 +54,7 @@ static int gif_write_header(AVFormatContext *s)
return 0;
}
static int gif_parse_packet(AVFormatContext *s, uint8_t *data, int size)
static int gif_parse_packet(AVFormatContext *s, const uint8_t *data, int size)
{
GetByteContext gb;
int x;
+3 -2
View File
@@ -384,7 +384,7 @@ static int read_dst_frame(AVFormatContext *s, AVPacket *pkt)
avio_skip(pb, 1);
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->stream_index = 0;
pkt->duration = 588LL * s->streams[0]->codecpar->sample_rate / 44100;
pkt->duration = s->streams[0]->codecpar->sample_rate / 75;
pkt->pos = chunk_pos;
chunk_pos = avio_tell(pb);
@@ -397,7 +397,8 @@ static int read_dst_frame(AVFormatContext *s, AVPacket *pkt)
case ID_FRTE:
if (data_size < 4)
return AVERROR_INVALIDDATA;
s->streams[0]->duration = avio_rb32(pb) * 588LL * s->streams[0]->codecpar->sample_rate / 44100;
s->streams[0]->duration = avio_rb32(pb) * (uint64_t)s->streams[0]->codecpar->sample_rate / 75;
break;
}
+14 -8
View File
@@ -36,6 +36,7 @@
typedef struct VideoMuxData {
const AVClass *class; /**< Class for private options. */
int start_img_number;
int img_number;
int split_planes; /**< use independent file for each Y, U, V plane */
char tmp[4][1024];
@@ -69,6 +70,7 @@ static int write_header(AVFormatContext *s)
&&(desc->flags & AV_PIX_FMT_FLAG_PLANAR)
&& desc->nb_components >= 3;
}
img->img_number = img->start_img_number;
return 0;
}
@@ -161,13 +163,17 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
}
} else if (av_get_frame_filename2(filename, sizeof(filename), s->url,
img->img_number,
AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
img->img_number > 1) {
av_log(s, AV_LOG_ERROR,
"Could not get frame filename number %d from pattern '%s'. "
"Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n",
img->img_number, s->url);
return AVERROR(EINVAL);
AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
if (img->img_number == img->start_img_number) {
av_log(s, AV_LOG_WARNING, "The specified filename '%s' does not contain an image sequence pattern or a pattern is invalid.\n", s->url);
av_log(s, AV_LOG_WARNING,
"Use a pattern such as %%03d for an image sequence or "
"use the -update option (with -frames:v 1 if needed) to write a single image.\n");
av_strlcpy(filename, s->url, sizeof(filename));
} else {
av_log(s, AV_LOG_ERROR, "Cannot write more than one file with the same name. Are you missing the -update option or a sequence pattern?\n");
return AVERROR(EINVAL);
}
}
for (i = 0; i < 4; i++) {
av_dict_copy(&options, img->protocol_opts, 0);
@@ -246,7 +252,7 @@ static int query_codec(enum AVCodecID id, int std_compliance)
#define ENC AV_OPT_FLAG_ENCODING_PARAM
static const AVOption muxoptions[] = {
{ "update", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
{ "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC },
{ "start_number", "set first number in the sequence", OFFSET(start_img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC },
{ "strftime", "use strftime for filename", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
{ "frame_pts", "use current frame pts for filename", OFFSET(frame_pts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
{ "atomic_writing", "write files atomically (using temporary files and renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
+2
View File
@@ -89,6 +89,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
{ AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
{ AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */
{ AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'l', 'p') }, /* DV PAL 16:9 produced by Radius SoftDV */
{ AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'l', ' ') }, /* DV NTSC 16:9 produced by Radius SoftDV */
{ AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'p', 'p') }, /* DVCPRO PAL produced by FCP */
{ AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'p') }, /* DVCPRO50 PAL produced by FCP */
{ AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'n') }, /* DVCPRO50 NTSC produced by FCP */
+4 -27
View File
@@ -5179,6 +5179,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
distance++;
if (av_sat_add64(dts, sample_duration) != dts + (uint64_t)sample_duration)
return AVERROR_INVALIDDATA;
if (!sample_size)
return AVERROR_INVALIDDATA;
dts += sample_duration;
offset += sample_size;
sc->data_size += sample_size;
@@ -6822,9 +6824,6 @@ static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption
{
int i, ret;
int bytes_of_protected_data;
int partially_encrypted_block_size;
uint8_t *partially_encrypted_block;
uint8_t block[16];
if (!sc->cenc.aes_ctr) {
/* initialize the cipher */
@@ -6847,8 +6846,6 @@ static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption
return 0;
}
partially_encrypted_block_size = 0;
for (i = 0; i < sample->subsample_count; i++) {
if (sample->subsamples[i].bytes_of_clear_data + sample->subsamples[i].bytes_of_protected_data > size) {
av_log(c->fc, AV_LOG_ERROR, "subsample size exceeds the packet size left\n");
@@ -6861,28 +6858,8 @@ static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption
/* decrypt the encrypted bytes */
if (partially_encrypted_block_size) {
memcpy(block, partially_encrypted_block, partially_encrypted_block_size);
memcpy(block+partially_encrypted_block_size, input, 16-partially_encrypted_block_size);
av_aes_ctr_crypt(sc->cenc.aes_ctr, block, block, 16);
memcpy(partially_encrypted_block, block, partially_encrypted_block_size);
memcpy(input, block+partially_encrypted_block_size, 16-partially_encrypted_block_size);
input += 16-partially_encrypted_block_size;
size -= 16-partially_encrypted_block_size;
bytes_of_protected_data = sample->subsamples[i].bytes_of_protected_data - (16-partially_encrypted_block_size);
} else {
bytes_of_protected_data = sample->subsamples[i].bytes_of_protected_data;
}
if (i < sample->subsample_count-1) {
int num_of_encrypted_blocks = bytes_of_protected_data/16;
partially_encrypted_block_size = bytes_of_protected_data%16;
if (partially_encrypted_block_size)
partially_encrypted_block = input + 16*num_of_encrypted_blocks;
av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, 16*num_of_encrypted_blocks);
} else {
av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, bytes_of_protected_data);
}
bytes_of_protected_data = sample->subsamples[i].bytes_of_protected_data;
av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, bytes_of_protected_data);
input += bytes_of_protected_data;
size -= bytes_of_protected_data;
+3
View File
@@ -6513,6 +6513,9 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
} else if (trk->par->codec_id == AV_CODEC_ID_RAWVIDEO &&
(trk->par->format == AV_PIX_FMT_GRAY8 ||
trk->par->format == AV_PIX_FMT_MONOBLACK)) {
ret = av_packet_make_writable(pkt);
if (ret < 0)
goto fail;
for (i = 0; i < pkt->size; i++)
pkt->data[i] = ~pkt->data[i];
}
+1 -1
View File
@@ -62,7 +62,7 @@ typedef struct MOVIentry {
} MOVIentry;
typedef struct HintSample {
uint8_t *data;
const uint8_t *data;
int size;
int sample_number;
int offset;
+1 -1
View File
@@ -96,7 +96,7 @@ static void sample_queue_free(HintSampleQueue *queue)
* not copied. sample_queue_retain should be called before pkt->data
* is reused/freed.
*/
static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
static void sample_queue_push(HintSampleQueue *queue, const uint8_t *data, int size,
int sample)
{
/* No need to keep track of smaller samples, since describing them
+1 -1
View File
@@ -2139,7 +2139,7 @@ static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{
MXFContext *mxf = s->priv_data;
MXFStreamContext *sc = st->priv_data;
uint8_t *vs_pack, *vsc_pack;
const uint8_t *vs_pack, *vsc_pack;
int apt, ul_index, stype, pal;
if (mxf->header_written)
+2 -2
View File
@@ -197,13 +197,13 @@ static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
}
static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
uint8_t *data, unsigned size, int64_t granule,
const uint8_t *data, unsigned size, int64_t granule,
int header)
{
OGGStreamContext *oggstream = st->priv_data;
OGGContext *ogg = s->priv_data;
int total_segments = size / 255 + 1;
uint8_t *p = data;
const uint8_t *p = data;
int i, segments, len, flush = 0;
// Handles VFR by flushing page because this frame needs to have a timestamp
+2
View File
@@ -949,6 +949,8 @@ static void rtsp_parse_transport(AVFormatContext *s,
";,", &p);
}
th->transport = RTSP_TRANSPORT_RAW;
} else {
break;
}
if (!av_strcasecmp(lower_transport, "TCP"))
th->lower_transport = RTSP_LOWER_TRANSPORT_TCP;
+2
View File
@@ -282,6 +282,8 @@ fail:
goto restart;
}
fail1:
if (fd >= 0)
closesocket(fd);
ret = AVERROR(EIO);
freeaddrinfo(ai);
return ret;
+2 -2
View File
@@ -63,7 +63,7 @@ typedef struct IEC61937Context {
uint8_t *buffer; ///< allocated buffer, used for swap bytes
int buffer_size; ///< size of allocated buffer
uint8_t *out_buf; ///< pointer to the outgoing data before byte-swapping
const uint8_t *out_buf; ///< pointer to the outgoing data before byte-swapping
int out_bytes; ///< amount of outgoing bytes
int use_preamble; ///< preamble enabled (disabled for exactly pre-padded DTS)
@@ -657,7 +657,7 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
if (!ctx->buffer)
return AVERROR(ENOMEM);
ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (const uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1);
}
+2 -2
View File
@@ -481,8 +481,8 @@ static int swf_write_video(AVFormatContext *s,
return 0;
}
static int swf_write_audio(AVFormatContext *s,
AVCodecParameters *par, uint8_t *buf, int size)
static int swf_write_audio(AVFormatContext *s, AVCodecParameters *par,
const uint8_t *buf, int size)
{
SWFEncContext *swf = s->priv_data;
+1 -1
View File
@@ -31,7 +31,7 @@
#include "version_major.h"
#define LIBAVFORMAT_VERSION_MINOR 26
#define LIBAVFORMAT_VERSION_MINOR 28
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
+4 -1
View File
@@ -1411,7 +1411,8 @@ static int opencl_get_plane_format(enum AVPixelFormat pixfmt,
// The bits in each component must be packed in the
// most-significant-bits of the relevant bytes.
if (comp->shift + comp->depth != 8 &&
comp->shift + comp->depth != 16)
comp->shift + comp->depth != 16 &&
comp->shift + comp->depth != 32)
return AVERROR(EINVAL);
// The depth must not vary between components.
if (depth && comp->depth != depth)
@@ -1455,6 +1456,8 @@ static int opencl_get_plane_format(enum AVPixelFormat pixfmt,
} else {
if (depth <= 16)
image_format->image_channel_data_type = CL_UNORM_INT16;
else if (depth == 32)
image_format->image_channel_data_type = CL_FLOAT;
else
return AVERROR(EINVAL);
}
+4
View File
@@ -510,6 +510,8 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
return ptr;
max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
/* *size is an unsigned, so the real maximum is <= UINT_MAX. */
max_size = FFMIN(max_size, UINT_MAX);
if (min_size > max_size) {
*size = 0;
@@ -542,6 +544,8 @@ static inline void fast_malloc(void *ptr, unsigned int *size, size_t min_size, i
}
max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
/* *size is an unsigned, so the real maximum is <= UINT_MAX. */
max_size = FFMIN(max_size, UINT_MAX);
if (min_size > max_size) {
av_freep(ptr);
+1 -1
View File
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 57
#define LIBAVUTIL_VERSION_MINOR 27
#define LIBAVUTIL_VERSION_MINOR 29
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
+1 -1
View File
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBPOSTPROC_VERSION_MINOR 5
#define LIBPOSTPROC_VERSION_MINOR 7
#define LIBPOSTPROC_VERSION_MICRO 100
#define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \
+1 -1
View File
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBSWRESAMPLE_VERSION_MINOR 6
#define LIBSWRESAMPLE_VERSION_MINOR 8
#define LIBSWRESAMPLE_VERSION_MICRO 100
#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \
+1 -1
View File
@@ -28,7 +28,7 @@
#include "version_major.h"
#define LIBSWSCALE_VERSION_MINOR 6
#define LIBSWSCALE_VERSION_MINOR 8
#define LIBSWSCALE_VERSION_MICRO 100
#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
+2
View File
@@ -231,6 +231,7 @@ FATE_H264-$(call FRAMECRC, MXF, H264, PCM_S24LE_DECODER SCALE_FILTER ARESAMPLE_F
FATE_H264-$(call FRAMECRC, MOV, H264) += fate-h264-attachment-631
FATE_H264-$(call FRAMECRC, MPEGTS, H264, H264_PARSER MP3_DECODER SCALE_FILTER ARESAMPLE_FILTER) += fate-h264-skip-nokey fate-h264-skip-nointra
FATE_H264_FFPROBE-$(call DEMDEC, MATROSKA, H264) += fate-h264-dts_5frames
FATE_H264_FFPROBE-$(call PARSERDEMDEC, H264, H264, H264) += fate-h264-afd
FATE_SAMPLES_AVCONV += $(FATE_H264-yes)
FATE_SAMPLES_FFPROBE += $(FATE_H264_FFPROBE-yes)
@@ -450,6 +451,7 @@ fate-h264-timecode: CMD = framecrc -i $(TARGET_SAM
fate-h264-reinit-%: CMD = framecrc -i $(TARGET_SAMPLES)/h264/$(@:fate-h264-%=%).h264 -vf scale,format=yuv444p10le,scale=w=352:h=288
fate-h264-dts_5frames: CMD = probeframes $(TARGET_SAMPLES)/h264/dts_5frames.mkv
fate-h264-afd: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -bitexact -show_entries frame_side_data_list $(TARGET_SAMPLES)/h264/bbc2.sample.h264
fate-h264-encparams: CMD = venc_data $(TARGET_SAMPLES)/h264-conformance/FRext/FRExt_MMCO4_Sony_B.264 0 1
FATE_SAMPLES_DUMP_DATA += fate-h264-encparams
+31
View File
@@ -27,6 +27,37 @@ fate-dcinema-encode: tests/data/asynth-96000-6.wav
fate-dcinema-encode: SRC = tests/data/asynth-96000-6.wav
fate-dcinema-encode: CMD = enc_dec_pcm daud framemd5 s16le $(SRC) -c:a pcm_s24daud -frames:a 20
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, TRUEHD_DEMUXER TRUEHD_DECODER PCM_S24LE_ENCODER) += fate-pcm_dvd-24-7.1-48000
fate-pcm_dvd-24-7.1-48000: CMD = transcode truehd $(TARGET_SAMPLES)/truehd/atmos.thd vob "-c:a pcm_dvd" "-c:a pcm_s24le"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, MXF_DEMUXER PCM_S16LE_DECODER) += fate-pcm_dvd-16-7.1-48000
fate-pcm_dvd-16-7.1-48000: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Sony-00001.mxf vob "-map 0:a -c:a pcm_dvd"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, DAUD_DEMUXER PCM_S24DAUD_DECODER) += fate-pcm_dvd-16-5.1-96000
fate-pcm_dvd-16-5.1-96000: CMD = transcode daud $(TARGET_SAMPLES)/d-cinema/THX_Science_FLT_1920-partial.302 vob "-c:a pcm_dvd"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, TRUEHD_DEMUXER TRUEHD_DECODER PCM_S24LE_ENCODER) += fate-pcm_dvd-24-5.1-48000
fate-pcm_dvd-24-5.1-48000: CMD = transcode truehd $(TARGET_SAMPLES)/lossless-audio/truehd_5.1.raw vob "-c:a pcm_dvd" "-c:a pcm_s24le -t 0.2"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, MATROSKA_DEMUXER FLAC_DECODER) += fate-pcm_dvd-16-5.1-48000
fate-pcm_dvd-16-5.1-48000: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/flac_channel_layouts.mka vob "-map 0:a:1 -c:a pcm_dvd" "-t 0.2"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, FLAC_DEMUXER FLAC_PARSER FLAC_DECODER PCM_S24LE_ENCODER) += fate-pcm_dvd-24-2-48000
fate-pcm_dvd-24-2-48000: CMD = transcode flac $(TARGET_SAMPLES)/filter/seq-3341-7_seq-3342-5-24bit.flac vob "-c:a pcm_dvd" "-c:a pcm_s24le -t 0.2"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, WAV_DEMUXER PCM_S16LE_DECODER) += fate-pcm_dvd-16-2-48000
fate-pcm_dvd-16-2-48000: CMD = transcode wav $(TARGET_SAMPLES)/wav/200828-005.wav vob "-c:a pcm_dvd" "-t 0.2"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, MXF_DEMUXER PCM_S24LE_DECODER PCM_S24LE_ENCODER) += fate-pcm_dvd-24-1-48000
fate-pcm_dvd-24-1-48000: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/omneon_8.3.0.0_xdcam_startc_footer.mxf vob "-map 0:a:0 -c:a pcm_dvd" "-c:a pcm_s24le"
FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, MXF_DEMUXER PCM_S16LE_DECODER) += fate-pcm_dvd-16-1-48000
fate-pcm_dvd-16-1-48000: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/opatom_missing_index.mxf vob "-c:a pcm_dvd"
FATE_PCM-$(call TRANSCODE, PCM_DVD, MPEG2VOB MPEGPS, WAV_DEMUXER PCM_S16LE_DECODER) += fate-pcm_dvd-16-1-96000
fate-pcm_dvd-16-1-96000: tests/data/asynth-96000-1.wav
fate-pcm_dvd-16-1-96000: CMD = transcode wav $(TARGET_PATH)/tests/data/asynth-96000-1.wav vob "-c:a pcm_dvd" "-t 0.2"
FATE_FFMPEG += $(FATE_PCM-yes)
FATE_SAMPLES_AVCONV += $(FATE_SAMPLES_PCM-yes)
fate-pcm: $(FATE_PCM-yes) $(FATE_SAMPLES_PCM-yes)
+282
View File
@@ -0,0 +1,282 @@
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
[FRAME]
[SIDE_DATA]
side_data_type=Active format description
active_format=14
[/SIDE_DATA]
[/FRAME]
+11
View File
@@ -0,0 +1,11 @@
af7b5ae365019ec64a9397bc6b33e18c *tests/data/fate/pcm_dvd-16-1-48000.vob
8192 tests/data/fate/pcm_dvd-16-1-48000.vob
#tb 0: 1/48000
#media_type 0: audio
#codec_id 0: pcm_s16le
#sample_rate 0: 48000
#channel_layout_name 0: mono
0, 0, 0, 997, 1994, 0xd416def5
0, 1004, 1004, 1006, 2012, 0xb492d66d
0, 2008, 2008, 1006, 2012, 0x52d3f72e
0, 3012, 3012, 995, 1990, 0xa23de22f

Some files were not shown because too many files have changed in this diff Show More