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 "libavutil/timestamp.h"
00029 #include "avfilter.h"
00030 #include "internal.h"
00031 #include "video.h"
00032
00033 typedef struct {
00034 unsigned int frame;
00035 } ShowInfoContext;
00036
00037 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
00038 {
00039 ShowInfoContext *showinfo = ctx->priv;
00040 showinfo->frame = 0;
00041 return 0;
00042 }
00043
00044 static void end_frame(AVFilterLink *inlink)
00045 {
00046 AVFilterContext *ctx = inlink->dst;
00047 ShowInfoContext *showinfo = ctx->priv;
00048 AVFilterBufferRef *picref = inlink->cur_buf;
00049 uint32_t plane_checksum[4] = {0}, checksum = 0;
00050 int i, plane, vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
00051
00052 for (plane = 0; picref->data[plane] && plane < 4; plane++) {
00053 size_t linesize = av_image_get_linesize(picref->format, picref->video->w, plane);
00054 uint8_t *data = picref->data[plane];
00055 int h = plane == 1 || plane == 2 ? inlink->h >> vsub : inlink->h;
00056
00057 for (i = 0; i < h; i++) {
00058 plane_checksum[plane] = av_adler32_update(plane_checksum[plane], data, linesize);
00059 checksum = av_adler32_update(checksum, data, linesize);
00060 data += picref->linesize[plane];
00061 }
00062 }
00063
00064 av_log(ctx, AV_LOG_INFO,
00065 "n:%d pts:%s pts_time:%s pos:%"PRId64" "
00066 "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
00067 "checksum:%08X plane_checksum:[%08X",
00068 showinfo->frame,
00069 av_ts2str(picref->pts), av_ts2timestr(picref->pts, &inlink->time_base), picref->pos,
00070 av_pix_fmt_descriptors[picref->format].name,
00071 picref->video->sample_aspect_ratio.num, picref->video->sample_aspect_ratio.den,
00072 picref->video->w, picref->video->h,
00073 !picref->video->interlaced ? 'P' :
00074 picref->video->top_field_first ? 'T' : 'B',
00075 picref->video->key_frame,
00076 av_get_picture_type_char(picref->video->pict_type),
00077 checksum, plane_checksum[0]);
00078
00079 for (plane = 1; picref->data[plane] && plane < 4; plane++)
00080 av_log(ctx, AV_LOG_INFO, " %08X", plane_checksum[plane]);
00081 av_log(ctx, AV_LOG_INFO, "]\n");
00082
00083 showinfo->frame++;
00084 avfilter_unref_buffer(picref);
00085 avfilter_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_keep_ref,
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 };