#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/fifo.h"
+#include "libavutil/hwcontext.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))
av_dict_set(&ost->encoder_opts, "threads", "auto", 0);
- if (ost->filter && ost->filter->filter->inputs[0]->hw_frames_ctx) {
+ 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) {
ost->enc_ctx->hw_frames_ctx = av_buffer_ref(ost->filter->filter->inputs[0]->hw_frames_ctx);
if (!ost->enc_ctx->hw_frames_ctx)
return AVERROR(ENOMEM);
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/buffer.h"
#include "libavutil/channel_layout.h"
}
if (link->src->nb_inputs && link->src->inputs[0]->hw_frames_ctx &&
- !link->hw_frames_ctx) {
- AVHWFramesContext *input_ctx = (AVHWFramesContext*)link->src->inputs[0]->hw_frames_ctx->data;
-
- if (input_ctx->format == link->format) {
- link->hw_frames_ctx = av_buffer_ref(link->src->inputs[0]->hw_frames_ctx);
- if (!link->hw_frames_ctx)
- return AVERROR(ENOMEM);
- }
+ !(link->src->filter->flags_internal & FF_FILTER_FLAG_HWFRAME_AWARE)) {
+ av_assert0(!link->hw_frames_ctx &&
+ "should not be set by non-hwframe-aware filter");
+ link->hw_frames_ctx = av_buffer_ref(link->src->inputs[0]->hw_frames_ctx);
+ if (!link->hw_frames_ctx)
+ return AVERROR(ENOMEM);
}
if ((config_link = link->dstpad->config_props))
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
* code.
*/
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)
+
#endif /* AVFILTER_INTERNAL_H */
.inputs = qsvdeint_inputs,
.outputs = qsvdeint_outputs,
+
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
.priv_class = &hwdownload_class,
.inputs = hwdownload_inputs,
.outputs = hwdownload_outputs,
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
.priv_class = &hwupload_class,
.inputs = hwupload_inputs,
.outputs = hwupload_outputs,
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
.inputs = cudaupload_inputs,
.outputs = cudaupload_outputs,
+
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
.inputs = nppscale_inputs,
.outputs = nppscale_outputs,
+
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
.inputs = qsvscale_inputs,
.outputs = qsvscale_outputs,
+
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
.inputs = scale_vaapi_inputs,
.outputs = scale_vaapi_outputs,
.priv_class = &scale_vaapi_class,
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};