00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00025 #include "libavutil/adler32.h"
00026 #include "libavutil/imgutils.h"
00027 #include "libavutil/pixdesc.h"
00028 #include "avfilter.h"
00029
00030 typedef struct {
00031 unsigned int frame;
00032 } ShowInfoContext;
00033
00034 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
00035 {
00036 ShowInfoContext *showinfo = ctx->priv;
00037 showinfo->frame = 0;
00038 return 0;
00039 }
00040
00041 static void end_frame(AVFilterLink *inlink)
00042 {
00043 AVFilterContext *ctx = inlink->dst;
00044 ShowInfoContext *showinfo = ctx->priv;
00045 AVFilterBufferRef *picref = inlink->cur_buf;
00046 uint32_t plane_checksum[4] = {0}, checksum = 0;
00047 int i, plane, vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
00048
00049 for (plane = 0; picref->data[plane] && plane < 4; plane++) {
00050 size_t linesize = av_image_get_linesize(picref->format, picref->video->w, plane);
00051 uint8_t *data = picref->data[plane];
00052 int h = plane == 1 || plane == 2 ? inlink->h >> vsub : inlink->h;
00053
00054 for (i = 0; i < h; i++) {
00055 plane_checksum[plane] = av_adler32_update(plane_checksum[plane], data, linesize);
00056 checksum = av_adler32_update(checksum, data, linesize);
00057 data += picref->linesize[plane];
00058 }
00059 }
00060
00061 av_log(ctx, AV_LOG_INFO,
00062 "n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
00063 "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
00064 "checksum:%08X plane_checksum:[%08X %08X %08X %08X]\n",
00065 showinfo->frame,
00066 picref->pts, picref ->pts * av_q2d(inlink->time_base), picref->pos,
00067 av_pix_fmt_descriptors[picref->format].name,
00068 picref->video->sample_aspect_ratio.num, picref->video->sample_aspect_ratio.den,
00069 picref->video->w, picref->video->h,
00070 !picref->video->interlaced ? 'P' :
00071 picref->video->top_field_first ? 'T' : 'B',
00072 picref->video->key_frame,
00073 av_get_picture_type_char(picref->video->pict_type),
00074 checksum, plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3]);
00075
00076 showinfo->frame++;
00077 avfilter_end_frame(inlink->dst->outputs[0]);
00078 }
00079
00080 AVFilter avfilter_vf_showinfo = {
00081 .name = "showinfo",
00082 .description = NULL_IF_CONFIG_SMALL("Show textual information for each video frame."),
00083
00084 .priv_size = sizeof(ShowInfoContext),
00085 .init = init,
00086
00087 .inputs = (const AVFilterPad[]) {{ .name = "default",
00088 .type = AVMEDIA_TYPE_VIDEO,
00089 .get_video_buffer = avfilter_null_get_video_buffer,
00090 .start_frame = avfilter_null_start_frame,
00091 .end_frame = end_frame,
00092 .min_perms = AV_PERM_READ, },
00093 { .name = NULL}},
00094
00095 .outputs = (const AVFilterPad[]) {{ .name = "default",
00096 .type = AVMEDIA_TYPE_VIDEO },
00097 { .name = NULL}},
00098 };