Commit Graph

110984 Commits

Author SHA1 Message Date
Paul B Mahol 29710dd7f2 avfilter/af_silenceremove: speed-up start-only trimming once trim is over 2023-05-26 10:13:37 +02:00
Paul B Mahol f59d9514da avfilter/silenceremove_template: skip silence start detection after start-only trimming is over 2023-05-26 10:13:37 +02:00
Paul B Mahol 2b5166addf avfilter/af_silenceremove: add real peak detector
Rename old peak detector to more correct name one.
2023-05-26 10:13:37 +02:00
Paul B Mahol 3235de4883 avfilter/af_silenceremove: switch to activate
Do full rewrite, new code is much faster for typical filter usages.
Also previous code was hard to follow and basically very-hard to maintain.
2023-05-26 10:13:37 +02:00
yuanhecai 82278e8749
avutil/la: Add function performance testing
This patch supports the use of the "checkasm --bench" testing feature
on loongarch platform.

Change-Id: I42790388d057c9ade0dfa38a19d9c1fd44ca0bc3
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:05:21 +02:00
Jin Bo cb4ae8baee
swscale/la: Add following builtin optimized functions
yuv420_rgb24_lsx
yuv420_bgr24_lsx
yuv420_rgba32_lsx
yuv420_argb32_lsx
yuv420_bgra32_lsx
yuv420_abgr32_lsx
./configure --disable-lasx
ffmpeg -i ~/media/1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo
-pix_fmt rgb24 -y /dev/null -an
before: 184fps
after:  207fps

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:05:15 +02:00
Lu Wang 4501b1dfd7
swscale/la: Optimize the functions of the swscale series with lsx.
./configure --disable-lasx
ffmpeg -i ~/media/1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -s 640x480
-pix_fmt bgra -y /dev/null -an
before: 91fps
after:  160fps

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:05:08 +02:00
yuanhecai f6077cc666
avcodec/la: Add LSX optimization for h264 qpel.
./configure --disable-lasx
ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before: 214fps
after:  274fps

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:05:01 +02:00
Lu Wang 8815a7719e
avcodec/la: Add LSX optimization for h264 chroma and intrapred.
./configure --disable-lasx
ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before: 199fps
after:  214fps

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:04:56 +02:00
Hao Chen 7845b5ecd6
avcodec/la: Add LSX optimization for loop filter.
Replaced function(LSX is sufficient for these functions):
ff_h264_v_lpf_chroma_8_lasx
ff_h264_h_lpf_chroma_8_lasx
ff_h264_v_lpf_chroma_intra_8_lasx
ff_h264_h_lpf_chroma_intra_8_lasx
ff_weight_h264_pixels4_8_lasx
ff_biweight_h264_pixels4_8_lasx

./configure --disable-lasx
ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before: 161fps
after:  199fps

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:04:43 +02:00
Shiyou Yin e1b6ecd20a
avcodec/la: add LSX optimization for h264 idct.
loongson_asm.S is LoongArch asm optimization helper.
Add functions:
  ff_h264_idct_add_8_lsx
  ff_h264_idct8_add_8_lsx
  ff_h264_idct_dc_add_8_lsx
  ff_h264_idct8_dc_add_8_lsx
  ff_h264_idct_add16_8_lsx
  ff_h264_idct8_add4_8_lsx
  ff_h264_idct_add8_8_lsx
  ff_h264_idct_add8_422_8_lsx
  ff_h264_idct_add16_intra_8_lsx
  ff_h264_luma_dc_dequant_idct_8_lsx
Replaced function(LSX is sufficient for these functions):
  ff_h264_idct_add_lasx
  ff_h264_idct4x4_addblk_dc_lasx
  ff_h264_idct_add16_lasx
  ff_h264_idct8_add4_lasx
  ff_h264_idct_add8_lasx
  ff_h264_idct_add8_422_lasx
  ff_h264_idct_add16_intra_lasx
  ff_h264_deq_idct_luma_dc_lasx
Renamed functions:
  ff_h264_idct8_addblk_lasx ==> ff_h264_idct8_add_8_lasx
  ff_h264_idct8_dc_addblk_lasx ==> ff_h264_idct8_dc_add_8_lasx

