1
0
Fork 0
Commit Graph

1703 Commits

Author SHA1 Message Date
Devin Heitmueller 859c34706d avdevice/decklink_common: Convert to using avpriv_packet_list functions
The existing DecklinkQueue implementation was using the PacketList
structure but wasn't using the standard avpriv_packet_list_get and
avpriv_packet_list_put functions.  Convert to using them so we
eliminate the duplicate logic, per Marton Balint's suggestion.

Updated to reflect feedback from Marton Balint provided on 05/11/23.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-05-31 00:21:00 +02:00
Paul B Mahol 557686ac63 avdevice/opengl_enc: check sscanf return value 2023-05-22 20:08:55 +02:00
James Almer 7f890b2fbb avfilter/ccfifo: remove unnecessary context allocations
This is not public API, no it has no need for an alloc() and free()
functions. The struct can reside on stack.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-12 16:21:18 -03:00
Devin Heitmueller 4fd729a1f8 avdevice/decklink: move AVPacketQueue into decklink_common and rename it to DecklinkPacketQueue
Move the AVPacketQueue functionality that is currently only used
for the decklink decode module into decklink_common, so it can
be shared by the decklink encoder (i.e. for VANC insertion when
we receive data packets separate from video).

The threadsafe queue used within the decklink module was named
"AVPacketQueue" which implies that it is part of the public API,
which it is not.

Rename the functions and the name of the queue struct to make
clear it is used exclusively by decklink, per Marton Balint's
suggestion.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-05-11 22:46:15 +02:00
Devin Heitmueller 9f4df9a535 avdevice/decklink_enc: add support for playout of 608 captions in MOV files
Unlike other cases where the closed captions are embedded in the
video stream as MPEG-2 userdata or H.264 SEI data, with MOV files
the captions are often found on a separate "e608" subtitle track.

Add support for playout of such files, leveraging the new ccfifo
mechanism to ensure that they are embedded into VANC at the correct
rate (since e608 packets often contain batches of multiple 608 pairs).

Note this patch includes a new file named libavdevice/ccfifo.c, which
allows the ccfifo functionality in libavfilter to be reused even if
doing shared builds.  This is the same approach used for log2_tab.c.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2023-05-11 22:06:20 +08:00
Paul B Mahol 5ce76506de avdevice/lavfi: check that pointer is set
Fixes NULL pointer dereference later.
2023-05-10 12:55:22 +02:00
Marton Balint 2f8690c5d4 avdevice/decklink_enc: fix operator precedence in create_s337_payload
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-04-24 23:00:50 +02:00
Devin Heitmueller 12d1f7c4b7 avdevice/decklink_enc: Add support for compressed AC-3 output over SDI
Extend the decklink output to include support for compressed AC-3,
encapsulated using the SMPTE ST 377:2015 standard.

This functionality can be exercised by using the "copy" codec when
the input audio stream is AC-3.  For example:

./ffmpeg -i ~/foo.ts -codec:a copy -f decklink 'UltraStudio Mini Monitor'

Note that the default behavior continues to be to do PCM output,
which means without specifying the copy codec a stream containing
AC-3 will be decoded and downmixed to stereo audio before output.

Thanks to Marton Balint for providing feedback.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-04-08 20:08:18 +02:00
Devin Heitmueller 33ef8778e0 avdevice/decklink_enc: Add support for output of Active Format Description (AFD)
Implement support for including AFD in decklink output when putting
out 10-bit VANC data.

Updated to reflect feedback in 2018 from Marton Balint <cus@passwd.hu>,
Carl Eugen Hoyos <ceffmpeg@gmail.com> and Aaron Levinson
<alevinsn_dev@levland.net>.  Also includes fixes to set the AR field
based on the SAR, as well as now sending the AFD info in both fields
for interlaced formats.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-04-06 00:40:42 +02:00
Anton Khirnov 27f8c9b27b lavu/frame: deprecate AVFrame.pkt_{pos,size}
These fields are supposed to store information about the packet the
frame was decoded from, specifically the byte offset it was stored at
and its size.

