Commit Graph

110421 Commits

Author SHA1 Message Date
xufuji456 bd2f00f665 codec/aarch64/hevc: add transform_luma_neon
got 56% speed up (run_count=1000, CPU=Cortex A53)
transform_4x4_luma_neon: 45 transform_4x4_luma_c: 103

Signed-off-by: xufuji456 <839789740@qq.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-04-14 12:07:57 +03:00
Niklas Haas 4eaaa38d3d avutil: make av_frame_get_plane_buffer accept a const AVFrame*
Signed-off-by: Niklas Haas <git@haasn.dev>
2023-04-14 10:53:28 +02:00
Anton Khirnov cea71b2139 fftools/ffmpeg: stop using fake dts for generating timestamps
When no packet dts values are available from the container, video
decoding code will currently use its own guessed values, which will then
be propagated to pkt_dts on decoded frames and used as pts in certain
cases. This is inaccurate, fragile, and unnecessarily convoluted.
Simply removing this allows the extrapolation code introduced in the
previous commit to do a better job.

Changes the results of numerous h264 and hevc FATE tests, where no
spurious timestamp gaps are generated anymore. Several tests no longer
need -vsync passthrough.
2023-04-13 15:34:07 +02:00
Anton Khirnov 5d407cb2d7 fftools/ffmpeg: change video decoding timestamp generation
When no timestamps are available from the container, the video decoding
code will currently use fake dts values - generated in
process_input_packet() based on a combination of information from the
decoder and the parser (obtained via the demuxer) - to generate
timestamps during decoder flushing. This is fragile, hard to follow, and
unnecessarily convoluted, since more reliable information can be
obtained directly from post-decoding values.

The new code keeps track of the last decoded frame pts and estimates its
duration based on a number of heuristics. Timestamps generated when both
pts and pkt_dts are missing are then simple pts+duration of the last frame.
The heuristics are somewhat complicated by the fact that lavf insists on
making up packet timestamps based on its highly incomplete information.
That should be removed in the future, allowing to further simplify this
code.

The results of the following tests change:
* h264-3386 now requires -fps_mode passthrough to avoid dropping frames
  at the end; this is a pathology of the interaction of the new and old
  code, and the fact that the sample switches from field to frame coding
  in the last packet, and will be fixed in following commits
* hevc-conformance-DELTAQP_A_BRCM_4 stops inventing an arbitrary
  timestamp gap at the end
* hevc-small422chroma - the single frame output by this test now has a
  timestamp of 0, rather than an arbitrary 7
2023-04-13 15:34:07 +02:00
Anton Khirnov 380db56928 fftools/ffmpeg: use InputStream.pts as last resort for decoded frame pts 2023-04-13 15:34:07 +02:00
Anton Khirnov 95fa4edbd6 fftools/ffmpeg: improve decoder -ts_debug line
* log to the input stream log context
* drop the now-duplicate index/type information
* show pkt_dts and frame duration
2023-04-13 15:34:07 +02:00
Anton Khirnov be3b1e27e5 lavf/rawdec: mark raw demuxers as having no timestamps
Changes the result of the h264_redundant_pps-mov test, where the output
timebase is now 1001/24000 instead of 1/24. This is more correct, as the
source file actually is 23.98fps.
2023-04-13 15:34:07 +02:00
Anton Khirnov 7b827a0293 lavf/demux: treat streams with AVSTREAM_PARSE_FULL_RAW as having timestamps
In this case the timestamps are set by the parser.
Cf. a6b3471c44

Required by the following commit.
2023-04-13 15:34:07 +02:00
Anton Khirnov ba4b73c977 lavf/rawdec: set avg_frame_rate
Timestamps in two FATE H.264 conformance tests now start at 1 instead
of 0, which also happens in some other H.264 tests before this commit
and so is not a big issue.
Conversely, timestamps in some HEVC conformance tests start from a
smaller value now.
Ideally this should be addressed later in a more general way.

h264-conformance-frext-frext2_panasonic_b no longer requires -vsync
passthrough.
2023-04-13 15:34:07 +02:00
Anton Khirnov d56652fdc8 fftools/ffmpeg: stop using InputStream.pts for streamcopy
This field contains different values depending on whether the stream is
being decoded or not. When it is, InputStream.pts is set to the
timestamp of the last decoded frame. Otherwise, it is made equal to
InputStream.dts.

Since a given InputStream can be at the same time decoded and
streamcopied to any number of output streams, this use is incorrect, as
decoded frame timestamps can be delayed with respect to input packets by
an arbitrary amount (e.g. depending on the thread count when frame
threading is used).

