Commit Graph

51 Commits

Author SHA1 Message Date
Martin Pulec
8b94de582c lavc: replace deprecated items
Some AVCodec properties like pix_fmts or sample_fmts are marked as
deprecated and should be replaced by avcodec_get_supported_config()
in current FFmpeg.

Created compat functions to get rid of deprecate warnings running with
both old and new FFmpeg.
2024-11-12 14:59:19 +01:00
Martin Pulec
468b2ca2eb lavc audio: fixed typo
fixes #351
2023-10-30 10:31:16 +01:00
Martin Pulec
cfa25394a5 lavc audio: ensure NUL-termination on truncation
strappend() actually doesn't NUL-terminate output, so in the edge cases,
the output doesn't need to be terminated.
2023-10-26 08:44:45 +02:00
Martin Pulec
5013ee9b10 lavc audio: suggest Opus if using MP3 or AAC
Opus shuould outperform both (see articles referenced in the wiki),
use warning for FFmpeg native AAC.
2023-10-25 13:02:41 +02:00
Martin Pulec
b122be0be3 lavc audio enc: improved error reporting
- print error if:

    1. `uv -s testcard -A Opus --param audio-lavc-encoder=nonsense`
    2. `uv -s testcard -A Opus --param audio-lavc-encoder=libopus` but libopus
was not compiled in

- print requested encoder name if not suitable to encode the codec,
eg. `uv -t testcard -A Opus --param audio-lavc-encoder=AAC`
2023-10-25 13:02:41 +02:00
Martin Pulec
01493ce580 lavc audio: refactor init a bit
Moved encoder/decoder AVCodec init to separate functions to reduce
complexity.
2023-10-25 13:02:41 +02:00
Martin Pulec
53027dc874 lavc audio: removed custom macro
duplicite, already in macros.h
2023-10-25 13:02:41 +02:00
Martin Pulec
561436b8ea lavc audio: set Opus default bitrate to 96000
Opus excels at 96 kbps in the test [1]. See also [2], which however
measures stereo and Opus seems to do some inter-channel optimizations
[3], therfore the bitrate cannot be simply divided by 2 (UG audio bitrate
is given per channel).

[1]:
https://listening-test.coresv.net/results.htm

[2]:
https://hydrogenaud.io/index.php/topic,120007.0.html

[3]:
https://hydrogenaud.io/index.php/topic,120007.75.html
2023-10-25 13:02:41 +02:00
Martin Pulec
717813ae0d lavc audio: prefer libopus
Currently, libopus is prefered over opus as encoder but only because
opus is marked as experimental; it, however, precedes libopus in FFmpeg
codec_list[] so the native would be selected as soon as the experimental
flag is removed.
2023-10-25 13:02:41 +02:00
Martin Pulec
53fad82f7e lavc audio: print available encoders/decoders 2023-10-25 13:02:41 +02:00
Martin Pulec
ff5ca386e6 audio codec: remove deprecated flag + new API fn
Get the info from audio lavc in textual form instead with a new API to
querying additional info about codec for user.

The new API will allow adding additional useful information in help,
eg. encoders present.

this updates the commit a0dd6b9b85
2023-10-25 13:02:38 +02:00
Martin Pulec
395cb24845 lavc audio: missing NL 2023-10-23 14:28:46 +02:00
Martin Pulec
a081105ac5 lavc audio: added some debug 2023-10-23 13:40:22 +02:00
Martin Pulec
8e8c1f3356 lavc audio: fixed TS computation
fixes:
```
uv -d decklink:sync -r embedded -t testcard:mode=Hp24 -s embedded -A AAC
```

TS adjustnment was made with input BPS (2 B in example above) but the
data len is already converted for codec (4 B for AAC).
2023-10-17 12:45:30 +02:00
Martin Pulec
d49e59864e lavc audio: drop frame if PTS < 0
Some codecs (eg. libopus) produce first packet with PTS -120 at 48000 time
base so drop this packet, because we do not support negative timestamps
It would crash on assert in audio_frame2::set_timestamp(), anyways.
2023-10-16 16:29:24 +02:00
Martin Pulec
07c9a1e7e7 lavc audio: do not return NULL on overflow
Data encoded so far can be useful.
2023-10-16 16:29:24 +02:00
Martin Pulec
16b59cffc1 lavc audio: write output in a function 2023-10-16 16:29:24 +02:00
Martin Pulec
3683965e2c audio compress: correctly pass timestamps 2023-10-16 16:29:23 +02:00
Martin Pulec
46a2cae951 lavc audio: flush aux buffer
can be issue only under some circumstances:
1. reconfiguring audio encoder
2. audio frame is not divisible by chunk_size (codec frame size) so
there was left some data in the buffer
2023-10-16 16:29:12 +02:00
Martin Pulec
2191dfd228 Revert "audio decompress: pass packet list (iterator)"
This reverts commit 29421cd1fe.
2023-10-16 16:19:56 +02:00
Martin Pulec
175844d63a Revert "lavd audio: use packet API"
This reverts commit 7f810b8ddd.
2023-10-16 16:19:56 +02:00
Martin Pulec
63fc94e294 lavc audio: refactor a bit
factored out input data processing to a separate function
2023-10-16 16:19:56 +02:00
Martin Pulec
a2ec0374c1 lavc audio: unref av_frame in cleanup
fixes GH-338
2023-09-19 11:14:28 +02:00
Martin Pulec
ebca9c7daf lavc audio: early return + reformat 2023-09-19 11:14:28 +02:00
Martin Pulec
2f995895c8 rename indent_paragraph to wrap_paragraph
More suitable name - the function doesn't indent but just wraps long
lines.
2023-09-15 15:36:41 +02:00
Martin Pulec
7f810b8ddd lavd audio: use packet API
use packet API for OPUS
2023-08-01 12:01:09 +02:00
Martin Pulec
29421cd1fe audio decompress: pass packet list (iterator) 2023-08-01 12:01:09 +02:00
Martin Pulec
f7e29f1d81 remove more FFmpeg compat
according to FFmpeg commit 80154b1b, the current cut-off in UG was lavc
version 57.107.100 (incl), which corresponds to lavu 55.78.100 (incl).
2023-05-05 10:25:46 +02:00
Martin Pulec
90609916bc added param audio-lavc-decoder
added param to specify decoder (complement to option specifying encoder)

