62 #define OFFSET(x) offsetof(PSNRContext, x) 63 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 82 return 10.0 * log10(
pow_2(max) / (mse / nb_frames));
90 for (j = 0; j < outw; j++)
91 m2 +=
pow_2(main_line[j] - ref_line[j]);
100 const uint16_t *main_line = (
const uint16_t *) _main_line;
101 const uint16_t *ref_line = (
const uint16_t *) _ref_line;
103 for (j = 0; j < outw; j++)
104 m2 +=
pow_2(main_line[j] - ref_line[j]);
112 int main_linesize[4];
123 int jobnr,
int nb_jobs)
131 const int slice_start = (outh * jobnr) / nb_jobs;
132 const int slice_end = (outh * (jobnr+1)) / nb_jobs;
140 ref_line += ref_linesize;
141 main_line += main_linesize;
152 snprintf(value,
sizeof(value),
"%f", d);
155 snprintf(key2,
sizeof(key2),
"%s%c", key, comp);
167 double comp_mse[4],
mse = 0.;
168 uint64_t comp_sum[4] = { 0 };
216 set_meta(metadata,
"lavfi.psnr.mse.", s->
comps[j], comp_mse[c]);
219 set_meta(metadata,
"lavfi.psnr.mse_avg", 0, mse);
224 fprintf(s->
stats_file,
"psnr_log_version:2 fields:n");
276 "stats_add_max was specified but stats_version < 2.\n" );
302 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf 303 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf 304 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf) 394 outlink->
w = mainlink->
w;
395 outlink->
h = mainlink->
h;
406 av_log(ctx,
AV_LOG_WARNING,
"not matching timebases found between first input: %d/%d and second input %d/%d, results may be incorrect!\n",
473 .preinit = psnr_framesync_preinit,
479 .priv_class = &psnr_class,
const uint8_t * ref_data[4]
static int activate(AVFilterContext *ctx)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_GBRAP10
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
uint64_t(* sse_line)(const uint8_t *buf, const uint8_t *ref, int w)
int h
agreed upon image height
#define AV_PIX_FMT_GBRP10
static uint64_t sse_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
int is_disabled
the enabled state from the last expression evaluation
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
#define AV_PIX_FMT_GRAY10
const char * name
Pad name.
AVFilterContext * parent
Parent filter context.
#define AV_PIX_FMT_GRAY12
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
FRAMESYNC_DEFINE_CLASS(psnr, PSNRContext, fs)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
static double get_psnr(double mse, uint64_t nb_frames, int max)
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
GLsizei GLboolean const GLfloat * value
static double psnr(double d)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
AVDictionary * metadata
metadata.
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int config_input_ref(AVFilterLink *inlink)
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
#define AV_PIX_FMT_GBRAP12
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
static av_cold void uninit(AVFilterContext *ctx)
#define AV_PIX_FMT_GBRAP16
int w
agreed upon image width
uint8_t nb_components
The number of components each pixel has, (1-4)
#define AV_PIX_FMT_GBRP16
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
#define AV_PIX_FMT_GRAY16
static unsigned pow_2(unsigned base)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
static int config_output(AVFilterLink *outlink)
AVRational time_base
Time base for the output events.
static av_cold int init(AVFilterContext *ctx)
AVFilterContext * src
source filter
#define AV_PIX_FMT_GBRP14
static const AVFilterPad outputs[]
int format
agreed upon media format
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
#define AV_LOG_INFO
Standard information.
Used for passing data between threads.
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...
#define AV_PIX_FMT_GRAY14
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
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_GBRP12
#define flags(name, subs,...)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
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 psnr_inputs[]
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static int ref[MAX_W *MAX_W]
planar GBRA 4:4:4:4 32bpp
static int compute_images_mse(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static const AVFilterPad psnr_outputs[]
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static const AVOption psnr_options[]
avfilter_execute_func * execute
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static int query_formats(AVFilterContext *ctx)
AVFilterContext * dst
dest filter
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
const uint8_t * main_data[4]
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp)
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
int depth
Number of bits in the component.
static int do_psnr(FFFrameSync *fs)
AVPixelFormat
Pixel format.
#define AV_CEIL_RSHIFT(a, b)