• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavfilter/af_ashowinfo.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011 Stefano Sabatini
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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) /* packed layout */
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 };
Generated on Fri Feb 1 2013 14:34:48 for FFmpeg by doxygen 1.7.1