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/internal.h"
00028 #include "libavutil/pixdesc.h"
00029 #include "libavutil/timestamp.h"
00030 #include "avfilter.h"
00031 #include "internal.h"
00032 #include "video.h"
00033
00034 typedef struct {
00035 unsigned int frame;
00036 } ShowInfoContext;
00037
00038 static av_cold int init(AVFilterContext *ctx, const char *args)
00039 {
00040 ShowInfoContext *showinfo = ctx->priv;
00041 showinfo->frame = 0;
00042 return 0;
00043 }
00044
00045 static int end_frame(AVFilterLink *inlink)
00046 {
00047 AVFilterContext *ctx = inlink->dst;
00048 ShowInfoContext *showinfo = ctx->priv;
00049 AVFilterBufferRef *picref = inlink->cur_buf;
00050 uint32_t plane_checksum[4] = {0}, checksum = 0;
00051 int i, plane, vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
00052
00053 for (plane = 0; picref->data[plane] && plane < 4; plane++) {
00054 size_t linesize = av_image_get_linesize(picref->format, picref->video->w, plane);
00055 uint8_t *data = picref->data[plane];
00056 int h = plane == 1 || plane == 2 ? inlink->h >> vsub : inlink->h;
00057
00058 for (i = 0; i < h; i++) {
00059 plane_checksum[plane] = av_adler32_update(plane_checksum[plane], data, linesize);
00060 checksum = av_adler32_update(checksum, data, linesize);
00061 data += picref->linesize[plane];
00062 }
00063 }
00064
00065 av_log(ctx, AV_LOG_INFO,
00066 "n:%d pts:%s pts_time:%s pos:%"PRId64" "
00067 "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
00068 "checksum:%08X plane_checksum:[%08X",
00069 showinfo->frame,
00070 av_ts2str(picref->pts), av_ts2timestr(picref->pts, &inlink->time_base), picref->pos,
00071 av_pix_fmt_descriptors[picref->format].name,
00072 picref->video->sample_aspect_ratio.num, picref->video->sample_aspect_ratio.den,
00073 picref->video->w, picref->video->h,
00074 !picref->video->interlaced ? 'P' :
00075 picref->video->top_field_first ? 'T' : 'B',
00076 picref->video->key_frame,
00077 av_get_picture_type_char(picref->video->pict_type),
00078 checksum, plane_checksum[0]);
00079
00080 for (plane = 1; picref->data[plane] && plane < 4; plane++)
00081 av_log(ctx, AV_LOG_INFO, " %08X", plane_checksum[plane]);
00082 av_log(ctx, AV_LOG_INFO, "]\n");
00083
00084 showinfo->frame++;
00085 return ff_end_frame(inlink->dst->outputs[0]);
00086 }
00087
00088 AVFilter avfilter_vf_showinfo = {
00089 .name = "showinfo",
00090 .description = NULL_IF_CONFIG_SMALL("Show textual information for each video frame."),
00091
00092 .priv_size = sizeof(ShowInfoContext),
00093 .init = init,
00094
00095 .inputs = (const AVFilterPad[]) {{ .name = "default",
00096 .type = AVMEDIA_TYPE_VIDEO,
00097 .get_video_buffer = ff_null_get_video_buffer,
00098 .start_frame = ff_null_start_frame,
00099 .end_frame = end_frame,
00100 .min_perms = AV_PERM_READ, },
00101 { .name = NULL}},
00102
00103 .outputs = (const AVFilterPad[]) {{ .name = "default",
00104 .type = AVMEDIA_TYPE_VIDEO },
00105 { .name = NULL}},
00106 };