Go to the documentation of this file.
40 #define MV_P_FOR (1<<0)
41 #define MV_B_FOR (1<<1)
42 #define MV_B_BACK (1<<2)
43 #define MV_TYPE_FOR (1<<0)
44 #define MV_TYPE_BACK (1<<1)
45 #define FRAME_TYPE_I (1<<0)
46 #define FRAME_TYPE_P (1<<1)
47 #define FRAME_TYPE_B (1<<2)
59 #define OFFSET(x) offsetof(CodecViewContext, x)
60 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
61 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
65 CONST(
"pf",
"forward predicted MVs of P-frames",
MV_P_FOR,
"mv"),
66 CONST(
"bf",
"forward predicted MVs of B-frames",
MV_B_FOR,
"mv"),
67 CONST(
"bb",
"backward predicted MVs of B-frames",
MV_B_BACK,
"mv"),
84 static int clip_line(
int *sx,
int *sy,
int *ex,
int *ey,
int maxx)
92 *sy = *ey + (*sy - *ey) * (int64_t)*ex / (*ex - *sx);
99 *ey = *sy + (*ey - *sy) * (int64_t)(maxx - *sx) / (*ex - *sx);
112 static void draw_line(uint8_t *buf,
int sx,
int sy,
int ex,
int ey,
136 f = ((ey - sy) * (1 << 16)) / ex;
137 for (x = 0; x <= ex; x++) {
139 fr = (x *
f) & 0xFFFF;
140 buf[ y *
stride + x] += (
color * (0x10000 - fr)) >> 16;
141 if(fr) buf[(y + 1) *
stride + x] += (
color * fr ) >> 16;
151 f = ((ex - sx) * (1 << 16)) / ey;
154 for(y= 0; y <= ey; y++){
157 buf[y *
stride + x ] += (
color * (0x10000 - fr)) >> 16;
158 if(fr) buf[y *
stride + x + 1] += (
color * fr ) >> 16;
171 int ey,
int w,
int h,
int stride,
int color,
int tail,
int direction)
188 if (dx * dx + dy * dy > 3 * 3) {
191 int length = sqrt((rx * rx + ry * ry) << 8);
210 for (
int x = sx; x < sx +
w; x++)
213 for (
int y = sy; y < sy +
h; y++) {
219 for (
int x = sx; x < sx +
w; x++)
230 int qstride, qp_type,
ret;
243 uint8_t *pu =
frame->data[1];
245 const int lzu =
frame->linesize[1];
246 const int lzv =
frame->linesize[2];
248 for (y = 0; y <
h; y++) {
249 for (x = 0; x <
w; x++) {
250 const int qp =
ff_norm_qscale(qp_table[(y >> 3) * qstride + (x >> 3)], qp_type) * 128/31;
267 for (
int block_idx = 0; block_idx < par->
nb_blocks; block_idx++) {
277 if (
s->mv ||
s->mv_type) {
286 for (
i = 0;
i < sd->
size /
sizeof(*mvs);
i++) {
288 const int direction =
mv->source > 0;
291 const int is_fp = direction == 0 && (
s->mv_type &
MV_TYPE_FOR);
292 const int is_bp = direction == 1 && (
s->mv_type &
MV_TYPE_BACK);
294 if ((!
s->frame_type && (is_fp || is_bp)) ||
295 is_iframe && is_fp || is_iframe && is_bp ||
296 is_pframe && is_fp ||
297 is_bframe && is_fp || is_bframe && is_bp)
321 s->hsub =
desc->log2_chroma_w;
322 s->vsub =
desc->log2_chroma_h;
352 .priv_class = &codecview_class,
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).
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
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).
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)
static const int8_t mv[256][2]
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.
const char * name
Filter name.
A link between two filters.
#define CONST(name, help, val, unit)
static int clip_line(int *sx, int *sy, int *ex, int *ey, int maxx)
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,...
Video encoding parameters for a given frame.
A filter pad used for either input or output.
#define AV_CEIL_RSHIFT(a, b)
const AVFilter ff_vf_codecview
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const AVFilterPad codecview_inputs[]
Describe the class of an AVClass context structure.
#define ROUNDED_DIV(a, b)
@ AV_PICTURE_TYPE_I
Intra.
static void draw_block_rectangle(uint8_t *buf, int sx, int sy, int w, int h, int stride, int color)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVOption codecview_options[]
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
unsigned int nb_blocks
Number of blocks in the array.
AVFILTER_DEFINE_CLASS(codecview)
static const AVFilterPad codecview_outputs[]
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define i(width, name, range_min, range_max)
Data structure for storing block-level encoding information.
const char * name
Pad name.
#define FFSWAP(type, a, b)
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
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
@ AV_FRAME_DATA_VIDEO_ENC_PARAMS
Encoding parameters for a video frame, as described by AVVideoEncParams.
@ AV_PICTURE_TYPE_P
Predicted.
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,...
Structure to hold side data for an AVFrame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
The exact code depends on how similar the blocks are and how related they are to the block
@ AV_FRAME_DATA_MOTION_VECTORS
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
static int config_input(AVFilterLink *inlink)
static av_always_inline AVVideoBlockParams * av_video_enc_params_block(AVVideoEncParams *par, unsigned int idx)
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.