[FFmpeg-devel] [PATCH 6/6] ffmpeg: Pass the global device context to encoder and decoder instances
wm4
nfxjfg at googlemail.com
Wed Jan 18 10:03:39 EET 2017
On Tue, 17 Jan 2017 22:32:15 +0000
Mark Thompson <sw at jkqxz.net> wrote:
> ---
> ffmpeg.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 6d1e358..781c0a4 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -2748,6 +2748,12 @@ static int init_input_stream(int ist_index, char *error, int error_len)
> * audio, and video decoders such as cuvid or mediacodec */
> av_codec_set_pkt_timebase(ist->dec_ctx, ist->st->time_base);
>
> + if (hw_device_ctx) {
> + ist->dec_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
> + if (!ist->dec_ctx->hw_device_ctx)
> + return AVERROR(ENOMEM);
> + }
> +
> if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0))
> av_dict_set(&ist->decoder_opts, "threads", "auto", 0);
> if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) {
> @@ -3271,6 +3277,12 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
> !av_dict_get(ost->encoder_opts, "ab", NULL, 0))
> av_dict_set(&ost->encoder_opts, "b", "128000", 0);
>
> + if (hw_device_ctx) {
> + ost->enc_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
> + if (!ost->enc_ctx->hw_device_ctx)
> + return AVERROR(ENOMEM);
> + }
> +
> if (ost->filter && av_buffersink_get_hw_frames_ctx(ost->filter->filter)) {
> ost->enc_ctx->hw_frames_ctx = av_buffer_ref(av_buffersink_get_hw_frames_ctx(ost->filter->filter));
> if (!ost->enc_ctx->hw_frames_ctx)
Doesn't this break the case when hw decoder and encoder are different?
More information about the ffmpeg-devel
mailing list