summaryrefslogtreecommitdiff
path: root/libavdevice
Commit message (Collapse)AuthorAge
* avdevice/iec61883: #if unused code away, fix -O0 compilationAndreas Rheinhardt2022-01-08
| | | | | | | | | | | | 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>
* lib*/version.h: Bump Versions after release/5.0 branchAndreas Rheinhardt2022-01-04
| | | | | | | 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>
* lib*/version.h: Bump Versions before release/5.0 branchAndreas Rheinhardt2022-01-04
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/packet_internal: Add proper PacketList structAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | | | | 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>
* configure, avcodec/Makefile: Add new mpeg4audio CONFIG_EXTRA groupAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | | | | 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>
* avcodec/raw: Reduce number of avpriv symbolsAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* avdevice/dshow: ensure pin's default format is setDiederick Niehorster2022-01-04
| | | | | | | | | | | | 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>
* avdevice/dshow: only set pin format if wantedDiederick Niehorster2022-01-04
| | | | | Signed-off-by: Diederick Niehorster <dcnieho@gmail.com> Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
* avdevice/dshow: fix crash on x86Diederick Niehorster2022-01-04
| | | | | | | | | | | fix regression introduced in 911ba8417e8881a7380842e69e11ca05fdc46575. 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>
* avdevice/dshow: proper cleanup of queried media typesDiederick Niehorster2022-01-04
| | | | | Signed-off-by: Diederick Niehorster <dcnieho@gmail.com> Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
* avdevice/dshow: tv_tuner_audio_dialog cleanup missingDiederick Niehorster2022-01-04
| | | | | | | | 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>
* Makefile: Redo duplicating object files in shared buildsAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib*/version.h: Bump Versions after release/5.0 branchMichael Niedermayer2022-01-03
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lib*/version.h: Bump Versions before release/5.0 branchMichael Niedermayer2022-01-03
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avdevice/dshow: don't mix declarations and codeJames Almer2021-12-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/dshow: remove unused variablesJames Almer2021-12-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/dshow: select format with extended color infoDiederick Niehorster2021-12-24
| | | | | | | | | | | | | | | | | | | | | | 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>
* avdevice/dshow: discover source color range/space/etcDiederick Niehorster2021-12-24
| | | | | | | | | | 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>
* avdevice/dshow: add media type info to get_device_listDiederick Niehorster2021-12-24
| | | | | | | | 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>
* avdevice: add info about media types(s) to AVDeviceInfoDiederick Niehorster2021-12-24
| | | | | | | | | | | | | | 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>
* avdevice/dshow: list_devices: show media type(s) per deviceDiederick Niehorster2021-12-24
| | | | | | | | | | | | 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>
* avdevice/dshow: implement get_device_listDiederick Niehorster2021-12-24
| | | | | | | Needed to enable programmatic discovery of DirectShow devices Signed-off-by: Diederick Niehorster <dcnieho@gmail.com> Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
* avdevice/dshow: set no-seek flagsDiederick Niehorster2021-12-24
| | | | | | | | | | | | | | | | 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>
* avdevice/dshow: handle unknown sample timeDiederick Niehorster2021-12-24
| | | | | | | | | | | | | 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>
* avdevice/dshow: query graph and sample time only onceDiederick Niehorster2021-12-24
| | | | | | | | 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>
* avdevice/dshow: implement option to use device video timestampsDiederick Niehorster2021-12-24
| | | | | | | | | | | | | | | | | | | | | 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>
* avdevice/dshow: prevent NULL accessDiederick Niehorster2021-12-24
| | | | | | | | | 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>
* lavd/v4l2: detect device name truncationAnton Khirnov2021-12-07
| | | | | | | | | | | | | | | | 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).
* lavd/v4l2: reduce variable scopeAnton Khirnov2021-12-07
| | | | | | 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.
* lavd/v4l2: do not clobber the context FD in v4l2_get_device_list()Anton Khirnov2021-12-07
| | | | | | 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.
* lavd/jack: increase buffer size for snprintf()Anton Khirnov2021-12-07
| | | | | | | | | | | | | | 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); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* avdevice/lavfi: Don't require AV_PIX_FMT_NONE == -1Andreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/lavfi: Simplify setting sample_fmtsAndreas Rheinhardt2021-12-03
| | | | | | | | | 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>
* avdevice/lavfi: Make array static constAndreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/lavfi: Avoid calling av_buffersink_get_* multiple timesAndreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/lavfi: Use dedicated pointer to access st->codecparAndreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/lavfi: Don't unnecessarily write '\0' to AVBPrintAndreas Rheinhardt2021-12-03
| | | | | | | | | An AVBPrint's internal string is always already zero-terminated; writing another '\0' is unnecessary as long as one treats the string only as a C-string. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/lavfi: Properly free an AVDictionaryAndreas Rheinhardt2021-12-03
| | | | | | | | It is not documented that freeing the last (and only) entry of an AVDictionary frees the dictionary. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/lavfi: Cleanup generically on read_header failureAndreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* av(codec|device): Don't cast pointers to intAndreas Rheinhardt2021-11-21
| | | | | | | | | | C99/C11 6.3.2.3 5: "Any pointer type may be converted to an integer type. [...] If the result cannot be represented in the integer type, the behavior is undefined." So stop casting pointers to int; use uintptr_t instead. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* */version.h: define FF_API macros unconditionallyAnton Khirnov2021-11-15
| | | | | | | There is no reason to wrap them in #ifndef guards, they should only be defined here and nowhere else. The define guards just add the possibility to accidentally use the same FF_API name in different libraries.
* avdevice/dshow: fix a unused variable warningJames Almer2021-11-13
| | | | | | | Unused if DSHOWDEBUG is not set since commit d9a9b4c877b85fea5a5bad74c3d592a756047f79. Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/dshow: fix print format for some variablesJames Almer2021-11-13
| | | | | | | WAVEFORMATEX.nChannels and WAVEFORMATEX.wBitsPerSample are of type WORD, aka unsigned short. Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/dshow: Fix missing PCM sample size option when it is used as the ↵Brad Isbell2021-11-05
| | | | | | | | lone option for DirectShow audio capture Signed-off-by: Brad Isbell <brad@audiopump.co> Reviewed-by: Roger Pack <rogerdpack2@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avdevice/dshow: Use WAVEFORMATEX from AM_MEDIA_TYPE for describing device ↵Brad Isbell2021-11-05
| | | | | | | | capabilities. (Fixes #9420) Signed-off-by: Brad Isbell <brad@audiopump.co> Reviewed-by: Roger Pack <rogerdpack2@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avdevice/caca: Don't free AVOpt-enabled string manuallyAndreas Rheinhardt2021-10-09
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/caca: Make deinit function out of write_trailerAndreas Rheinhardt2021-10-09
| | | | | | | Fixes memleaks in case the trailer is never written. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice/xv: Increase array sizeAndreas Rheinhardt2021-10-09
| | | | | | | | | | | | | av_image_copy() expects an array of four pointers according to its declaration; although it currently only touches pointers that are actually in use (depending upon the pixel format) this might change at any time (as has already happened for the linesizes in d7bc52bf456deba0f32d9fe5c288ec441f1ebef5). This fixes ticket #9264 as well as a warning from GCC 11. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libavdevice/avfoundation.m: fix potential unreleased lock issueChengfeng Ye2021-09-17
| | | | | | | | | The problem here is that the lock ctx->frame_lock will become an unreleased lock if the program returns at patched lines. Bug tracker link: https://trac.ffmpeg.org/ticket/9386\#ticket Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
* libavdevice/avfoundation.m: fix protential unreleased lock issueChengfeng Ye2021-09-17
| | | | | | | | | | The problem here is that the lock ctx->frame_lock will become an unreleased lock if the program returns at line 697, line 735 and line744. Bug tracker link: https://trac.ffmpeg.org/ticket/9385\#ticket Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>