Commit Graph

110492 Commits

Author SHA1 Message Date
Leo Izen 453b524974
fate: add tests for RGB jpegs
Added framecrc tests for RGB JPEGs to verify future changes to the
decoder.
2023-04-21 09:55:12 -04:00
Leo Izen 869248c053
avcodec/mjpegdec: fix remaining RGB JPEGs
The change introduced in b18a9c2971
created a regression for non-subsampled progressive RGB jpegs. This
should fix that.

Additionally, this should fix other RGB JPEGs broken before the recent
patches, such as those in Trac issue #10190.
2023-04-21 09:55:08 -04:00
James Almer 0e1745774e fftools/ffprobe: fix printing AVFrame.crop_right
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-21 09:25:53 -03:00
Steven Liu 4570ba5d86 fate/png-icc-parse: update ref data
When enable lcms2, the fate-png-icc-parse will get error bellow.
TEST    png-icc-parse
This because updated how PNG handles colors (no
longer using mastering display metadata for that).

Reviewed-by: Leo Izen <leo.izen@gmail.com>
Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2023-04-21 14:06:37 +08:00
James Almer adeb5b6c67 avcodec/pdvdec: honor the requested avctx->skip_frame value
The decoder is tagged as being FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, so might as
well make use of it.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-20 13:04:34 -03:00
Paul B Mahol 0dceda12e7 avcodec/pdvdec: fix leaks on init failure and when seeking 2023-04-20 17:13:45 +02:00
Paul B Mahol dc2da568cf avformat: add PDV demuxer 2023-04-20 16:11:18 +02:00
Paul B Mahol 40bae5be5e avcodec: add PDV decoder 2023-04-20 15:44:38 +02:00
James Almer 0760528af2 avcodec/hevc_ps: use get_ue_golomb() for some PPS multilayer extension fields
Also remove the _plus* and _minus* parts of some of these to be in line with
other similar fields in the decoder.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-20 09:53:30 -03:00
James Almer ab0f3f7fbf avcodec/hevc_ps: fix storage type for some PPS multilayer extension fields
The spec states that the range of values for them is −2^14 to 2^14 − 1, inclusive.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-20 09:53:30 -03:00
James Almer 7fece7676b avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values
The spec says: "The value of num_ref_loc_offsets shall be in the range of 0 to
vps_max_layers_minus1, inclusive".

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-20 09:53:30 -03:00
Anton Khirnov c17e33c058 fftools/ffmpeg: propagate frame durations to packets when encoding
Remove now-obsolete code setting packet durations pre-muxing for CFR
encoded video.

Changes output in the following FATE tests:
* numerous adpcm tests
* ffmpeg-filter_complex_audio
* lavf-asf
* lavf-mkv
* lavf-mkv_attachment
* matroska-encoding-delay
  All of these change due to the fact that the output duration is now
  the actual input data duration and does not include padding added by
  the encoder.

* apng-osample: less wrong packet durations are now passed to the muxer.
  They are not entirely correct, because the first frame duration should
  be 3 rather than 2. This is caused by the vsync code and should be
  addressed later, but this change is a step in the right direction.
* tscc2-mov: last output frame has a duration of 11 rather than 1 - this
  corresponds to the duration actually returned by the demuxer.
* film-cvid: video frame durations are now 2 rather than 1 - this
  corresponds to durations actually returned by the demuxer and matches
  the timestamps.
* mpeg2-ticket6677: durations of some video frames are now 2 rather than
  1 - this matches the timestamps.
2023-04-19 21:12:03 +02:00
Anton Khirnov af286f17a1 fftools/ffmpeg_enc: set audio frame duration when encoding 2023-04-19 21:12:03 +02:00
Anton Khirnov 9a44e0335c fftools/sync_queue: update audio frame duration when re-chunking 2023-04-19 21:12:03 +02:00
Anton Khirnov b088d59347 lavc/mjpegdec: properly set pts and duration for smvjpeg
A single smvjpeg packet decodes into one large mjpeg frame, slices of
which are then returned as output frames. Packet duration covers all of
these slices.
2023-04-19 21:12:03 +02:00
Anton Khirnov 7ec4881f3e lavc/mjpegdec: simplify smvjpeg_receive_frame()
Unify the code for returning the first and every subsequent frame in a
packet.
2023-04-19 21:12:03 +02:00
Anton Khirnov 6118be25e1 lavc/encode: do not use pkt_duration for encoding
Current code prefers deprecated AVFrame.pkt_duration over its
replacement AVFrame.duration whenever the former is set and not equal to
the latter. However, duration will only be actually used when the
caller sets the AV_CODEC_FLAG_FRAME_DURATION flag, which was added
_after_ AVFrame.duration.

This implies that any caller aware of AV_CODEC_FLAG_FRAME_DURATION is
also aware of AVFrame.duration. pkt_duration should then never be used.
2023-04-19 21:12:03 +02:00
Anton Khirnov e392674399 lavfi: ensure audio frame durations match the sample count 2023-04-19 21:12:03 +02:00
Ronald S. Bultje 989ff02472 yuv4mpegenc: add bitdepth multiplier after rounding width.
Fixes output of HBD odd-width chroma.
2023-04-19 09:49:09 -04:00
James Almer 13450b6722 avcodec/mpegvideo_enc: ensure lmin is smaller than lmax
Fixes ticket #10234

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-18 22:14:06 -03:00
Michael Niedermayer 1440bf15e2
avcodec/pcm_rechunk_bsf: unref packet before putting a new one in
Fixes: memleak
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_BSF_PCM_RECHUNK_fuzzer-5562089618407424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-18 01:31:38 +02:00
Michael Niedermayer e2c3aa8e2b
avcodec/lcldec: More space for rgb24
Fixes: Ticket 10239
Fixes: zlib_306_306_rgb24.av

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-18 01:31:38 +02:00
Michael Niedermayer 4ea28554db
avcodec/lcldec: 420 seems missing 2 bytes, ignore that
Fixes: Ticket 10238
Fixes: mszh_306_306_yuv420.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-18 01:31:38 +02:00
Michael Niedermayer 0cf1ac905d
avcodec/lcldec: Support 4:1:1 and 4:2:2 with odd width
Fixes: Ticket10240
Fixes: zlib_306_306_yuv422.avi
Fixes: zlib_306_306_yuv411.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-18 01:31:37 +02:00
Michael Niedermayer 3eb4e28c26
libavcodec/lcldec: width and height should not be unsigned
Computations like col < width - 3 will not work with unsigned width=1

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-18 01:31:37 +02:00
Leo Izen c3625ccfcd
avcodec/mjpegdec: fix regression with baseline RGB JPEGs
Commit b18a9c2971 introduced a regression
that broke some baseline RGB jpegs. (See Trac issue #4045). This fixes
that.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2023-04-17 10:44:31 -04:00
Anton Khirnov 0b0fa5c2a8 fftools/ffmpeg_enc: make data_size_enc private to encoding code
It is no longer used outside of ffmpeg_enc.c
2023-04-17 12:01:40 +02:00
Anton Khirnov 30699c103f fftools/ffmpeg_mux: make copy_initial_nonkeyframes private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov 7f8827f28e fftools/ffmpeg_mux: make copy_prior_start private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov 8763b9cc36 fftools/ffmpeg_mux: make streamcopy_started private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov 83646146fe fftools/ffmpeg_mux: make ts_copy_start private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov 3f11582ca3 fftools/ffmpeg_mux: stop using filter_in_rescale_delta_last for streamcopy
That field was added to store timestamp conversion state for audio
decoding code. Later it started being used by streamcopy as well, but
that use is wrong because, for a given input stream, both decoding and
an arbitrary number of streamcopies may be performed simultaneously.
They would then all overwrite the same state variable.

Store this state in MuxStream instead.

This is the last use of InputStream in of_streamcopy(), so the ist
parameter can now be removed.
2023-04-17 12:01:40 +02:00
Anton Khirnov 150c992490 fftools/ffmpeg_mux: use output stream parameters in of_streamcopy()
They should always be the same as the input stream parameters, but this
reduces the need to access InputStream in muxing code.
2023-04-17 12:01:40 +02:00
Anton Khirnov 2178ff2162 fftools/ffmpeg: move do_streamcopy() to ffmpeg_mux
do_streamcopy() is muxing code, so this is a more appropriate place for
this. The last uses of InputStream in it will be removed in following
commits.
2023-04-17 12:01:40 +02:00
Anton Khirnov a34f483291 fftools/ffmpeg: add muxer-input codec parameters to OutputStream
It stores codec parameters of the stream submitted to the muxer, which
may be different from the codec parameters in AVStream due to bitstream
filtering.

This avoids the confusing back and forth synchronisation between the
encoder, bitstream filters, and the muxer, now information flows only in
one direction. It also reduces the need for non-muxing code to access
AVStream.
2023-04-17 12:01:40 +02:00
Anton Khirnov a064aed4c3 fftools/ffmpeg: store stream media type in OutputStream
Reduces access to a deeply nested muxer property
OutputStream.st->codecpar->codec_type for this fundamental and immutable
stream property.

Besides making the code shorter, this will allow making the AVStream
(OutputStream.st) private to the muxer in the future.
2023-04-17 12:01:40 +02:00
Anton Khirnov de38e17583 fftools/ffmpeg: initialize no-filter streams earlier
There is no reason to postpone it until transcode_init() anymore, it can
be done right at the end of of_open().
2023-04-17 12:01:40 +02:00
Anton Khirnov 2058402e00 fftools/ffmpeg: open decoders right after we know they are needed
Will allow initializing subtitle encoding earlier.
2023-04-17 12:01:40 +02:00
Anton Khirnov c8fa58430e fftools/ffmpeg_dec: drop useless abort_codec_experimental()
It does nothing beyond exit_program().
2023-04-17 12:01:40 +02:00
Anton Khirnov 503c705634 fftools/ffmpeg_dec: reindent after previous commit 2023-04-17 12:01:40 +02:00
Anton Khirnov 9ce1a041d8 fftools/ffmpeg: move opening decoders to a new file
All decoding code will be moved to this file in the future.
2023-04-17 12:01:40 +02:00
Anton Khirnov ff92ecad2f fftools/ffmpeg: stop setting InputStream fields from muxing/filtering code
Set InputStream.decoding_needed/discard/etc. only from
ist_{filter,output},add() functions. Reduces the knowledge of
InputStream internals in muxing/filtering code.
2023-04-17 12:01:40 +02:00
Anton Khirnov ae071c9e39 fftools/ffmpeg: add a function adding a destination filter for InputStream
This way filtering code does not directly mess with InputStream
internals. Will become more useful in following commits.
2023-04-17 12:01:40 +02:00
Anton Khirnov c7438e8737 fftools/ffmpeg_mux_init: consolidate input stream flagging code
Makes it easier to see where the input stream is modified from muxer
code.
2023-04-17 12:01:40 +02:00
Anton Khirnov 0c44db4646 fftools/ffmpeg: drop unnecessary indirection
init_input_stream() can print log messages directly, there is no need to
ship them to the caller.

Also, log errors to the InputStream and avoid duplicate information in
the message.
2023-04-17 12:01:40 +02:00
Anton Khirnov 4358d4d8e7 fftools/ffmpeg: move a check to a more appropriate place
reap_filters() no longer needs to access the encoding context.
2023-04-17 12:01:40 +02:00
Anton Khirnov 4fc513b5e3 fftools/ffmpeg: move a misplaced assignment
Changing AVCodecContext.sample_aspect_ratio after the encoder was opened
is by itself questionable, but if anywhere it belongs in encoding rather
than filtering code.
2023-04-17 12:01:36 +02:00
Anton Khirnov a0452ee837 fftools/ffmpeg_mux_init: remove a redundant check 2023-04-17 12:00:06 +02:00
Anton Khirnov 12f3f41bbf fftools/ffmpeg: move init_output_stream_streamcopy() to ffmpeg_mux_init
Everything in it can be done immediately when creating the output
stream, there is no reason to postpone it.
2023-04-17 12:00:06 +02:00
Anton Khirnov 9bae55165d fftools/ffmpeg_mux_init: restructure output stream creation
Creating a new output stream of a given type is currently done by
calling new_<type>_stream(), which all start by calling
new_output_stream() to allocate the stream and do common init, followed
by type-specific init.

Reverse this structure - the caller now calls the common function
ost_add() with the type as a parameter, which then calls the
type-specific function internally. This will allow adding common code
that runs after type-specific code in future commits.
2023-04-17 12:00:06 +02:00