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);
144 f = ((ey - sy) * (1 << 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) * (1 << 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)
196 if (dx * dx + dy * dy > 3 * 3) {
199 int length = sqrt((rx * rx + ry * ry) << 8);
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;
253 if (
s->mv ||
s->mv_type) {
262 for (
i = 0;
i < sd->
size /
sizeof(*mvs);
i++) {
264 const int direction =
mv->source > 0;
267 const int is_fp = direction == 0 && (
s->mv_type &
MV_TYPE_FOR);
268 const int is_bp = direction == 1 && (
s->mv_type &
MV_TYPE_BACK);
270 if ((!
s->frame_type && (is_fp || is_bp)) ||
271 is_iframe && is_fp || is_iframe && is_bp ||
272 is_pframe && is_fp ||
273 is_bframe && is_fp || is_bframe && is_bp)
297 s->hsub =
desc->log2_chroma_w;
298 s->vsub =
desc->log2_chroma_h;
328 .priv_class = &codecview_class,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define flags(name, subs,...)
#define FFSWAP(type, a, b)
#define AV_CEIL_RSHIFT(a, b)
#define ROUNDED_DIV(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
@ AV_FRAME_DATA_MOTION_VECTORS
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
static const int8_t mv[256][2]
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,...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
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,...
Describe the class of an AVClass context structure.
A link between two filters.
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVPictureType pict_type
Picture type of the frame.
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)
static const AVFilterPad codecview_outputs[]
static const AVFilterPad codecview_inputs[]
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).
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).
#define CONST(name, help, val, unit)
static int query_formats(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
AVFILTER_DEFINE_CLASS(codecview)
static const AVOption codecview_options[]