39 #define MV_P_FOR (1<<0) 40 #define MV_B_FOR (1<<1) 41 #define MV_B_BACK (1<<2) 42 #define MV_TYPE_FOR (1<<0) 43 #define MV_TYPE_BACK (1<<1) 44 #define FRAME_TYPE_I (1<<0) 45 #define FRAME_TYPE_P (1<<1) 46 #define FRAME_TYPE_B (1<<2) 57 #define OFFSET(x) offsetof(CodecViewContext, x) 58 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 59 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit } 63 CONST(
"pf",
"forward predicted MVs of P-frames",
MV_P_FOR,
"mv"),
64 CONST(
"bf",
"forward predicted MVs of B-frames",
MV_B_FOR,
"mv"),
65 CONST(
"bb",
"backward predicted MVs of B-frames",
MV_B_BACK,
"mv"),
92 static int clip_line(
int *sx,
int *sy,
int *ex,
int *ey,
int maxx)
100 *sy = *ey + (*sy - *ey) * (int64_t)*ex / (*ex - *sx);
107 *ey = *sy + (*ey - *sy) * (int64_t)(maxx - *sx) / (*ex - *sx);
125 if (
clip_line(&sx, &sy, &ex, &ey, w - 1))
127 if (
clip_line(&sy, &sx, &ey, &ex, h - 1))
130 sx = av_clip(sx, 0, w - 1);
131 sy = av_clip(sy, 0, h - 1);
132 ex = av_clip(ex, 0, w - 1);
133 ey = av_clip(ey, 0, h - 1);
135 buf[sy * stride + sx] +=
color;
144 f = ((ey - sy) << 16) / ex;
145 for (x = 0; x <= ex; x++) {
147 fr = (x *
f) & 0xFFFF;
148 buf[ y * stride + x] += (color * (0x10000 - fr)) >> 16;
149 if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
159 f = ((ex - sx) << 16) / ey;
162 for(y= 0; y <= ey; y++){
165 buf[y * stride + x ] += (color * (0x10000 - fr)) >> 16;
166 if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
179 int ey,
int w,
int h,
int stride,
int color,
int tail,
int direction)
188 sx = av_clip(sx, -100, w + 100);
189 sy = av_clip(sy, -100, h + 100);
190 ex = av_clip(ex, -100, w + 100);
191 ey = av_clip(ey, -100, h + 100);
196 if (dx * dx + dy * dy > 3 * 3) {
199 int length = sqrt((rx * rx + ry * ry) << 8);
210 draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
211 draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
213 draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
223 int qstride, qp_type,
ret;
241 for (y = 0; y <
h; y++) {
242 for (x = 0; x <
w; x++) {
243 const int qp =
ff_norm_qscale(qp_table[(y >> 3) * qstride + (x >> 3)], qp_type) * 128/31;
262 for (i = 0; i < sd->
size /
sizeof(*mvs); i++) {
264 const int direction = mv->
source > 0;
271 is_iframe && is_fp || is_iframe && is_bp ||
272 is_pframe && is_fp ||
273 is_bframe && is_fp || is_bframe && is_bp)
326 .
inputs = codecview_inputs,
328 .priv_class = &codecview_class,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
int16_t src_x
Absolute source position.
Main libavfilter public API header.
static const AVFilterPad codecview_outputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static const AVOption codecview_options[]
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
int16_t dst_x
Absolute destination position.
Structure to hold side data for an AVFrame.
int32_t source
Where the current macroblock comes from; negative value when it comes from the past, positive value when it comes from the future.
static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color, int tail, int direction)
Draw an arrow from (ex, ey) -> (sx, sy).
#define ROUNDED_DIV(a, b)
A filter pad used for either input or output.
static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color)
Draw a line from (ex, ey) -> (sx, sy).
A link between two filters.
#define CONST(name, help, val, unit)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h, int *qscale_type)
Extract a libpostproc-compatible QP table - an 8-bit QP value per 16x16 macroblock, stored in raster order - from AVVideoEncParams side data.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
AVFILTER_DEFINE_CLASS(codecview)
enum AVPictureType pict_type
Picture type of the frame.
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const AVFilterPad outputs[]
int format
agreed upon media format
static int query_formats(AVFilterContext *ctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int clip_line(int *sx, int *sy, int *ex, int *ey, int maxx)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
static int ff_norm_qscale(int qscale, int type)
Normalize the qscale factor FIXME the H264 qscale is a log based scale, mpeg1/2 is not...
static enum AVPixelFormat pix_fmts[]
#define flags(name, subs,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int config_input(AVFilterLink *inlink)
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
static const AVFilterPad codecview_inputs[]
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
AVFilterContext * dst
dest filter
#define FFSWAP(type, a, b)
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
AVPixelFormat
Pixel format.
#define AV_CEIL_RSHIFT(a, b)