428 Commits

Author SHA1 Message Date
Bojan Šernek
dc2a82f890
software::resampling::Context: add get_with method (#41)
get_with allows setting additional options not covered by swr_alloc_set_opts.

Signed-off-by: Zhiming Wang <i@zhimingwang.org>
2020-12-13 10:39:04 +08:00
Zhiming Wang
b0722df007
Fix clippy::match_like_matches_macro 2020-10-11 10:10:08 +08:00
Zhiming Wang
6f0a14ee8b
codec: fix codec description potential null ptr issue
Codecs may not have .long_name initialized.

Issue raised by Pilyushkin in #34.
2020-10-04 11:37:59 +08:00
Maor Kleinberger
6a7a69e1e7
util::error: drop reserved errnos that are not available on Windows
Signed-off-by: Zhiming Wang <i@zhimingwang.org>
2020-08-12 10:30:11 +08:00
Zhiming Wang
545180cad0
format: context::{input,output}::dump: fix url/path printing
Previously the unwrapped CString did not have long enough lifetime to be
printed; not sure why there's no compiler warning.
2020-08-11 00:30:58 +08:00
Zhiming Wang
48b5751752
lib: export util::log 2020-08-10 21:57:55 +08:00
Zhiming Wang
d07530267e
format: mark Context::nb_streams as public 2020-08-09 13:58:48 +08:00
Zhiming Wang
1849a07aa6
lib: export util::error 2020-08-09 13:58:24 +08:00
Zhiming Wang
c9d223e8fe
util::error: correct comment regarding errno reexports 2020-08-09 13:57:43 +08:00
Zhiming Wang
81e142c6b7
util: introduce new Error variant Error:Other { errno }
Do not hide all the POSIX error codes behind a useless Error::Unknown.

Fixes #24.
2020-08-08 23:16:09 +08:00
Zhiming Wang
5affb85148
codec: fix signature of Packet::write_interleaved
av_interleaved_write_frame never returns 1, so bool makes no sense:
https://github.com/FFmpeg/FFmpeg/blob/n4.3.1/libavformat/avformat.h#L2592-L2635

Fixes #25.
2020-08-08 22:48:01 +08:00
Zhiming Wang
6f44fb79fd
codec: deprecate encoder's encode/flush and decoder's decode 2020-08-08 01:16:44 +08:00
Zhiming Wang
07fe207ac2
codec: implement DerefMut for encoder::Audio and encoder::Subtitle 2020-08-08 00:38:09 +08:00
Zhiming Wang
363001febe
codec: expose modern send/receive packet/frame APIs
avcodec_encode_video2()/avcodec_decode_video2/avcodec_encode_audio2()/avcodec_decode_audio4()
have been deprecated since FFmpeg 3.1, with modern
avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/avcodec_receive_packet()
as replacements.

This commit adds send_packet(), send_eof() and receive_frame() to
decoder::Opened; send_frame(), send_eof() and receive_packet() to
encoder::Encoder to expose these modern APIs.
2020-08-08 00:37:54 +08:00
Kornel Lesiński
516f8069f6
Packet setters 2020-08-07 22:43:53 +08:00
Kornel Lesiński
50e1ccaca4
Don't panic on OOM 2020-08-07 22:43:53 +08:00
Kornel Lesiński
f0903fb69b
Allow null codec 2020-08-07 22:43:52 +08:00
Kornel Lesiński
f73dca70b4
Debug for Context 2020-08-07 22:43:52 +08:00
Kornel Lesiński
aa8df7d0d2
DRY nb_streams 2020-08-07 22:42:17 +08:00
Kornel Lesiński
53570d13d7
Add Debug for dictionary 2020-08-07 22:42:17 +08:00
Vasily Chekalkin
b31b5507fb
Add Send trait to resampling::Context 2020-08-07 22:31:11 +08:00
Zhiming Wang
f1ccd4e696
filter::Source: add close method
Expose av_buffersrc_close.
2020-08-03 18:49:14 +08:00
Zhiming Wang
d3270133be
Add log::util module 2020-08-03 18:46:49 +08:00
Zhiming Wang
b28e852eb0
Implement automatic FFmpeg version detection
Based on ffmpeg-sys-next 4.3.2.
2020-08-02 11:44:13 +08:00
Zhiming Wang
1d0d42d81a
filter: test_paditer: register_all before testing the overlay filter
avfilter_register_all required on FFmpeg <4 before avfilter_get_by_name can
find the builtin filters.
2020-07-26 12:42:57 +08:00
Zhiming Wang
e947bc5606
Fix clippy::transmute_ptr_to_ptr 2020-07-26 12:26:20 +08:00
Zhiming Wang
c9c6031a53
Fix clippy::ptr_offset_with_cast 2020-07-26 01:01:21 +08:00
Zhiming Wang
73b66ea438
Fix clippy::redundant_field_names 2020-07-26 01:01:13 +08:00
Zhiming Wang
ceb1a7ea7c
Allow clippy::{missing_safety_doc, module_inception, too_many_arguments} 2020-07-26 01:00:54 +08:00
Zhiming Wang
6639f02b80
Fix filter::filter::PadIter to actually iterate
Bug caught by clippy:

  error: offset calculation on zero-sized value
    --> src/filter/filter.rs:98:33
     |
  98 |             let pad = Pad::wrap(self.ptr.offset(self.cur));
     |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `#[deny(clippy::zst_offset)]` on by default
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zst_offset

The problem is that `AVFilterPad` is zero-sized:

  #[repr(C)]
  #[derive(Debug, Copy, Clone)]
  pub struct AVFilterPad {
      _unused: [u8; 0],
  }

which is in turn due to `AVFilterPad` being an opaque type in
`libavfilter/avfilter.h`:

  typedef struct AVFilterContext AVFilterContext;
  typedef struct AVFilterLink    AVFilterLink;
  typedef struct AVFilterPad     AVFilterPad;
  typedef struct AVFilterFormats AVFilterFormats;

Doing pointer arithmetic on an opaque (incomplete) type doesn't work. We have
to use the proper FFI calls to obtain info on individual pads. The API has to
be tweaked a bit; hopefully it doesn't break user programs (if it does it
should only break bugged ones...).

