Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently,
Parameters
tries to differentiate its states (owned, shared) by setting theowner
field. With the way the API works at the moment, there really isn't any advantage to this over using different structs for owned, shared, and mutable shared states. It takes up an extraRc
and complicates the differentiation between immutable and mutable borrows (since it's all the same type).I'm also pretty sure that there is some potential for nasty UB via
Stream::parameters
because the returnedParameters
type can be accessed mutably1 even thoughStream
is supposed to be an immutable reference toAVStream
.Some notes regarding the new implementation:
Something
(owned),SomethingRef
,SomethingMut
for other wrapper types in the futureimpl<'a> AsRef<SomethingRef<'a>> for Something
because it returns a&'b SomethingRef<'a>
with two levels of indirection, which seems unnecessaryfrom_raw
. At the moment, the only safety concern is that you need to bound the returned lifetime correctly (since it can otherwise be arbitrarily chosen). The best way to do this is by bounding it on a borrow of another type:StreamMut::copy_parameters_from_context
seems a bit unnecessary, but it is more efficient. The old implementation always allocated a newAVCodecParameters
from a context, and then copied thatAVCodecParameters
into the stream. The new one just usesparameters_from_context(stream.codecpar, context)
which avoids the in-between stepFootnotes
See examples/transcode-x264.rs:
(*ost.parameters().as_mut_ptr()).codec_tag = 0;
↩