Go to the documentation of this file.
44 #define OFFSET(x) offsetof(DnnProcessingContext, dnnctx.x)
45 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
48 #if (CONFIG_LIBTENSORFLOW == 1)
51 #if (CONFIG_LIBOPENVINO == 1)
75 #define LOG_FORMAT_CHANNEL_MISMATCH() \
76 av_log(ctx, AV_LOG_ERROR, \
77 "the frame's format %s does not match " \
78 "the model input channel %d\n", \
79 av_get_pix_fmt_name(fmt), \
80 model_input->channels);
184 ctx->sws_uv_height = sws_src_h;
216 if (!
ctx->sws_uv_scale) {
220 for (
int i = 1;
i < 3; ++
i) {
227 bytewidth, uv_height);
231 0,
ctx->sws_uv_height,
out->data + 1,
out->linesize + 1);
234 0,
ctx->sws_uv_height,
out->data + 1,
out->linesize + 1);
236 0,
ctx->sws_uv_height,
out->data + 2,
out->linesize + 2);
265 *out_pts = out_frame->
pts +
pts;
326 int64_t out_pts =
pts;
363 .
name =
"dnn_processing",
371 .priv_class = &dnn_processing_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static av_cold void uninit(AVFilterContext *ctx)
static const AVOption dnn_processing_options[]
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
#define FILTER_PIXFMTS_ARRAY(array)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
swscale wrapper, so we don't need to export the SwsContext.
static int config_input(AVFilterLink *inlink)
const char * name
Filter name.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
void * priv
private data for use by the filter
static FilteringContext * filter_ctx
A filter pad used for either input or output.
static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define check(x, y, S, v)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
static int copy_uv_planes(DnnProcessingContext *ctx, AVFrame *out, const AVFrame *in)
#define AV_CEIL_RSHIFT(a, b)
static enum AVPixelFormat pix_fmt
static enum AVPixelFormat pix_fmts[]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
DNNAsyncStatusType ff_dnn_get_result(DnnContext *ctx, AVFrame **in_frame, AVFrame **out_frame)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int av_usleep(unsigned usec)
Sleep for a period of time.
#define AV_PIX_FMT_GRAYF32
static int check_modelinput_inlink(const DNNData *model_input, const AVFilterLink *inlink)
#define FILTER_INPUTS(array)
int ff_dnn_get_input(DnnContext *ctx, DNNData *input)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your context
AVFILTER_DEFINE_CLASS(dnn_processing)
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static av_cold int init(AVFilterContext *context)
static const AVFilterPad dnn_processing_inputs[]
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
int ff_dnn_flush(DnnContext *ctx)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
#define DNN_COMMON_OPTIONS
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
struct SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
const AVFilter ff_vf_dnn_processing
FF_FILTER_FORWARD_WANTED(outlink, inlink)
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane.
#define i(width, name, range_min, range_max)
int w
agreed upon image width
static int activate(AVFilterContext *filter_ctx)
const char * name
Pad name.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height)
int h
agreed upon image height
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
#define LOG_FORMAT_CHANNEL_MISMATCH()
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static int prepare_uv_scale(AVFilterLink *outlink)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
void ff_dnn_uninit(DnnContext *ctx)
int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame)
struct SwsContext * sws_uv_scale
static const AVFilterPad dnn_processing_outputs[]
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static int config_output(AVFilterLink *outlink)