./configure --disable-lasx
ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before: 155fps
after:  161fps

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:04:25 +02:00
Paul B Mahol 90fba27743 avfilter/trim: switch to activate
This also signals EOF to filter inlink so that unnecessary
extra processing that is immediately dropped by this filter
is not done any more.
2023-05-25 19:52:04 +02:00
Paul B Mahol c6b6356635 avformat/gifdec: switch to using gif parser
Update fate test, more correct as last packet is not truncated.
2023-05-25 19:51:56 +02:00
Paul B Mahol e7cadd0ee5 avformat/demux: add support to derive timestamps from packet durations for video 2023-05-25 19:51:47 +02:00
Paul B Mahol a1838c59bb avfilter/af_astats: add abs_peak_count stat 2023-05-25 19:51:39 +02:00
James Almer 97f4263457 avcodec/av1dec: convert to receive_frame()
This removes the overhead of inserting the av1_frame_split bsf as part of the
decoding process.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-25 11:21:35 -03:00
Gyan Doshi 944243477b doc/filters: clarify requirements for subtitles wrap_unicode option 2023-05-25 12:40:08 +05:30
Zhao Zhili 43ace8f2bc avfilter/vf_subtitles: add wrap_unicode option
So CJK can be wrapped automatically.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-05-25 11:31:54 +08:00
Haihao Xiang 8e2547ebb2 lavc/qsvenc: the height is aligned to 32 for AV1
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-05-25 09:04:13 +08:00
Haihao Xiang 943a42fc54 lavc/qsvenc: make sure continuous allocation
Intel MediaSDK and oneVPL expect continuous allocation for data[i],
however there are mandatory padding bytes between data[i] and data[i+1].
when calling av_frame_get_buffer. This patch removes all extra padding
bytes.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-05-25 09:04:13 +08:00
Haihao Xiang cf79dab8df lavc/qsvenc: avoid data copy if possible
The data copy is unnecessary for packed formats when frame width and
height are aligned

For example:
$ ffmpeg -f lavfi -i testsrc=size=1920x1088 -vf "format=yuyv422" -c:v hevc_qsv -f null -

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-05-25 09:04:13 +08:00
Haihao Xiang cfdfd6aa72 lavc/qsvenc: use the right alignment instead of hard coded value
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-05-25 09:04:13 +08:00
Haihao Xiang 2b0fe52967 lavc/qsv: fallback to the default mfx implementation for internal session on Windows
The mfx implementation based on D3D11 is expected for an internal
session on Windows, however sometimes this implemntation is not
supported [1]. A fallback to the default mfx implementation is added in
this patch.

[1] https://github.com/intel/cartwheel-ffmpeg/issues/246

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-05-25 09:04:13 +08:00
Niklas Haas 0bce5590c3 lavfi/vf_libplacebo: fix crop expr PTS calculation
mix->timestamps is expressed relative to the source timebase, which is
possibly a different timescale from `base_pts`. We can't mix-and-match
here. The only reason this worked in my previous testing was because I
was testing on a source file which had an exactly matching timebase.

Fix it by always using the exact PTS as tagged on the AVFrame.
2023-05-24 14:39:40 +02:00
Niklas Haas d815584755 lavif/vf_libplacebo: move code (cosmetic)
To eliminate need for forward declaration
2023-05-23 15:06:18 +02:00
Niklas Haas ee13414444 lavfi/vf_libplacebo: update settings after adding hooks
Failure to do so led to the update s->hooks never getting correctly
propagated to the render params.
2023-05-23 15:05:21 +02:00
Anton Khirnov 4e521e6102 fate/tests/ffmpeg: use -idct simple for fate-ffmpeg-input-r
Makes the test bitexact on non-x86_64.
2023-05-23 13:54:10 +02:00
James Almer f209614290 avcodec/libdav1d: only return EAGAIN when there are no buffered packets
Fixes decoding packets containing split temporal units, as generated for example
by the av1_frame_split bsf.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-22 16:19:10 -03:00
Paul B Mahol 557686ac63 avdevice/opengl_enc: check sscanf return value 2023-05-22 20:08:55 +02:00
Marvin Scholz 86b252ea9d avfilter/vf_tpad: accept hardware frames in clone-only mode
When no drawing is to be performed, tpad can work fine with
hardware frames, so advertise this in the query_formats
callback and ensure the drawing context is never initialised
when just cloning frames.

