On Thu, 2 Feb 2017 12:49:56 +0000
Mark Thompson <[email protected]> wrote:

> ---
> This is now needed independently of hwaccel setup because it has to happen 
> before avcodec_open2().
> 
> 
>  avconv.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/avconv.c b/avconv.c
> index 94b6da2..0536e72 100644
> --- a/avconv.c
> +++ b/avconv.c
> @@ -1703,6 +1703,13 @@ static int init_input_stream(int ist_index, char 
> *error, int error_len)
>  
>          if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0))
>              av_dict_set(&ist->decoder_opts, "threads", "auto", 0);
> +
> +        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 ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 
> 0) {
>              char errbuf[128];
>              if (ret == AVERROR_EXPERIMENTAL)
> @@ -2039,6 +2046,12 @@ static int init_output_stream(OutputStream *ost, char 
> *error, int error_len)
>          if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))
>              av_dict_set(&ost->encoder_opts, "threads", "auto", 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 && ost->filter->filter->inputs[0]->hw_frames_ctx &&
>              
> ((AVHWFramesContext*)ost->filter->filter->inputs[0]->hw_frames_ctx->data)->format
>  ==
>              ost->filter->filter->inputs[0]->format) {

Shouldn't it try to use the device from the filter's hw_frames_ctx
(which you see in the diff context)?

Also, could setting the hw_device_ctx unconditionally on input have
weird side-effect, like decoders behaving differently from before?
(E.g. would have created their own context if it isn't set, or could
pick up an incompatible device context meant for the encoder.)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to