summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/dca: Unavpriv dca_sample_ratesAndreas Rheinhardt2022-01-047-14/+67
| | | | | | | | | | | | | | | Said table is 64 bytes long and exported so that it can be used both in libavcodec and libavformat. This commit stops doing so and instead duplicates it for shared builds, because the overhead of exporting the symbol is bigger than 64 bytes. It consists of the length of the name of the symbol (2x24 bytes), two entries in .dynsym (2x24 bytes), two entries for symbol version (2x2 bytes), one hash value in the exporting library (4 bytes) in addition to one entry in the importing library's .got and .rela.dyn (8 + 24 bytes). (The above numbers are for a Linux/GNU/Elf system; the numbers for other platforms may be different.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3tab: Unavpriv ac3_channel_layout_tabAndreas Rheinhardt2022-01-049-24/+78
| | | | | | | | | | | | | | | | | It is small (16 B) and therefore the overhead of exporting it more than outweighs the size savings from not having duplicated symbols: When the symbol is no longer avpriv, one saves twice the size of the string containing the symbols name (2x30 byte), two entries in .dynsym (24 bytes each on x64), one entry in the importing libraries .got and .rela.dyn (8 + 24 bytes on x64) and two entries for the symbol version (2 bytes each) and one hash value in the exporting library (4 bytes). (The exact numbers are of course different for other platforms (e.g. when using dlls), but given that the strings saved alone more than outweigh the array size it can be presumed that this is beneficial for all platforms.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/raw: Reduce number of avpriv symbolsAndreas Rheinhardt2022-01-044-26/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libavcodec currently exports four avpriv symbols that deal with PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt, avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are lists of PixelFormatTags, the former returns such a list and the second searches a list for a pixel format that matches a given fourcc; only one of the aforementioned three lists is ever searched. Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and avpriv_find_pix_fmt the overhead of exporting these functions actually exceeds the size of said objects (at least for ELF; the following numbers are for x64 Ubuntu 20.10): The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B), yet exporting it adds a 20B string for the name alone to the exporting as well as to each importing library; there is more: Four bytes in the exporting libraries .gnu.hash; two bytes each for the exporting as well as each importing libraries .gnu.version; 24B in the exporting as well as each importing libraries .dynsym; 16B+24B for an entry in .plt as well as the accompanying relocation entry in .rela.plt for each importing library. The overhead for the lists is similar: The strings are 23B and the .plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and a relocation entry in .rela.dyn. These lists have a size of 80 resp. 72 bytes. Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to duplicating it into libavformat and potentially libavdevice. Therefore this commit replaces all library uses of the four symbols with a single function that is exported for shared builds. It has an enum parameter to choose the desired list besides the parameter for the fourcc. New lists can be supported with new enum values. Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this function remains. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/hevcdec: Parse DOVI RPU NALsNiklas Haas2022-01-042-8/+31
| | | | | | | | | | | | | | | | And expose the parsed values as frame side data. Update FATE results to match. It's worth documenting that this relies on the dovi configuration record being present on the first AVPacket fed to the decoder, which in practice is the case if if the API user has called something like av_format_inject_global_side_data, which is unfortunately not the default. This commit is not the time and place to change that behavior, though. Signed-off-by: Niklas Haas <git@haasn.dev> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc: Implement Dolby Vision RPU parsingNiklas Haas2022-01-043-0/+537
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on a mixture of guesswork, partial documentation in patents, and reverse engineering of real-world samples. Confirmed working for all the samples I've thrown at it. Contains some annoying machinery to persist these values in between frames, which is needed in theory even though I've never actually seen a sample that relies on it in practice. May or may not work. Since the distinction matters greatly for parsing the color matrix values, this includes a small helper function to guess the right profile from the RPU itself in case the user has forgotten to forward the dovi configuration record to the decoder. (Which in practice, only ffmpeg.c and ffplay do..) Notable omissions / deviations: - CRC32 verification. This is based on the MPEG2 CRC32 type, which is similar to IEEE CRC32 but apparently different in subtle enough ways that I could not get it to pass verification no matter what parameters I fed to av_crc. It's possible the code needs some changes. - Linear interpolation support. Nothing documents this (beyond its existence) and no samples use it, so impossible to implement. - All of the extension metadata blocks, but these contain values that seem largely congruent with ST2094, HDR10, or other existing forms of side data, so I will defer parsing/attaching them to a future commit. - The patent describes a mechanism for predicting coefficients from previous RPUs, but the bit for the flag whether to use the prediction deltas or signal entirely new coefficients does not seem to be present in actual RPUs, so we ignore this subsystem entirely. - In the patent's spec, the NLQ subsystem also loops over num_nlq_pivots, but even in the patent the number is hard-coded to one iteration rather than signalled. So we only store one set of coefs. Heavily influenced by https://github.com/quietvoid/dovi_tool Documentation drawn from US Patent 10,701,399 B2 and ETSI GS CCM 001 Signed-off-by: Niklas Haas <git@haasn.dev> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Makefile: Redo duplicating object files in shared buildsAndreas Rheinhardt2022-01-041-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case of shared builds, some object files containing tables are currently duplicated into other libraries: log2_tab.c, golomb.c, reverse.c. The check for whether this is duplicated is simply whether CONFIG_SHARED is true. Yet this is crude: E.g. libavdevice includes reverse.c for shared builds, but only needs it for the decklink input device, which given that decklink is not enabled by default will be unused in most libavdevice.so. This commit changes this by making it more explicit about what to duplicate from other libraries. To do this, two new Makefile variables were added: SHLIBOBJS and STLIBOBJS. SHLIBOBJS contains the objects that are duplicated from other libraries in case of shared builds; STLIBOBJS contains stuff that a library has to provide for other libraries in case of static builds. These new variables provide a way to enable/disable with a finer granularity than just whether shared builds are enabled or not. E.g. lavd's Makefile now contains: SHLIBOBJS-$(CONFIG_DECKLINK_INDEV) += reverse.o Another example is provided by the golomb tables. These are provided by lavc for static builds, even if one uses a build configuration that makes only lavf use them. Therefore lavc's Makefile contains STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o, whereas lavf's Makefile has a corresponding SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o. E.g. in case the MXF muxer is the only component needing these tables only libavformat.so will contain them for shared builds; currently libavcodec.so does so, too. (There is currently a CONFIG_EXTRA group for golomb. But actually one would need two groups (golomb_avcodec and golomb_avformat) in order to know when and where to include these tables. Therefore this commit uses a Makefile-based approach for this and stops using these groups for the users in libavformat.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lib*/version.h: Bump Versions after release/5.0 branchMichael Niedermayer2022-01-031-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lib*/version.h: Bump Versions before release/5.0 branchMichael Niedermayer2022-01-031-2/+2
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/pthread_frame: remove duplicate pointersYu Yang2022-01-031-7/+6
| | | | | | | '*src' and '*avctx' point to the same memory. It is enough to keep one of them. Signed-off-by: Yu Yang <yuyang14@kuaishou.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avcodec/speexdec: Consider mode in frame size checkMichael Niedermayer2022-01-011-1/+1
| | | | | | | | | | | | | | No speex samples with non default frame sizes are known (to me) the official speexenc seems to only generate the 3 default ones. Thus it may be that the fuzzer samples where the first non default values encountered by the decoder. Possibly the "<" should be "!=" Fixes: out of array access Fixes: 42821/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-5640695772217344 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/{av1, h264, h265}_metadata_bsf: fix description of tick_rateZhao Zhili2022-01-013-3/+3
| | | | | | | | Users may take the description literally which leads to inverted results. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> Reviewed-by: Jun Zhao <barryjzhao@tencent.com
* avcodec/apedec: fix integer overflow in 8bit samplesMichael Niedermayer2021-12-301-1/+1
| | | | | | | | Fixes: signed integer overflow: 2147483542 + 128 cannot be represented in type 'int' Fixes: 42812/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6344057861832704 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/targa: Check input size for uncompressed TGA before allocationMichael Niedermayer2021-12-301-1/+10
| | | | | | | | Fixes: Timeout Fixes: 42667/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TARGA_fuzzer-5619236075077632 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Remove messing with jpeg contextMichael Niedermayer2021-12-301-22/+2
| | | | | | | | | | | | | | | | The whole concept is just not correct, also as it seems not to be needed at all, all dng files i have decode without this. Fixes: various crashes Fixes: 42937/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4625073334517760 Fixes: 42938/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4643368217477120 Fixes: 42939/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4925325908246528 Fixes: 42940/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4925378806808576 Fixes: 42941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6202009265504256 Fixes: 42944/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6076860998483968 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/mediacodecdec: set codec profile and level from extradata for H264+HEVCsfan52021-12-301-0/+6
| | | | | | This value is later passed to MediaCodec and checked at decoder init. Notably decoding of 10-bit streams before this commit would "work" without returning errors but only return garbage output (on most Android devices).
* avcodec/v4l2_m2m_dec: dequeue frame if input isn't readyCameron Gutman2021-12-281-2/+6
| | | | | | | | | | | The V4L2M2M API operates asynchronously, so multiple packets can be enqueued before getting a batch of frames back. Since it was only possible to receive a frame by submitting another packet, there wasn't a way to drain those excess output frames from when avcodec_receive_frame() returned AVERROR(EAGAIN). Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Cameron Gutman <aicommander@gmail.com>
* avcodec/libx26[45]: reindent after last commitLimin Wang2021-12-282-46/+46
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/libx26[45]: add udu_sei option to import user data unregistered SEIsLimin Wang2021-12-283-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Most of user data unregistered SEIs are privated data which defined by user/ encoder. currently, the user data unregistered SEIs found in input are forwarded as side-data to encoders directly, it'll cause the reencoded output including some useless UDU SEIs. I prefer to add one option to enable/disable it and default is off after I saw the patch by Andreas Rheinhardt: https://patchwork.ffmpeg.org/project/ffmpeg/patch/AM7PR03MB66607C2DB65E1AD49D975CF18F7B9@AM7PR03MB6660.eurprd03.prod.outlook.com/ How to test by cli: ffmpeg -y -f lavfi -i testsrc -c:v libx264 -frames:v 1 a.ts ffmpeg -y -i a.ts -c:v libx264 -udu_sei 1 b.ts ffmpeg -y -i a.ts -c:v libx264 -udu_sei 0 c.ts # check the user data unregistered SEIs, you'll see two UDU SEIs for b.ts. # and mediainfo will show with wrong encoding setting info ffmpeg -i b.ts -vf showinfo -f null - ffmpeg -i c.ts -vf showinfo -f null - This fixes tickets #9500 and #9557. Reviewed-by: "zhilizhao(赵志立)" <quinkblack@foxmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/qsvenc_h264: use AV_OPT_TYPE_BOOL for aud, a53cc, cavlc, look_ahead, ↵Limin Wang2021-12-271-6/+6
| | | | | | | pic_timing_sei options Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec/qsvenc_hevc: use AV_OPT_TYPE_BOOL for aud optionLimin Wang2021-12-271-1/+1
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec/vaapi_encode_vp9: fix > 4k encode fail issueZhang yuankun2021-12-271-0/+8
| | | | | | | | | | | | This patch will fix following command: ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -i input.264 \ -vf 'scale_vaapi=w=7680:h=4096' -c:v vp9_vaapi output.ivf Max width of a vp9 tile is 4096. If the source frame > 4096, we need split to multiple tiles. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Zhang yuankun <yuankunx.zhang@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec/nvenc: add udu_sei option to import user data unregistered SEIsLimin Wang2021-12-255-1/+9
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
* avcodec/cdgraphics: avoid signed overflow in alphaMichael Niedermayer2021-12-251-1/+1
| | | | | | | | | Fixes: left shift of 255 by 24 places cannot be represented in type 'int' Fixes: 42766/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDGRAPHICS_fuzzer-5142826105569280 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/h2645: Fix SEI->display matrix transformationAndreas Rheinhardt2021-12-233-3/+31
| | | | | | | | | | | The earlier code did not account for the fact that av_display_rotation_set() wants the angle in the anticlockwise direction (despite what its documentation stated for a long time); furthermore, the H.2645 spec wants the flips applied first, whereas our code did it the other way around. This can be fixed by negating the angle once for every flip. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mjpegdec: Fix exif rotation->displaymatrix conversionAndreas Rheinhardt2021-12-231-2/+2
| | | | | | | The cases in which there was flipping together with a rotation that is not a multiple of the identity were wrong. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensionsMichael Niedermayer2021-12-231-7/+8
| | | | | | | | | | | sets coded_width / coded_height too to keep them consistent with width / height Fixes: OOM Fixes: 42263/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5653333619113984 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/tiff: Pass max_pixels to mjpeg contextMichael Niedermayer2021-12-231-0/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vqavideo: reset accounting on errorMichael Niedermayer2021-12-231-3/+4
| | | | | | | | Fixes: Timeout (same growing chunk is decoded to failure repeatedly) Fixes: 42582/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQA_fuzzer-6531195591065600 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: [loongarch] Optimize vc1dsp with LASX.Hao Chen2021-12-236-0/+1156
| | | | | | | | | ./ffmpeg -i 11_wmv3_720p_24fps_7Mbps.wmv -f rawvideo -y /dev/null -an before:131fps after :229fps Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: [loongarch] Optimize vp9_lpf/idct with LSX.Jin Bo2021-12-235-1/+4626
| | | | | | | | | ffmpeg -i ../10_vp9_1080p_30fps_3Mbps.webm -f rawvideo -y /dev/null -an before:294fps after :567fps Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: [loongarch] Optimize vp9_mc/intra with LSX.Hao Chen2021-12-237-0/+3379
| | | | | | | | | ffmpeg -i ../10_vp9_1080p_30fps_3Mbps.webm -f rawvideo -y /dev/null -an before:170fps after :294fps Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: [loongarch] Optimize vp8_lpf/mc with LSX.yuanhecai2021-12-237-0/+1701
| | | | | | | | | ./ffmpeg -i ../9_vp8_1080p_30fps_2Mbps.webm -f rawvideo -y /dev/null -an before: 210fps after : 585fps Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/qsvenc: enable lookahead for hevc encodingZhong Li2021-12-232-0/+13
| | | | | | | | | Update version based on the patch: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20211009015949.1510-1-haihao.xiang@intel.com/ Signed-off-by: Daniel Socek <daniel.socek@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com> Signed-off-by: Zhong Li <zhongli_dev@126.com>
* lavc/qsvenc: specify codec name when print profileZhong Li2021-12-231-19/+19
| | | | | | | | It is more clear and easily to detect the issues similar to commit 3857ecbe70e81cb6ad7a7f155c311e8522b93b3e Signed-off-by: Zhong Li <zhongli_dev@126.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/videotoolboxenc: explicitly set realtime=falsercombs2021-12-221-3/+3
| | | | | | On some encoders, this defaults to true, which can result in encode speed being _limited_ to only slightly above realtime (as a power-saving measure), so we need a way to disable it.
* libavcodec/videotoolboxenc: use the correct types for optionsrcombs2021-12-221-8/+8
| | | | | These are all set by AV_OPT_TYPE_INT or AV_OPT_TYPE_BOOL; the only reason they worked before was that this is only used on little-endian.
* lavc/videotoolbox: set attachments on decoded buffersrcombs2021-12-221-0/+4
| | | | | | VideoToolbox internally sets all the colorspace parameters to BT709, regardless of what the bitstream actually indicates, so we need to replace that with what we've parsed.
* lavc/proresdec: fix threaded hwaccel decodercombs2021-12-221-0/+14
|
* lavc/videotoolboxenc: add ProRes supportrcombs2021-12-224-7/+117
|
* lavc/Makefile: fix missing hevc_videotoolbox casercombs2021-12-221-0/+1
|
* lavc/videotoolboxenc: add handling for non-NAL-based codecsrcombs2021-12-221-57/+93
|
* lavc/videotoolboxenc: vastly simplify get_cv_pixel_inforcombs2021-12-221-56/+15
| | | | | | No longer requires per-format switch cases. The frame==0 path was unused (and would've crashed anyway).
* lavc/videotoolboxenc: config-gate ATSC CC supportrcombs2021-12-221-0/+2
|
* lavc/videotoolboxenc: fix RGB supportrcombs2021-12-221-0/+1
|
* lavc/videotoolboxenc: detect alpha more genericallyrcombs2021-12-221-5/+5
| | | | Fixes support for alpha in hardware input frames
* lavc/videotoolboxenc: don't access int64_t member as intrcombs2021-12-221-2/+2
|
* lavc/videotoolboxenc: use common routine for pixfmt conversionrcombs2021-12-221-18/+3
|
* avcodec/v210enc: suppport frame thread for v210Limin Wang2021-12-221-1/+1
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/rawenc: suppport frame thread for rawvideoLimin Wang2021-12-221-1/+1
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/libx264: Don't unnecessarily add in-band extradataAndreas Rheinhardt2021-12-211-1/+1
| | | | | | | | | | | | The check here is meant to check for whether avcintra-class option (default value -1) has been set; yet it checks for the x264_param_t value where 0 is the default value (treated as "no avcintra-mode" by x264). This meant that in-band extradata has been added unnecessarily when using global headers; furthermore, the first output packet had two x264 SEIs. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>