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.
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.
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.
This is really inconvenient for people who don't need to modify
rust-ffmpeg-sys.
To develop the two repos together just put
paths = ['../rust-ffmpeg-sys']
in .cargo/config.toml.
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.