Replace all uses of InputStream.pts for streamcopy with InputStream.dts,
which is its value when decoding is not performed. Stop setting
InputStream.pts for pure streamcopy.
Also, pass InputStream.dts as a parameter to do_streamcopy(), which
will allow that function to be decoupled from InputStream completely in
the future.
2023-04-13 15:32:56 +02:00
Anton Khirnov 106eb58ceb fftools/ffmpeg: move checking for input -t out of do_streamcopy()
This check is entirely about the properties of the input stream, while
do_streamcopy() should contain code specific to a given output stream.
2023-04-13 15:11:56 +02:00
Anton Khirnov 0feff04956 fftools/ffmpeg: only set InputStream.next_pts for decoding
It is write-only for streamcopy.
2023-04-13 15:11:56 +02:00
Anton Khirnov d867f9ab8c fftools/ffmpeg: use AVPacket.time_base to simplify do_streamcopy()
Besides making the code shorter, this also reduces the use of
InputStream in this function and will allow not accessing it at all in
the future.
2023-04-13 15:11:56 +02:00
Anton Khirnov d1cb31d7d8 fftools/ffmpeg_demux: set the timebase on demuxed packets
Simplifies tracking what timebase are the timestamps in. Will be useful
in following commits.
2023-04-13 15:11:56 +02:00
Anton Khirnov fdf29dcebb fftools/ffmpeg: inline check_output_constraints() into its only caller
Which is subtitle encoding. Also, check for AVSubtitle.pts rather than
InputStream.pts, since that is the more authoritative value and is
guaranteed to be valid.
2023-04-13 15:11:56 +02:00
Anton Khirnov ceb0275e45 fftools/ffmpeg: stop calling check_output_constraints() for streamcopy
That function only contains two checks now - whether the muxer returned
EOF and whether the packet timestamp is before requested output start
time.

The first check is unnecessary, since the packet will just be rejected
by the muxer. The second check is better combined with a related check
directly in do_streamcopy().
2023-04-13 15:11:56 +02:00
Anton Khirnov a85e7e5dea fftools/ffmpeg: track a list of non-lavfi outputs in InputStream
Currently, output streams where an input stream is sent directly (i.e.
not through lavfi) are determined by iterating over ALL the output
streams and skipping the irrelevant ones. This is awkward and
inefficient.
2023-04-13 15:11:56 +02:00
Anton Khirnov 798da60e6a fftools/ffmpeg_mux_init: print more meaningful error messages 2023-04-13 15:11:56 +02:00
Anton Khirnov 5297250920 fftools/ffmpeg_filter: stop setting encoder channel layout unnecessarily
The channel layout is set before opening the encoder, in enc_open().
Messing with it in configure_output_audio_filter() cannot accomplish
anything meaningful.
2023-04-13 15:11:56 +02:00
Anton Khirnov 2f24290c8e fftools/ffmpeg: disable and deprecate -qphist
This option adds a long string of numbers to the progress line, where
i-th number contains the base-2 logarithm of the number of times a frame
with this QP value was seen by print_report().

There are multiple problems with this feature:
* despite this existing since 2005, web search shows no indication
  that it was ever useful for any meaningful purpose;
* the format of what is printed is entirely undocumented, one has to
  find it out from the source code;
* QP values above 31 are silently ignored;
* it only works with one video stream;
* as it relies on global state, it is in conflict with ongoing
  architectural changes.

It then seems that the nontrivial cost of maintaining this option is not
worth its negligible (or possibly negative - since it pollutes the
already large option space) value.
Users who really need similar functionality can also implement it
themselves using -vstats.
2023-04-13 15:11:56 +02:00
Anton Khirnov 952110f974 fftools/ffmpeg_demux: log final stats to demuxer context 2023-04-13 15:11:56 +02:00
Anton Khirnov 28e258a809 fftools/ffmpeg_demux: reindent 2023-04-13 15:11:56 +02:00
Anton Khirnov 5d97ba5d9c fftools/ffmpeg: move printing verbose demuxing stats to ffmpeg_demux
This is a more appropriate place for this.
2023-04-13 15:11:56 +02:00
Anton Khirnov 0288951174 fftools/ffmpeg_mux: make data_size_mux private to ffmpeg_mux
It is no longer used outside of this file.
2023-04-13 15:11:56 +02:00
Anton Khirnov 37b118096a fftools/ffmpeg: rewrite printing the final output sizes
Current code in print_final_stats(), printing the final summary such as
  video:8851kB audio:548kB subtitle:0kB other streams:0kB global headers:20kB muxing overhead: 0.559521%
was written with a single output file in mind and makes very little
sense otherwise.

Print this information in mux_final_stats() instead, one line per output
file. Use the correct filesize, if available.
2023-04-13 15:11:56 +02:00
Anton Khirnov 6b2e222a45 fftools/ffmpeg_mux: log final stats to muxer context 2023-04-13 15:11:56 +02:00
Anton Khirnov c1764d067d fftools/ffmpeg_mux: reindent 2023-04-13 15:11:56 +02:00
Anton Khirnov 3b6b0d1afb fftools/ffmpeg: move printing verbose muxing stats to ffmpeg_mux
This is a more appropriate place for this.
2023-04-13 15:11:56 +02:00
Anton Khirnov 79e136f14b fftools/ffmpeg: factorize checking whether any output was written
This is currently done in two places:
* at the end of print_final_stats(), which merely prints a warning if
  the total size of all written packets is zero
