summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* fftools/ffmpeg_filter: remove YUVJ hackavcodec_yuv_rangeNiklas Haas2024-04-09
| | | | | | | This is no longer needed, since we now correctly negotiate the required range from the mjpeg encoder via avcodec_get_supported_config(). Signed-off-by: Anton Khirnov <anton@khirnov.net>
* fftools/ffmpeg_filter: propagate codec yuv metadata to filtersNiklas Haas2024-04-09
| | | | | | | To convert between color spaces/ranges, if needed by the codec properties. Signed-off-by: Anton Khirnov <anton@khirnov.net>
* fftools/ffmpeg_filter: switch to avcodec_get_supported_config()Niklas Haas2024-04-09
| | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* fftools/ffmpeg_mux_init: factor out binding filters to output streamsAnton Khirnov2024-04-09
|
* fftools/ffmpeg_filter: simplify choose_pix_fmtsNiklas Haas2024-04-09
| | | | | | | | | | | | | | | | | | | | | | | | The only meaningful difference between choose_pix_fmts and the default code was the inclusion of an extra branch for `keep_pix_fmt` being true. However, in this case, we either: 1. Force the specific `ofp->format` that we inherited from ofilter_bind_ost, or if no format was set: 2. Print an empty format list Both of these goals can be accomplished by simply moving the decision logic to ofilter_bind_ost, to avoid setting any format list when keep_pix_fmt is enabled. This is arguably cleaner as it moves format selection logic to a single function. In the case of branch 1, nothing else needs to be done as we already force the format provided in ofp->format, if any is set. Add an assertion to verify this assumption just in case. (Side note: The "choose_*" family of functions are arguably misnomers, as they should really be called "print_*" - their current behavior is to print the relevant format lists to the `vf/af_format` filter arguments) Signed-off-by: Anton Khirnov <anton@khirnov.net>
* fftools/ffmpeg_mux_init: switch to avcodec_get_supported_config()Niklas Haas2024-04-09
|
* fftools: drop unused/hacky macrosNiklas Haas2024-04-09
| | | | | | Having macros initialize local variables seems strange to me, and there are no more current users of these macros. (The one that was commented out was incorrect anyway, since the macro has changed in the meantime)
* fftools/opt_common: switch to avcodec_get_supported_config()Niklas Haas2024-04-09
| | | | | | | | While rewriting this macro, I decided to make it a bit more flexible so it can work for all of the fields (including future fields) in a more generic way, and to also print the channel layout using an AVBPrint to avoid hard-coding the assumption that the length is less than 128 characters.
* avcodec/codec_internal: nuke init_static_data()Niklas Haas2024-04-09
| | | | All hail get_supported_config()
* avcodec/mjpegenc: switch to get_supported_config()Niklas Haas2024-04-09
| | | | | | This codec's capabilities should be set dynamically based on the value of strict_std_compliance, when available. This will allow us to finally get rid of the strictness hack in ffmpeg_filter.c.
* avcodec/libaomenc: switch to get_supported_config()Niklas Haas2024-04-09
|
* avcodec/libvpxenc: switch to get_supported_config()Niklas Haas2024-04-09
|
* avcodec/libx265: switch to get_supported_config()Niklas Haas2024-04-09
|
* avcodec/allcodecs: add backcompat for new config APINiklas Haas2024-04-09
| | | | | | | | | In order to avoid breaking older clients not yet using the new API, we need to add backwards compatibility for codecs which have switched from init_static() to get_supported_config(). This function can be removed entirely once the deprecated static fields are removed.
* avcodec/encode: switch to avcodec_get_supported_config()Niklas Haas2024-04-09
|
* avcodec: add avcodec_get_supported_config()Niklas Haas2024-04-09
| | | | | | | | | | | | | | | | | | | | | | | | This replaces the myriad of existing lists in AVCodec by a unified API call, allowing us to (ultimately) trim down the sizeof(AVCodec) quite substantially, while also making this more trivially extensible. In addition to the already covered lists, add two new entries for color space and color range, mirroring the newly added negotiable fields in libavfilter. I decided to drop the explicit length field from the API proposed by Andreas Rheinhardt, because having it in place ended up complicating both the codec side and the client side implementations, while also being strictly less flexible (it's trivial to recover a length given a terminator, but requires allocation to add a terminator given a length). Using a terminator also presents less of a porting challenge for existing users of the current API. Once the deprecation period passes for the existing public fields, the rough plan is to move the commonly used fields (such as pix_fmt/sample_fmt) into FFCodec, possibly as a union of audio and video configuration types, and then implement the rarely used fields with custom callbacks.
* avcodec/internal: add FFCodec.color_rangesNiklas Haas2024-04-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I went through all codecs and put them into five basic categories: 1. JPEG range only 2. MPEG range only 3. Explicitly tagged 4. Broken (codec supports both but encoder ignores tags) 5. N/A (headerless or pseudo-formats) Filters in category 5 remain untouched. The rest gain an explicit assignment of their supported color ranges, with codecs in category 4 being set to MPEG-only for safety. It might be considered redundant to distinguish between 0 (category 5) and MPEG+JPEG (category 3), but in doing so we effectively communicate that we can guarantee that these tags will be encoded, which is distinct from the situation where there are some codecs that simply don't have tagging or implied semantics (e.g. rawvideo). A full list of codecs follows: JPEG range only: - amv - roqvideo MPEG range only: - asv1, asv2 - avui - cfhd - cljr - dnxhd - dvvideo - ffv1 - flv - h261, h263, h263p - {h263,vp8}_v4l2m2m - huffyuv, ffvhuff - jpeg2000 - libopenjpeg - libtheora - libwebp, libwebp_anim - libx262 - libxavs, libxavs2 - libxvid - mpeg1video, mpeg2video - mpeg2_qsv - mpeg2_vaapi - mpeg4, msmpeg4, msmpeg4v2, wmv1, wmv2 - mpeg4_omx - rv10, rv20 - snow - speedhq - svq1 - tiff - utvideo Explicitly tagged (MPEG/JPEG): - {av1,h264,hevc}_nvenc - {av1,h264,hevc}_vaapi - {av1,h264,hevc,vp8,vp9,mpeg4}_mediacodec - {av1,h264,hevc,vp9}_qsv - h264_amf - {h264,hevc,prores}_videotoolbox - libaom-av1 - libkvazaar - libopenh264 - librav1e - libsvtav1 - libvpx, libvpx-vp9 - libx264 - libx265 - ljpeg - mjpeg - vc2 Broken (encoder ignores tags): - {av1,hevc}_amf - {h264,hevc,mpeg4}_v4l2m2m - h264_omx - libxeve - magicyuv - {vp8,vp9,mjpeg}_vaapi N/A: - ayuv, yuv4, y41p, v308, v210, v410, v408 (headerless) - pgmyuv (headerless) - prores, prores_aw, prores_ks (?) - rawvideo, bitpacked (headerless) - vnull, wrapped_avframe (pseudocodecs)
* fftools/ffmpeg_mux_init: make encoder_opts local to ost_add()ffmpeg_encoder_optsAnton Khirnov2024-04-09
| | | | It is no longer needed after this function returns.
* fftools/ffmpeg_mux_init: apply encoder options manuallyAnton Khirnov2024-04-09
| | | | | | | | | | | | | | | Do not pass an options dictionary to the avcodec_open2() in enc_open(). This is cleaner and more robust, as previously various bits of code would try to interpret the contents of the options dictionary, with varying degrees of correctness. Now they can just access the encoder AVCodecContext directly. Cf. 372c78dd42f2b1ca743473b9c32fad71c65919e0 - analogous change for decoding. A non-progressive field order is now written on the container level in interlaced ProRes encoding tests.
* fftools/ffmpeg: rewrite checking whether codec AVOptions have been usedAnton Khirnov2024-04-09
| | | | | | Share the code between encoding and decoding. Instead of checking every stream's options dictionary (which is also used for other purposes), track all used options in a dedicated dictionary.
* lavc/qsvenc: rename the skip_frame private option to qsv_skip_frameAnton Khirnov2024-04-09
| | | | It conflicts with the AVCodecContext option of the same name.
* doc/ffmpeg: document that there can be multiple complex filtergraphsAnton Khirnov2024-04-09
|
* fftools/ffmpeg_filter: implement filtergraph chainingAnton Khirnov2024-04-09
| | | | | | | | | | This allows one complex filtergraph's output to be sent as input to another one, which is useful in certain situations (one is described in the docs). Chaining filtergraphs was already effectively possible by using a wrapped_avframe encoder connected to a loopback decoder, but it is ugly, non-obvious and inefficient.
* fftools/ffmpeg_sched: allow filtergraphs to send to filtergraphsAnton Khirnov2024-04-09
| | | | | Will be useful for filtergraph chaining that will be added in following commits.
* fftools/ffmpeg_filter: change processing order in fg_finalise_bindings()Anton Khirnov2024-04-09
| | | | | | | First bind all inputs in all filtergraphs, only then check that all outputs are bound. Needed by the following commit.
* fftools/ffmpeg_filter: only store complex filtergraphs in global arrayAnton Khirnov2024-04-09
| | | | | Store simple filtergraphs in the stream they feed. Keeping the two separate will be useful in following commits.
* fftools/ffmpeg_filter: drop OutputFilter.ostAnton Khirnov2024-04-09
| | | | | All remaining code accessing it only needs to know whether this filtergraph output has been bound or not.
* fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | | Stop digging through encoder options manually. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_mux: drop OutputFile.formatAnton Khirnov2024-04-09
| | | | | It is no longer used outside of the muxing code (where we can access the muxer directly).
* fftools/ffmpeg_mux: drop OutputFile.shortestAnton Khirnov2024-04-09
| | | | It is no longer needed outside of of_open() and its children.
* fftools/ffmpeg_filter: move most of -apad logic to the muxerAnton Khirnov2024-04-09
| | | | | | The decision whether -apad actually does anything is made based on muxer properties, and so more properly belongs there. Filtering code only receives the result.
* fftools/ffmpeg_filter: pass trim parameters through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | | Do not read them from OutputStream directly. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: pass autoscale through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | | Do not read it from OutputStream directly. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: pass sws/swr opts through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | | Do not read them from OutputStream directly. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: drop an unnecessary use of OutputStreamAnton Khirnov2024-04-09
| | | | OutputFilter.type contains the same information.
* fftools/ffmpeg_filter: add an AVClass to OutputFilterAnton Khirnov2024-04-09
| | | | | | | Use it for logging where appropriate, avoid logging to OutputStream as we do not own it. This is a step towards decoupling filtering from encoding.
* fftools/ffmpeg_filter: simplify retrieving filter typeAnton Khirnov2024-04-09
|
* fftools/ffmpeg_filter: drop a redundant checkAnton Khirnov2024-04-09
| | | | | fg_finalise_bindings() already checks that all filtergraph outputs are connected.
* fftools/ffmpeg_filter: accept a caller-provided output nameAnton Khirnov2024-04-09
| | | | | | Do not construct it from OutputStream manually. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg: drop OutputStream.is_cfrAnton Khirnov2024-04-09
| | | | | It is used in a single place in the filtering code, so it is better to inline it there.
* fftools/ffmpeg_filter: pass vsync method through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | | Do not read it from OutputStream directly. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: stop accessing encoder AVCodecContextAnton Khirnov2024-04-09
| | | | | | Pass all the necessary value through OutputFilterOptions. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: move the MJPEG format selection hack to muxer setupAnton Khirnov2024-04-09
| | | | That, if anywhere, is a more appropriate place for it.
* fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | Reduces the need to access OutputStream, which will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg: warn about ignored -enc_time_base for subtitles earlierAnton Khirnov2024-04-09
| | | | | Can do it as soon as that option is parsed, no need to postpone it until opening the encoder.
* fftools/ffmpeg_filter: pass keep_pix_fmt through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | Reduces the need to access OutputStream, which will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: pass ts offset through OutputFilterOptionsAnton Khirnov2024-04-09
| | | | | Reduces the need to access OutputFile, which will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: check that filter type matches output stream typeAnton Khirnov2024-04-09
| | | | For simple filtergraphs. For complex filtergraphs they always match.
* fftools/ffmpeg_filter: stop accessing AVCodecContext.codecAnton Khirnov2024-04-09
| | | | | | | Instead pass the encoder through a newly-added output options struct, analogous to previously added input options. Will allow decoupling filtering from encoding in future commits.
* fftools/ffmpeg_filter: do not pass OutputStream to set_channel_layout()Anton Khirnov2024-04-09
| | | | It only needs a list of allowed layouts and the requested layout.