+ hard-fail if requested encoder doesn't encode requested codec
2023-04-26 09:53:10 +02:00
Martin Pulec
48219758ea use Opus, not OPUS
For audio codecs, we respect its native capitalization of letters, eg.
AAC, speex. So do it also for Opus. This should not affect existing
applications since the Opus name is parsed case-insensitively.

Only exception is SDP (rtpmap) where is usually used lower-case (at
least in rfc7587).
2023-04-26 09:53:10 +02:00
Martin Pulec
da699d007d libavcodec audio decompress: read all frames
sync with current FFmpeg example (decode_audio.c) that reads all
available frames
2023-04-26 09:53:08 +02:00
Martin Pulec
3be1c115a7 audio libavcodec: do not use ad hoc allocated pkts
We have one AVPacket allocated in libavcodec state and since previous
commit, the allocated packet would leak in case of decode error.
2023-04-25 17:08:28 +02:00
Martin Pulec
b6fea1cfe8 audio libavcodec_decompress: refactor
This commit is mostly just a refactor - the removed while loop was
actually always run exactly once (supposing that data passed to us
is longer than zero).

Functional changes:
- assuming non-zero input
- returning NULL on error

Supposedly the above changes should not alter UG expected behavior.
2023-04-25 17:08:27 +02:00
Martin Pulec
97a7294999 audio libavcodec_decompress: simplified
some simplification after compat removal
2023-04-25 17:08:27 +02:00
Martin Pulec
ebaa9007a3 lavd audio: some support for native Opus encoder
It somehow works now but the stream isn't correct, gave up after few
hours of attempts, looks like every second frame (120 samples) is both
temporarily and spatially (inverse value) inverted for some reason.
2023-04-25 17:08:27 +02:00
Martin Pulec
36313f2f87 lavc audio: added param to specify encoder 2023-04-25 17:08:27 +02:00
Martin Pulec
72b3e61281 lavc audio: if temporary buffer is filled, continue
Returning doesn't make sense, because it would be impossible to drain
the buffer since the call will end up exactly in the same place under
similar circumstances (also with the same data_len).
2023-04-25 17:08:27 +02:00
Martin Pulec
56872e28cd audio lavc: removed old FFmpeg compat
removed compat with lavc <57.37.100

As commit 342faa1f removed compatibility code with libavcodec
57.107.100 (FFmpeg from 2017), there is no need to keep compatibility
with even older FFmpeg versions.
2023-04-25 17:08:25 +02:00
Martin Pulec
50e6d9a94b lavc audio: fixed wrong condition
fixes CID 405634
2023-03-20 16:54:28 +01:00
Martin Pulec
0a991aa0c5 lavc audio: use logger instead of fprintf 2023-03-02 12:35:35 +01:00
Martin Pulec
88621797cc lavc audio: reduce repeating allocations
Keep allocated temporary buffer for further use instead of repeatingly
reallocating it.
2023-03-02 12:35:35 +01:00
Martin Pulec
fa649b651e lavc audio: suppress a warning
suppress missing-field-initializers warning when assigning
AVChannelLayout to AVCodecContext::ch_layout. This is C++ specific, the
construction is entirely fine in C (empty-initializes remaining
members).

Rewritten to C - it seems to be a bit invasive, because the rewrite is
quite huge. On the other hand, it cleans the code a bit and also
removes some inefficiencies that there have been (now not possible
because the absence of RAII).
2023-03-02 12:35:30 +01:00
Martin Pulec
42504a3980 Use C++ compiler for files using audio_frame2 2014-08-13 13:37:52 +02:00
Martin Pulec
a68fca8258 Fixed name of module register functions 2014-08-13 13:36:25 +02:00
Martin Pulec
57932e3825 Libavcodec: fixed support for v54 2014-05-12 11:17:09 +02:00
Martin Pulec
e01c020c50 Audio codec: possibility to specify bitrate 2014-04-15 16:16:25 +02:00
Martin Pulec
47774f0664 fix 2014-01-15 15:43:27 +01:00
Martin Pulec
4b1b1d3314 Libavcodec: avoid division by zero
Fixed according to https://trac.videolan.org/vlc/ticket/8508.
2014-01-10 17:40:36 +01:00
Martin Pulec
c4f3433ce2 Audio: support for libavcodec < 55 2014-01-10 17:11:14 +01:00
Martin Pulec
af15bf84bd Fixed some additional compiler warnings (GCC) 2013-07-11 13:40:15 +02:00