Commit b5e1ec56 authored by Matthieu Bouron's avatar Matthieu Bouron

Merge commit 'e3fb74f7'

* commit 'e3fb74f7':
  lavfi: Always propagate hw_frames_ctx through links
Merged-by: 's avatarMatthieu Bouron <matthieu.bouron@gmail.com>
parents 78e871eb e3fb74f7
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "libavutil/parseutils.h" #include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h" #include "libavutil/samplefmt.h"
#include "libavutil/fifo.h" #include "libavutil/fifo.h"
#include "libavutil/hwcontext.h"
#include "libavutil/internal.h" #include "libavutil/internal.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/dict.h" #include "libavutil/dict.h"
...@@ -3421,7 +3422,9 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) ...@@ -3421,7 +3422,9 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
!av_dict_get(ost->encoder_opts, "ab", NULL, 0)) !av_dict_get(ost->encoder_opts, "ab", NULL, 0))
av_dict_set(&ost->encoder_opts, "b", "128000", 0); av_dict_set(&ost->encoder_opts, "b", "128000", 0);
if (ost->filter && av_buffersink_get_hw_frames_ctx(ost->filter->filter)) { if (ost->filter && av_buffersink_get_hw_frames_ctx(ost->filter->filter) &&
((AVHWFramesContext*)av_buffersink_get_hw_frames_ctx(ost->filter->filter)->data)->format ==
av_buffersink_get_format(ost->filter->filter)) {
ost->enc_ctx->hw_frames_ctx = av_buffer_ref(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) if (!ost->enc_ctx->hw_frames_ctx)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
......
...@@ -355,14 +355,12 @@ int avfilter_config_links(AVFilterContext *filter) ...@@ -355,14 +355,12 @@ int avfilter_config_links(AVFilterContext *filter)
} }
if (link->src->nb_inputs && link->src->inputs[0]->hw_frames_ctx && if (link->src->nb_inputs && link->src->inputs[0]->hw_frames_ctx &&
!link->hw_frames_ctx) { !(link->src->filter->flags_internal & FF_FILTER_FLAG_HWFRAME_AWARE)) {
AVHWFramesContext *input_ctx = (AVHWFramesContext*)link->src->inputs[0]->hw_frames_ctx->data; av_assert0(!link->hw_frames_ctx &&
"should not be set by non-hwframe-aware filter");
if (input_ctx->format == link->format) { link->hw_frames_ctx = av_buffer_ref(link->src->inputs[0]->hw_frames_ctx);
link->hw_frames_ctx = av_buffer_ref(link->src->inputs[0]->hw_frames_ctx); if (!link->hw_frames_ctx)
if (!link->hw_frames_ctx) return AVERROR(ENOMEM);
return AVERROR(ENOMEM);
}
} }
if ((config_link = link->dstpad->config_props)) if ((config_link = link->dstpad->config_props))
......
...@@ -268,6 +268,8 @@ typedef struct AVFilter { ...@@ -268,6 +268,8 @@ typedef struct AVFilter {
int priv_size; ///< size of private data to allocate for the filter int priv_size; ///< size of private data to allocate for the filter
int flags_internal; ///< Additional flags for avfilter internal use only.
/** /**
* Used by the filter registration system. Must not be touched by any other * Used by the filter registration system. Must not be touched by any other
* code. * code.
......
...@@ -386,6 +386,12 @@ int ff_filter_activate(AVFilterContext *filter); ...@@ -386,6 +386,12 @@ int ff_filter_activate(AVFilterContext *filter);
*/ */
void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter); void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter);
/**
* The filter is aware of hardware frames, and any hardware frame context
* should not be automatically propagated through it.
*/
#define FF_FILTER_FLAG_HWFRAME_AWARE (1 << 0)
/** /**
* Run one round of processing on a filter graph. * Run one round of processing on a filter graph.
*/ */
......
...@@ -570,4 +570,6 @@ AVFilter ff_vf_deinterlace_qsv = { ...@@ -570,4 +570,6 @@ AVFilter ff_vf_deinterlace_qsv = {
.inputs = qsvdeint_inputs, .inputs = qsvdeint_inputs,
.outputs = qsvdeint_outputs, .outputs = qsvdeint_outputs,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}; };
...@@ -214,4 +214,5 @@ AVFilter ff_vf_hwdownload = { ...@@ -214,4 +214,5 @@ AVFilter ff_vf_hwdownload = {
.priv_class = &hwdownload_class, .priv_class = &hwdownload_class,
.inputs = hwdownload_inputs, .inputs = hwdownload_inputs,
.outputs = hwdownload_outputs, .outputs = hwdownload_outputs,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}; };
...@@ -231,4 +231,5 @@ AVFilter ff_vf_hwupload = { ...@@ -231,4 +231,5 @@ AVFilter ff_vf_hwupload = {
.priv_class = &hwupload_class, .priv_class = &hwupload_class,
.inputs = hwupload_inputs, .inputs = hwupload_inputs,
.outputs = hwupload_outputs, .outputs = hwupload_outputs,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}; };
...@@ -187,4 +187,6 @@ AVFilter ff_vf_hwupload_cuda = { ...@@ -187,4 +187,6 @@ AVFilter ff_vf_hwupload_cuda = {
.inputs = cudaupload_inputs, .inputs = cudaupload_inputs,
.outputs = cudaupload_outputs, .outputs = cudaupload_outputs,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}; };
...@@ -592,4 +592,6 @@ AVFilter ff_vf_scale_npp = { ...@@ -592,4 +592,6 @@ AVFilter ff_vf_scale_npp = {
.inputs = nppscale_inputs, .inputs = nppscale_inputs,
.outputs = nppscale_outputs, .outputs = nppscale_outputs,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}; };
...@@ -628,4 +628,6 @@ AVFilter ff_vf_scale_qsv = { ...@@ -628,4 +628,6 @@ AVFilter ff_vf_scale_qsv = {
.inputs = qsvscale_inputs, .inputs = qsvscale_inputs,
.outputs = qsvscale_outputs, .outputs = qsvscale_outputs,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}; };
...@@ -477,4 +477,5 @@ AVFilter ff_vf_scale_vaapi = { ...@@ -477,4 +477,5 @@ AVFilter ff_vf_scale_vaapi = {
.inputs = scale_vaapi_inputs, .inputs = scale_vaapi_inputs,
.outputs = scale_vaapi_outputs, .outputs = scale_vaapi_outputs,
.priv_class = &scale_vaapi_class, .priv_class = &scale_vaapi_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment