00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #include "libavutil/adler32.h"
00027 #include "libavutil/audioconvert.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 filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
00042 {
00043 AVFilterContext *ctx = inlink->dst;
00044 ShowInfoContext *showinfo = ctx->priv;
00045 uint32_t plane_checksum[8] = {0}, checksum = 0;
00046 char chlayout_str[128];
00047 int plane;
00048 int linesize =
00049 samplesref->audio->nb_samples *
00050 av_get_bytes_per_sample(samplesref->format);
00051 if (!samplesref->audio->planar)
00052 linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout);
00053
00054 for (plane = 0; samplesref->data[plane] && plane < 8; plane++) {
00055 uint8_t *data = samplesref->data[plane];
00056
00057 plane_checksum[plane] = av_adler32_update(plane_checksum[plane],
00058 data, linesize);
00059 checksum = av_adler32_update(checksum, data, linesize);
00060 }
00061
00062 av_get_channel_layout_string(chlayout_str, sizeof(chlayout_str), -1,
00063 samplesref->audio->channel_layout);
00064
00065 av_log(ctx, AV_LOG_INFO,
00066 "n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
00067 "fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d "
00068 "checksum:%08X plane_checksum[%08X %08X %08X %08X %08X %08X %08X %08X]\n",
00069 showinfo->frame,
00070 samplesref->pts, samplesref->pts * av_q2d(inlink->time_base),
00071 samplesref->pos,
00072 av_get_sample_fmt_name(samplesref->format),
00073 chlayout_str,
00074 samplesref->audio->nb_samples,
00075 samplesref->audio->sample_rate,
00076 samplesref->audio->planar,
00077 checksum,
00078 plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3],
00079 plane_checksum[4], plane_checksum[5], plane_checksum[6], plane_checksum[7]);
00080
00081 showinfo->frame++;
00082
00083 avfilter_filter_samples(inlink->dst->outputs[0], samplesref);
00084 }
00085
00086 AVFilter avfilter_af_ashowinfo = {
00087 .name = "ashowinfo",
00088 .description = NULL_IF_CONFIG_SMALL("Show textual information for each audio frame."),
00089
00090 .priv_size = sizeof(ShowInfoContext),
00091 .init = init,
00092
00093 .inputs = (const AVFilterPad[]) {{ .name = "default",
00094 .type = AVMEDIA_TYPE_AUDIO,
00095 .get_audio_buffer = avfilter_null_get_audio_buffer,
00096 .filter_samples = filter_samples,
00097 .min_perms = AV_PERM_READ, },
00098 { .name = NULL}},
00099
00100 .outputs = (const AVFilterPad[]) {{ .name = "default",
00101 .type = AVMEDIA_TYPE_AUDIO },
00102 { .name = NULL}},
00103 };