Fixed HWAccel so we don't share contexts between streams #1689
+47
−29
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.
They may have different codecs (if both supported by the hardware), and in the future different devices and options. With the merging of HWAccel and HWAccelCtx we need to make a copy before we initialize the context.
IMO this makes the HWAccel class a bit confusing as it's now trying to do two different things - 1. Configs the user can supply that can be combined with a codec to create a hardware context, and 2. the hardware context itself. I think it makes more sense to keep them separate, but if you really want to merge them, the fix here fixes the multiple streams problem.
I removed the codec field from the class as that should never be supplied via init(). We only get that when we create an object for the class' second role using create(), and we can just pass it into _initialize_hw_context() then, after which we don't need the codec anymore.
In the future we may want to allow the user to specify multiple hwaccels for different codecs, then we'll need to add it back as a field, and it will be very confusing then, but that's another problem for another time.