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 "libavutil/timestamp.h"
00029 #include "audio.h"
00030 #include "avfilter.h"
00031
00032 typedef struct {
00033 unsigned int frame;
00034 } ShowInfoContext;
00035
00036 static av_cold int init(AVFilterContext *ctx, const char *args)
00037 {
00038 ShowInfoContext *showinfo = ctx->priv;
00039 showinfo->frame = 0;
00040 return 0;
00041 }
00042
00043 static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
00044 {
00045 AVFilterContext *ctx = inlink->dst;
00046 ShowInfoContext *showinfo = ctx->priv;
00047 uint32_t plane_checksum[8] = {0}, checksum = 0;
00048 char chlayout_str[128];
00049 int plane;
00050 int linesize =
00051 samplesref->audio->nb_samples *
00052 av_get_bytes_per_sample(samplesref->format);
00053 if (!av_sample_fmt_is_planar(samplesref->format))
00054 linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout);
00055
00056 for (plane = 0; samplesref->data[plane] && plane < 8; plane++) {
00057 uint8_t *data = samplesref->data[plane];
00058
00059 plane_checksum[plane] = av_adler32_update(plane_checksum[plane],
00060 data, linesize);
00061 checksum = av_adler32_update(checksum, data, linesize);
00062 }
00063
00064 av_get_channel_layout_string(chlayout_str, sizeof(chlayout_str), -1,
00065 samplesref->audio->channel_layout);
00066
00067 av_log(ctx, AV_LOG_INFO,
00068 "n:%d pts:%s pts_time:%s pos:%"PRId64" "
00069 "fmt:%s chlayout:%s nb_samples:%d rate:%d "
00070 "checksum:%08X plane_checksum[%08X",
00071 showinfo->frame,
00072 av_ts2str(samplesref->pts), av_ts2timestr(samplesref->pts, &inlink->time_base),
00073 samplesref->pos,
00074 av_get_sample_fmt_name(samplesref->format),
00075 chlayout_str,
00076 samplesref->audio->nb_samples,
00077 samplesref->audio->sample_rate,
00078 checksum,
00079 plane_checksum[0]);
00080
00081 for (plane = 1; samplesref->data[plane] && plane < 8; plane++)
00082 av_log(ctx, AV_LOG_INFO, " %08X", plane_checksum[plane]);
00083 av_log(ctx, AV_LOG_INFO, "]\n");
00084
00085 showinfo->frame++;
00086 return ff_filter_samples(inlink->dst->outputs[0], samplesref);
00087 }
00088
00089 AVFilter avfilter_af_ashowinfo = {
00090 .name = "ashowinfo",
00091 .description = NULL_IF_CONFIG_SMALL("Show textual information for each audio frame."),
00092
00093 .priv_size = sizeof(ShowInfoContext),
00094 .init = init,
00095
00096 .inputs = (const AVFilterPad[]) {{ .name = "default",
00097 .type = AVMEDIA_TYPE_AUDIO,
00098 .get_audio_buffer = ff_null_get_audio_buffer,
00099 .filter_samples = filter_samples,
00100 .min_perms = AV_PERM_READ, },
00101 { .name = NULL}},
00102
00103 .outputs = (const AVFilterPad[]) {{ .name = "default",
00104 .type = AVMEDIA_TYPE_AUDIO },
00105 { .name = NULL}},
00106 };