However,
- the fields are highly ad-hoc - there is no strong reason why
  specifically those (and not any other) packet properties should have a
  dedicated field in AVFrame; unlike e.g. the timestamps, there is no
  fundamental link between coded packet offset/size and decoded frames
- they only make sense for frames produced by decoding demuxed packets,
  and even then it is not always the case that the encoded data was
  stored in the file as a contiguous sequence of bytes (in order for pos
  to be well-defined)
- pkt_pos was added without much explanation, apparently to allow
  passthrough of this information through lavfi in order to handle byte
  seeking in ffplay. That is now implemented using arbitrary user data
  passthrough in AVFrame.opaque_ref.
- several filters use pkt_pos as a variable available to user-supplied
  expressions, but there seems to be no established motivation for using them.
- pkt_size was added for use in ffprobe, but that too is now handled
  without using this field. Additonally, the values of this field
  produced by libavcodec are flawed, as described in the previous
  ffprobe conversion commit.

In summary - these fields are ill-defined and insufficiently motivated,
so deprecate them.
2023-03-20 10:42:09 +01:00
Devin Heitmueller aca7ef78cc avdevice/decklink_enc: fix unused variable compiler warnings
Due to refactoring, the ctx/cctx variables are never actually used
in ff_decklink_write_packet(), so just remove them.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-08 23:53:26 +01:00
Devin Heitmueller 25d09ac0eb avdevice/decklink_enc: fix setting of last_pts to only be set for video
The ff_decklink_write_packet() was always caching the last pts
received, to be used when calling StopScheduledPlayback(). However
because audio and video are on different timebases and the call to
StopScheduledPlayback() expects the video timebase, we'll end up
sending a weird value to the stop routine if the last packet
received contained audio.

Move the setting of last_pts to just be for the video stream.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-08 23:53:19 +01:00
Devin Heitmueller 8fd345f018 avdevice/decklink_enc: don't take for granted that first frame to decklink output will be PTS 0
The existing code assumed that the first frame received by the decklink
output would always be PTS zero.  However if running in other timing
modes than the default of CBR, items such as frame dropping at the
beginning may result in starting at a non-zero PTS.

For example, in our setup because we discard probing data and run
with "-vsync 2" the first video frame scheduled to the decklink
output will have a PTS around 170.  Scheduling frames too far into
the future will either fail or cause a backlog of frames scheduled
far enough into the future that the entire pipeline will stall.

Issue can be reproduced with the following command-line:

./ffmpeg -copyts -i foo.ts -f decklink -vcodec v210 -ac 2  'DeckLink Duo (4)'

Keep track of the PTS of the first frame received, so that when
we enable start playback we can provide that value to the decklink
driver.

Thanks to Marton Balint for review and suggestion to use
AV_NOPTS_VALUE rather than zero for the initial value.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-08 23:53:15 +01:00
Michael Niedermayer 47ac3e6065
version.h: Bump minor post 6.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 18:37:36 +01:00
Michael Niedermayer 62efa096af
version.h: Bump minor for 6.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 18:32:07 +01:00
James Almer 5bad485603 Bump major versions of all libraries
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer 4fcd6c82cf avdevice: remove FF_API_DEVICE_CAPABILITIES
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
Andreas Rheinhardt 59c9dc82f4 avformat/avformat: Move AVOutputFormat internals out of public header
This commit does for AVOutputFormat what commit
20f9727018 did for AVCodec:
It adds a new type FFOutputFormat, moves all the internals
of AVOutputFormat to it and adds a now reduced AVOutputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for muxers (it is still a mess due to lavd).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
James Almer 0d0d67ce36 avdevice/avfoundation: convert to new channel layout-API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-08 14:08:05 -03:00
James Almer df968fc1ff avdevice/audiotoolbox: convert to new channel layout-API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-08 14:08:05 -03:00
Marvin Scholz 7cf22df14e avdevice/avdevice: Fix mismatching argument name 2022-10-17 09:51:47 +02:00
Andreas Rheinhardt 2b41463b87 avformat/internal: Don't include avcodec.h
The general demuxing API uses parsers and decoders. Therefore
FFStream contains pointers to AVCodecContexts and
AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h.

Yet actually only a few files files really use these; and it is best
when this number stays small. Therefore this commit uses opaque
structs in lavf/internal.h for these contexts and stops including
avcodec.h.
This also avoids including lavc/codec_desc.h implicitly. All other
headers are implicitly included as now (mostly through codec.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-26 03:02:50 +02:00
Andreas Rheinhardt 72c601e0f7 avutil/internal: Move avpriv-file API to a header of its own
It is not used by the large majority of files that include
lavu/internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:44 +02:00
Timo Rothenpieler b77fff47d0 configure: always enable gnu_windres if available
Use the appropiate Makefile variable to ensure the resource file is
only built into shared libraries instead.
2022-08-13 14:42:36 +02:00
Zhao Zhili 30aa0c3f48 avdevice/v4l2: fix leak of timefilter
Fixes ticket #9844.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-08-03 17:52:25 +08:00
Anton Khirnov 2d90fc89f2 lavd: use AVFrame.duration instead of AVFrame.pkt_duration 2022-07-19 12:27:17 +02:00
Timo Rothenpieler 2f0d45571b avdevice/lavfi: pass forward video framerate 2022-07-18 00:32:57 +02:00
Timo Rothenpieler 6ca43a9675 avdevice/lavfi: output wrapped AVFrames
This avoids an extra copy of potentially quite big video frames.
Instead of copying the entire frames data into a rawvideo packet it
packs the frame into a wrapped avframe packet and passes it through
as-is.
Unfortunately, wrapped avframes are set up to be video frames, so the
audio frames continue to be copied.

Additionally, this enabled passing through video frames that previously
were impossible to process, like hardware frames or other special
formats that couldn't be packed into a rawvideo packet.
2022-07-18 00:32:55 +02:00
Marton Balint 64f04df379 avdevice/avdevice: fix return value of avdevice_list_devices()
According to API docs avdevice_list_devices(), avdevice_list_input_sources()
and avdevice_list_input_sinks() should return the number of autodetected
devices on success. This is redundant with AVDeviceInfoList->nb_devices so it
was not noticed earlier that none of the underlying device list functions work
like that.

Let's fix it in generic code to make it in line with the API docs.

Fixes ticket #9820.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-17 22:03:41 +02:00
Michael Niedermayer fd26b07e8b Bump versions after 5.1 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-13 00:29:05 +02:00
Michael Niedermayer 6f1b144358 Bump Versions for 5.1 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-13 00:27:37 +02:00
Andreas Rheinhardt d5a0eba8a2 av(format|device): Add const to muxer packet data pointers
The packets given to muxers need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Matt Jacobson b3e261bab3 avdevice/oss_dec: account for sample size when computing timestamp
Don't assume each sample is one byte in size. Doing so results in wrong and
occasionally non-monotonically-increasing timestamps.

Fix nearby cosmetic typo.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-19 23:01:20 +02:00
Marton Balint 1b3ec3c8ca avdevice/pulse_audio_dec: deprecate frame_size option
It does not do anything. Frame sizes can be controlled by using fragment_size.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-16 21:28:20 +02:00
Marton Balint b67ca8a7a5 avdevice/pulse_audio_dec: reduce default fragment size
Reduces default fragment size from the pulse audio default of 2 sec to 50 ms.
This also has an effect on the size of the returned frames, which will be
around 50 ms as well, making timestamps more accurate.

This should fix the regression in ticket #9776.

Pulseaudio timestamps for monitor sources are still pretty inaccurate for me,
but I don't see how else should we query latencies from the library.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-16 21:28:20 +02:00
Marton Balint b83032899a Revert "avdevice/pulse_audio_dec: only set adjust latency flag if fragment_size is not set"
This reverts commit 7f059a250b.

Apparently adjusting latency makes a difference even if fragment size is specifed.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-16 21:28:20 +02:00
Diederick Niehorster d2d8b9b972 avdevice/dshow: reuse unused variables.
Fix for f125c504d8, requested_sample_rate
and such should be used.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-05-12 22:06:44 -03:00
Andreas Rheinhardt 8550a05ece avdevice/v4l2*: Improve included headers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:38:01 +02:00
Andreas Rheinhardt 284313c664 avformat/utils: Move parser functions to a new file, demux_utils.c
This file is both for the various public APIs that are demuxer-only
as well as for the demuxer-only internal functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:37:50 +02:00
Andreas Rheinhardt 35ec5c819b avformat/demux: Add new demux.h header
And move those stuff already in demuxer-only files to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:37:38 +02:00
Andreas Rheinhardt f4a2d722aa avformat/internal: Move muxing-only functions to new mux.h header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:27:01 +02:00
Andreas Rheinhardt f2b79c5b85 lib*/version: Move library version functions into files of their own
This avoids having to rebuild big files every time FFMPEG_VERSION
changes (which it does with every commit).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 06:49:32 +02:00
Romain Beauxis 2a44db59ca avdevice/dshow: Fix dshow device name/description
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-04-09 21:29:39 +02:00
Diederick Niehorster f125c504d8 avdevice/dshow: fix regression
a1c4929f accidentally undid part of d9a9b4c8, so the bug in ticket #9420
resurfaced. Fixing again.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-29 23:25:33 +02:00
Martin Storsjö 2d368392a5 Keep including the full version.h when headers are included externally
This avoids unnecessary churn and build breakage for users, by
making sure the whole version.h is included like it has been so far,
while keeping the benefit of not needing to rebuild most files in
the ffmpeg tree on minor/micro bumps.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-19 00:01:57 +02:00
Martin Storsjö a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
This avoids unnecessary rebuilds of most source files if only the
list of enabled components has changed, but not the other properties
of the build, set in config.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:49 +02:00
Martin Storsjö f3a0e2ee2b doc: Add an entry to APIchanges about changes to version.h and version_major.h
Also bump the minor versions of all libraries, to signify the
API change of splitting the version.h headers and adding the
new version_major.h header.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:46 +02:00
Martin Storsjö 884c597659 libavdevice: Split version.h
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:05:26 +02:00
Martin Storsjö 4eb9232c6e libavformat: Split version.h
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:05:26 +02:00
James Almer 53d60aafaf avdevice/lavfi: remove call to deprecated function av_buffersink_get_channel_layout()
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:46 -03:00
James Almer 6f1a9effef sndio: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:37 -03:00
James Almer c218144748 pulseaudio: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:36 -03:00
Anton Khirnov 6964b59245 oss: port to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:35 -03:00
James Almer 16970e1acb openal: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:35 -03:00
Anton Khirnov e271d534e3 libcdio: port to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:34 -03:00
James Almer 678c1952a9 avdevice/lavfi: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:34 -03:00
Anton Khirnov 368f50404d jack: port to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:33 -03:00
James Almer daf329fc38 dshow: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:31 -03:00
James Almer d03b327787 decklink: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:31 -03:00
James Almer ffc4fd3cc2 alsa: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:30 -03:00
Martin Storsjö 17ab836a5f libavcodec, libavdevice: Remove unnecessary includes of version.h
xvmc.h used FF_API_* macros before, but they were removed in
1c63aed232, leaving the include
unused.

The ones in android_camera.c and mediacodec_wrapper.c have been
added due to a misunderstanding, fixed in
c0bce367e4 and
13b77af2f0.

The one in mediacodec.c seems to never have been used at all.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-02-24 22:36:15 +02:00
Andreas Rheinhardt 636631d9db Remove unnecessary libavutil/(avutil|common|internal).h inclusions
Some of these were made possible by moving several common macros to
libavutil/macros.h.

While just at it, also improve the other headers a bit.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-24 12:56:49 +01:00
Thilo Borgmann a473e11e32 lavd/avfoundation: Fix mixed declaration and code 2022-02-22 13:10:42 +01:00
Zhao Zhili 079de49912 avdevice/avfoundation: check strdup 2022-02-22 13:06:59 +01:00
Zhao Zhili 6b708592fa avdevice/avfoundation: fix memleak 2022-02-22 13:02:02 +01:00
Andreas Rheinhardt 760b4709ab avdevice/decklink_(common_c|dec|enc).h: Fix checkheaders
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-21 13:09:48 +01:00
Anton Khirnov d46fd9640f lavd/jack: switch to the new FIFO API 2022-02-07 00:31:23 +01:00
Andreas Rheinhardt ad0b4afec5 avdevice/iec61883: #if unused code away, fix -O0 compilation
iec61883_parse_queue_hdv() is only called when the mpegts-demuxer
is available and can be optimized away when not. Yet this
optimization is not a given and it fails with e.g. GCC 11 when
using -O0 in which case one will get a compilation error
because the call to the unavailable avpriv_mpegts_parse_packet()
is not optimized away. Therefore #if the offending code away
in this case.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-08 18:15:18 +01:00
Andreas Rheinhardt b189550137 lib*/version.h: Bump Versions after release/5.0 branch
This is done a second time for 5.0 because master was
merged into 5.0 so that it contains the recent DOVI additions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 14:29:06 +01:00
Andreas Rheinhardt c512be9a90 lib*/version.h: Bump Versions before release/5.0 branch
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:40:03 +01:00
Andreas Rheinhardt d61240f8c9 avcodec/packet_internal: Add proper PacketList struct
Up until now, we had a PacketList structure which is actually
a PacketListEntry; a proper PacketList did not exist
and all the related functions just passed pointers to pointers
to the head and tail elements around. All these pointers were
actually consecutive elements of their containing structs,
i.e. the users already treated them as if they were a struct.

So add a proper PacketList struct and rename the current PacketList
to PacketListEntry; also make the functions use this structure
instead of the pair of pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:50 +01:00
Andreas Rheinhardt d82c91ba2f configure, avcodec/Makefile: Add new mpeg4audio CONFIG_EXTRA group
This group is mainly for the users of *_mpeg4audio_get_config2();
it is not for those who only use avpriv_mpeg4audio_sample_rates.
This is in preparation for splitting the latter into a file of its own;
if there were no CONFIG_EXTRA group for *_mpeg4audio_get_config2()
users, one would have to add a dependency to the new file for all
these users on top of the existing dependency on mpeg4audio.o.

Adding a new CONFIG_EXTRA group only takes effect after a reconfigure;
so in order to force a reconfigure some unnecessary headers from
libavdevice/alldevices.c have been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:50 +01:00
Andreas Rheinhardt 3d53cefb49 avcodec/raw: Reduce number of avpriv symbols
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>
2022-01-04 13:16:49 +01:00
Diederick Niehorster e84d8ba441 avdevice/dshow: ensure pin's default format is set
Fixes regression in a1c4929f: there apparently are devices out there
that expose a pin default format that has parameters outside the
capabilities of any of the formats exposed on the pin (sic?). The
VirtualCam plugin (v 2.0.5) of OBS-Studio (v 27.1.3) is such a device.
Now when a default format was found, but not selected when iterating all
formats, fall back to directly setting the default format.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2022-01-04 17:41:05 +05:30
Diederick Niehorster 25518f2aa6 avdevice/dshow: only set pin format if wanted
Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2022-01-04 17:41:00 +05:30
Diederick Niehorster 76e164f332 avdevice/dshow: fix crash on x86
fix regression introduced in 911ba8417e.
Removal of WINAPI decoration from function signatures caused crashed
when using dshow on x86.

Fixes #9568

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2022-01-04 17:40:54 +05:30
Diederick Niehorster 307d2b867f avdevice/dshow: proper cleanup of queried media types
Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2022-01-04 17:40:47 +05:30
Diederick Niehorster d1f7700133 avdevice/dshow: tv_tuner_audio_dialog cleanup missing
Cleanup was missing for when the show_analog_tv_tuner_audio_dialog is
true.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2022-01-04 17:40:29 +05:30
Andreas Rheinhardt 20b0d24c2f Makefile: Redo duplicating object files in shared builds
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>
2022-01-04 05:01:04 +01:00
Michael Niedermayer 4be85c9331 lib*/version.h: Bump Versions after release/5.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-03 22:10:46 +01:00
Michael Niedermayer f3964a59e1 lib*/version.h: Bump Versions before release/5.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-03 22:08:31 +01:00
James Almer 2497a45562 avdevice/dshow: don't mix declarations and code
Signed-off-by: James Almer <jamrial@gmail.com>
2021-12-24 14:24:07 -03:00
James Almer c147f7962c avdevice/dshow: remove unused variables
Signed-off-by: James Almer <jamrial@gmail.com>
2021-12-24 14:23:01 -03:00
Diederick Niehorster a1c4929f65 avdevice/dshow: select format with extended color info
Some DirectShow devices (Logitech C920 webcam) expose each DirectShow
format they support twice, once without and once with extended color
information. During format selection, both match, this patch ensures
that the format with extended color information is selected if it is
available, else it falls back to a matching format without such
information. This also necessitated a new code path taken for default
formats of a device (when user didn't request any specific video size,
etc), because the default format may be one without extended color
information when a twin with extended color information is also
available. Getting the extended color information when available is
important as it allows setting the color space, range, primaries,
transfer characteristics and chroma location of the stream provided by
dshow, enabling users to get more correct color automatically out of
their device.

Closes: #9271

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:07:07 +05:30
Diederick Niehorster dde92fb7d9 avdevice/dshow: discover source color range/space/etc
Enabled discovering a DirectShow device's color range, space, primaries,
transfer characteristics and chroma location, if the device exposes that
information. Sets them in the stream's codecpars.

Co-authored-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:07:02 +05:30
Diederick Niehorster e4b9aee11c avdevice/dshow: add media type info to get_device_list
The list returned by get_device_list now contains info about what media
type(s), if any, can be provided by each device.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:51 +05:30
Diederick Niehorster a8a530331f avdevice: add info about media types(s) to AVDeviceInfo
An avdevice, regardless of whether its category says its an audio or
video device, may provide access to devices providing different media
types, or even single devices providing multiple media types. Also, some
devices may provide no media types. dshow is an example encompassing all
of these cases. Users should be provided with this information, so
AVDeviceInfo is extended to provide it.

Bump avdevice version

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:45 +05:30
Diederick Niehorster 54fdbfc366 avdevice/dshow: list_devices: show media type(s) per device
the list_devices option of dshow didn't indicate whether a specific
device provides audio or video output. This patch iterates through all
media formats of all pins exposed by the device to see what types it
provides for capture, and prints this to the console for each device.
Importantly, this now allows to find devices that provide both audio and
video, and devices that provide neither.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:40 +05:30
Diederick Niehorster ec579b4e36 avdevice/dshow: implement get_device_list
Needed to enable programmatic discovery of DirectShow devices

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:33 +05:30
Diederick Niehorster 937de260eb avdevice/dshow: set no-seek flags
avdevice/dshow is a realtime device and as such does not support
seeking. Therefore, its demuxer format should define the
AVFMT_NOBINSEARCH, AVFMT_NOGENSEARCH and AVFMT_NO_BYTE_SEEK flags.
With these flags set, attempting to seek (with, e.g.,
avformat_seek_file()) correctly yields -1 (operation not permitted)
instead of -22 (invalid argument).

This actually seems to apply to many other devices, at least the
gdigrab, v4l2, vfwcap, x11grab, fbdev, kmsgrab and android_camera
devices, from reading the source.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:27 +05:30
Diederick Niehorster 271e55987f avdevice/dshow: handle unknown sample time
GetTime may return an error indication that the sample has not
timestamps, or may return a NULL start time. In those cases, fall back
to graph time. Emit log when that happens.
Improve logging in the frame receive function: now logged against
correct avclass instead of NULL.
Better debug message in case sample dropped: could now be audio or
video frame.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:21 +05:30
Diederick Niehorster 584b0fbe4b avdevice/dshow: query graph and sample time only once
No need to query twice, use value we've already unconditionally got.
Improve variable names

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:14 +05:30
Diederick Niehorster 7dc33aad45 avdevice/dshow: implement option to use device video timestamps
The dshow avdevice ignores timestamps for video frames provided by the
DirectShow device, instead using wallclock time, apparently because the
implementer of this code had a device that provided unreliable
timestamps. Me (and others) would like to use the device's timestamps.
The new use_video_device_timestamps option for dshow device enables them
to do so. Since the majority of video devices out there probably provide
fine timestamps, this patch sets the default to using the device
timestamps, which means best fidelity timestamps are used by default.
Using the new option, the user can switch this off and revert to the old
behavior, so a fall back remains available in case the device provides
broken timestamps.

add use_video_device_timestamps to docs.

Closes: #8620

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:06:06 +05:30
Diederick Niehorster 7b21841ce4 avdevice/dshow: prevent NULL access
list_options true would crash when both a video and an audio device were
specified as input. Crash would occur on line 784 because
ctx->device_unique_name[otherDevType] would be NULL

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
2021-12-24 14:04:14 +05:30
Anton Khirnov 877b6a9e82 lavd/v4l2: detect device name truncation
Silences the following warning with gcc 10:
src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
src/libavdevice/v4l2.c:1042:64: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 251 [-Wformat-truncation=]
 1042 |         ret = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
      |                                                                ^~
src/libavdevice/v4l2.c:1042:15: note: ‘snprintf’ output between 6 and 261 bytes into a destination of size 256
 1042 |         ret = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previous patches intending to silence it have proposed increasing the
buffer size, but doing that correctly seems to be tricky. Failing on
truncation is simpler and just as effective (as excessively long device
names are unlikely).
2021-12-07 11:16:14 +01:00
Anton Khirnov b532ca3d2f lavd/v4l2: reduce variable scope
device and cap are local to the loop iteration, there is no need for
them to retain their values. Especially for device it may be dangerous,
since it points to av_malloc'ed data.
2021-12-07 11:16:14 +01:00
Anton Khirnov e1151fbf22 lavd/v4l2: do not clobber the context FD in v4l2_get_device_list()
The FD opened here is local to the loop iteration, there is no reason to
store it in the context. Since read_header() may have already been
called, this may ovewrite an existing valid FD.
2021-12-07 11:16:14 +01:00
Anton Khirnov 007819a5bc lavd/jack: increase buffer size for snprintf()
Maximum output size with a 32-bit int is 17 bytes, or 26 with a 64-bit
int.

Silences the following gcc 10 warning:
src/libavdevice/jack.c: In function ‘audio_read_header’:
src/libavdevice/jack.c:171:45: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
      |                                             ^
src/libavdevice/jack.c:171:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 16
  171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-12-07 11:16:14 +01:00
Andreas Rheinhardt 61bbd0cf3c avdevice/lavfi: Don't require AV_PIX_FMT_NONE == -1
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 17:01:24 +01:00
Andreas Rheinhardt b7e3ae19b8 avdevice/lavfi: Simplify setting sample_fmts
The length of this list is a compile-time constant, so there is
no need to calculate it again at runtime.
(This also avoids an implicit requirement of -1 == AV_SAMPLE_FMT_NONE.)

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 17:01:06 +01:00