Reviewed-by: Thilo Borgmann <thilo.borgmann@mail.de>
Reviewed-by: Niklas Haas <git@haasn.dev>
2023-05-22 18:41:22 +02:00
Marvin Scholz fa7180b827 avfilter/vf_tpad: use enum for start/stop_mode
Reviewed-by: Thilo Borgmann <thilo.borgmann@mail.de>
Reviewed-by: Niklas Haas <git@haasn.dev>
2023-05-22 18:40:42 +02:00
Anton Khirnov c894f85f72 fftools/ffmpeg_dec: rename decode_video() to video_frame_process()
This function does not do any decoding anymore.
2023-05-22 17:10:44 +02:00
Anton Khirnov 909f5dfae1 fftools/ffmpeg_dec: inline decode_audio() into dec_packet()
The former function is now trivial - it has 3 lines and cannot fail.
2023-05-22 17:10:44 +02:00
Anton Khirnov 959a5decf2 fftools/ffmpeg_dec: deduplicate code in decode_audio/video() 2023-05-22 17:10:44 +02:00
Anton Khirnov ab3493006f fftools/ffmpeg_dec: merge check_decode_result() into its callers
Not only is this easier to read, this also makes the code shorter.
2023-05-22 17:10:44 +02:00
Anton Khirnov c08717adae fftools/ffmpeg: reindent after previous commit 2023-05-22 17:10:44 +02:00
Anton Khirnov 748f2999ee fftools/ffmpeg_dec: restructure audio/video decoding loop
It currently emulates the long-removed
avcodec_decode_audio4/avcodec_decode_video2 APIs, which obfuscates the
actual decoding flow. Restructure the decoding calls so that they
naturally follow the new avcodec_send_packet()/avcodec_receive_frame()
design.

This is not only significantly easier to read, but also shorter.
2023-05-22 17:10:44 +02:00
Anton Khirnov 172f901e35 fftools/ffmpeg_dec: deobfuscate subtitle decoding
It is currently handled in the same loop as audio and video, but this
obscures the actual flow, because only one iteration is ever performed
for subtitles.

Also, avoid a pointless packet reference.
2023-05-22 17:10:44 +02:00
Anton Khirnov dbf1c6f5f1 fftools/ffmpeg: move decoding code to ffmpeg_dec 2023-05-22 17:10:44 +02:00
Anton Khirnov 79c1dde5c3 fftools/ffmpeg: split decoding loop out of process_input_packet()
process_input_packet() contains two non-interacting pieces of nontrivial
size and complexity - decoding and streamcopy. Separating them makes the
code easier to read.
2023-05-22 17:10:44 +02:00
Anton Khirnov b5beff3f15 fftools/ffmpeg: move a block to a more appropriate place
New placement requires fewer explicit conditions and is easier to
understand.
The logic should be exactly equivalent, since this is the only place
where eof_reached is set for decoding.
2023-05-22 17:10:44 +02:00
Anton Khirnov 4cec5ffc45 fftools/ffmpeg: rework handling -max_error_rate
Replace the decode_error_stat global with a per-input-stream variable.
Also, print an error message when the error rate is exceeded.
2023-05-22 17:10:44 +02:00
Anton Khirnov d064c9ded5 fftools/ffmpeg: deobfuscate check_decode_result() call
Passing ist=NULL is currently used to identify stream types that do not
decode into AVFrames, i.e. subtitles. That is highly non-obvious -
always pass a non-NULL InputStream and just check the type explicitly.
2023-05-22 17:10:44 +02:00
Anton Khirnov 4fbc699ac3 fftools/ffmpeg: replace an unreachable return with av_assert0(0)
This cannot be reached, because initialization will fail if decoding is
requested for a stream but no decoder can be found.
2023-05-22 17:10:44 +02:00
Anton Khirnov 4a59dde0c7 fftools/ffmpeg: eliminate InputStream.got_output
It tracks whether the decoder for this stream ever produced any frames
and its only use is for checking whether a filter input ever received a
frame - those that did not are prioritized by the scheduler.

This is awkward and unnecessarily complicated - checking whether the
filtergraph input format is valid works just as well and does not
require maintaining an extra variable.
2023-05-22 17:10:44 +02:00
Anton Khirnov 5fa00b38e6 fftools/ffmpeg: drop an obsolete hack
This special handling for decoder flushing has not been needed since
af1761f7b5, as the filtergraph actually is drained after that commit.
2023-05-22 17:10:44 +02:00
Anton Khirnov 37fcbe121d fftools/cmdutils: constify the argument of get_rotation() 2023-05-22 17:10:44 +02:00
Anton Khirnov 9effea016c fftools/ffmpeg_filter: embed displaymatrix into private context
It has a small fixed size, so it is better to embed it rather than deal
with dynamic allocation.
2023-05-22 17:10:44 +02:00
Anton Khirnov dcfbfb417c fftools/ffmpeg_filter: keep track of the real filter input type
Avoid extracting it from various remote sources.
2023-05-22 17:10:44 +02:00
Anton Khirnov f980df2c04 fftools/ffmpeg_filter: move InputFilter.type to private data
It is not accessed outside of ffmpeg_filter.
2023-05-22 17:10:44 +02:00