* at the end of transcode() (under a misleading historical 'close each
  encoder' comment), which instead checks the packet count to implement
  -abort_on empty_output[_stream]

Consolidate both of these blocks into a single function called from
of_write_trailer(), which is a more appropriate place for this. Also,
return an error code rather than exit immediately, which ensures all
output files are properly closed.
2023-04-13 15:11:56 +02:00
Anton Khirnov 5cf81bed88 fftools/ffmpeg: eliminate the main_return_code global
Properly pass muxing return codes through the call stack instead.
Slightly changes behavior in case of errors:
* the output IO stream is closed even if writing the trailer returns an
  error, which should be more correct
* all files get properly closed with -xerror, even if one of them fails
2023-04-13 15:11:56 +02:00
Anton Khirnov d99846d2f2 fftools/ffmpeg: move the hw_device_free_all() call to ffmpeg_cleanup()
Frees devices on failure as well as success.
2023-04-13 15:11:56 +02:00
Anton Khirnov f2c8dff906 fftools/ffmpeg: drop a useless goto
There is no cleanup in transcode(), can return an error directly.
2023-04-13 15:11:56 +02:00
Anton Khirnov 5d4f467cc9 fftools/ffmpeg_enc: replace abort() with av_assert0(0)
This is consistent with the treatment of other unreachable paths.
2023-04-13 15:11:56 +02:00
Anton Khirnov fd91ac11ed fftools/ffmpeg: move OutputStream.last_filter_pts to OutputFilter
This value is associated with the filtergraph output rather than the
output stream, so this is a more appropriate place for it.
2023-04-13 15:11:56 +02:00
Anton Khirnov 83da6d3f54 fftools/ffmpeg: move OutputStream.last_nb0_frames to Encoder
It is video encoding-only and does not need to be visible outside of
ffmpeg_enc.c

Also, rename the variable to frames_prev_hist to be consistent with
the naming in do_video_out().
2023-04-13 15:11:56 +02:00
Anton Khirnov 87ae84e4af fftools/ffmpeg: move OutputStream.sq_frame to Encoder
It is audio/video encoding-only and does not need to be visible outside
of ffmpeg_enc.c
2023-04-13 15:11:56 +02:00
Anton Khirnov 710da200fc fftools/ffmpeg: move OutputStream.next_pts to Encoder
It is audio/video encoding-only and does not need to be visible outside
of ffmpeg_enc.c
2023-04-13 15:11:56 +02:00
Anton Khirnov 45202556cb fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder
It is video encoding-only and does not need to be visible outside of
ffmpeg_enc.c
2023-04-13 15:11:56 +02:00
xufuji456 1e91a39502 checkasm: pass context as pointer
Signed-off-by: xufuji456 <839789740@qq.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-04-13 15:17:04 +03:00
xufuji456 30def6365d checkasm/hevc: add transform_luma test
Signed-off-by: xufuji456 <839789740@qq.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-04-13 15:17:04 +03:00
Leo Izen 1179bb703e
avcodec/libjxlenc: use reciprocol gamma for GAMMA22 and GAMMA28
libjxl rejects JxlColorEncoding->gamma 2.2f or 2.8f and expects
1/2.2f or 1/2.8f, respectively.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2023-04-12 10:13:58 -04:00
xufuji456 00a062b8d5 codec/aarch64/hevc:add idct_32x32_neon
got 73% speed up (run_count=1000, CPU=Cortex A53)
idct_32x32_neon: 4826 idct_32x32_c: 18236
idct_32x32_neon: 4824 idct_32x32_c: 18149
idct_32x32_neon: 4937 idct_32x32_c: 18333

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-04-12 15:58:09 +03:00
Zhao Zhili 4dffa564d1 configure: remove duplicated extralibs of android_camera
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-11 19:57:09 +08:00
Zhao Zhili ef09db1eac configure: add mediacodec_extralibs to avutil
Fix #10299

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-11 19:57:00 +08:00
Zhao Zhili ab177c7469 configure: cleanup mediacodec dependency
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-11 19:56:50 +08:00
James Almer 1a7df525f6 avformat/matroskaenc: fix memory leak in fail codepath
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-10 22:12:13 -03:00
James Almer c558fcf41e avformat/matroskadec: also export non-HDR10+ ITU-T T.35 payloads as BlockAdditional side data
Partially reverts a change from 88de01d878, and
2133cadfcf.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-10 18:52:08 -03:00
Leo Izen b18a9c2971
avcodec/mjpegdec: support weird RGB subsampling with progressive
This allows weird subsampling with progressive JPEGs to be decoded,
such as full-RG and only B subsampled.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2023-04-10 04:55:41 -04:00
Anton Khirnov f098eaee56 fftools/ffmpeg_enc: factorize calling enc_init()
It is done in the same way for both audio and video, so can be moved to
enc_frame().
2023-04-09 15:47:45 +02:00
Anton Khirnov 2225134e7d fftools/ffmpeg: clean up #includes
Drop unneeded ctype.h and math.h.
Group all system headers together.
Sort unconditional includes alphabetically.
Group local includes by the library, sort alphabetically.
2023-04-09 15:47:45 +02:00