Fixes #20.
2020-07-25 23:34:27 +08:00
Tim Hellhake
65be233a12
Add Raspberry Pi compatibility
Signed-off-by: Zhiming Wang <i@zhimingwang.org>
2020-07-24 22:18:58 +08:00
Zhiming Wang
d4c64458db
Fix ARM compatibility
Tested to successfully compile in an arm64v8/debian:buster container (running
on an x64 box through qemu-aarch64). Should work on armhf too, though haven't
tested yet.
2020-07-24 20:27:58 +08:00
Zhiming Wang
ba2caf9d13
software::scaling::context::run: fix srcSliceH argument
Output height was erroneously used as the srcSliceH argument to
sws_scale, causing the output frame to be partially blank when scaling
down or outright erroring when scaling up. See documentation of sws_scale:

https://www.ffmpeg.org/doxygen/4.0/group__libsws.html#gae531c9754c9205d90ad6800015046d74

Fixes #18.
2020-07-23 10:01:19 +08:00
Zhiming Wang
15c87a7837
Add FFmpeg 4.3 specific code 2020-06-17 01:51:38 +08:00
Zhiming Wang
036c0e5b42
Fix duplicate enum variant issues for FFmpeg 3.4 2020-06-11 23:18:47 +08:00
Zhiming Wang
307f52c002
Reformat code with latest cargo fmt 2020-06-02 17:54:31 +08:00
Zhiming Wang
fcca68ae5e
Add FFmpeg 4.2 specific code 2020-06-01 14:42:39 +08:00
Zhiming Wang
a69a457e3a
Add FFmpeg 4.1 specific code 2020-06-01 14:15:33 +08:00
Zhiming Wang
6220b88ef2
util/format/pixel: drop deprecated error::Error::description 2020-06-01 13:39:59 +08:00
Zhiming Wang
506f66ac51
Fix issues related to duplicate enum variants
C enums allow duplicate variants, but Rust enums don't. At some point bindgen
switched to generating duplicate variants as associated constants instead of
module-level constants, so use SomeEnum::* broke. Here we switch to associated
constants in the native API as well.
2020-06-01 13:36:50 +08:00
Zhiming Wang
1cd6d0499b
Switch to my fork of ffmpeg-sys 2020-06-01 13:17:08 +08:00
Zhiming Wang
6644a91da4
Update bitflags to 1.2 and fix namespacing 2020-06-01 13:06:34 +08:00
Zhiming Wang
3a8f366f60
software/scaling/context: fix mutability 2020-06-01 13:02:53 +08:00
Zhiming Wang
6c2d33fc07
Drop outdated lints 2020-05-31 14:16:23 +08:00
Zhiming Wang
13a2354a2c
Fix bare_trait_objects deprecation 2020-05-31 14:16:23 +08:00
Zhiming Wang
d3c10e4068
Fix libc::uint8_t deprecation 2020-05-31 14:16:23 +08:00
Zhiming Wang
cd6c9d972b
Fix std::error::Error::description deprecation 2020-05-31 14:16:23 +08:00
Zhiming Wang
587ec66592
Fix libc::int64_t deprecation 2020-05-31 13:34:24 +08:00
Zhiming Wang
3056975836
Fix libc::uint32_t deprecation 2020-05-31 13:28:14 +08:00
Erin Moon
a7ea073619
scaling and resampling contexts: fix null checks
dc6ace91ec

Fixes #1.
2019-02-16 21:20:56 +08:00