2011-08-18 19:19:55 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 Stefano Sabatini
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
2011-10-27 23:16:24 +03:00
|
|
|
* filter for showing textual audio frame information
|
2011-08-18 19:19:55 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libavutil/adler32.h"
|
|
|
|
#include "libavutil/audioconvert.h"
|
2012-02-09 21:30:26 +03:00
|
|
|
#include "libavutil/timestamp.h"
|
2012-05-12 18:58:14 +03:00
|
|
|
#include "audio.h"
|
2011-08-18 19:19:55 +03:00
|
|
|
#include "avfilter.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int frame;
|
|
|
|
} ShowInfoContext;
|
|
|
|
|
2012-06-27 00:27:59 +03:00
|
|
|
static av_cold int init(AVFilterContext *ctx, const char *args)
|
2011-08-18 19:19:55 +03:00
|
|
|
{
|
|
|
|
ShowInfoContext *showinfo = ctx->priv;
|
|
|
|
showinfo->frame = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-09 23:10:38 +03:00
|
|
|
static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
|
2011-08-18 19:19:55 +03:00
|
|
|
{
|
|
|
|
AVFilterContext *ctx = inlink->dst;
|
|
|
|
ShowInfoContext *showinfo = ctx->priv;
|
|
|
|
uint32_t plane_checksum[8] = {0}, checksum = 0;
|
|
|
|
char chlayout_str[128];
|
|
|
|
int plane;
|
2011-10-16 01:44:22 +03:00
|
|
|
int linesize =
|
|
|
|
samplesref->audio->nb_samples *
|
|
|
|
av_get_bytes_per_sample(samplesref->format);
|
2012-05-12 18:38:47 +03:00
|
|
|
if (!av_sample_fmt_is_planar(samplesref->format))
|
2011-10-16 02:49:20 +03:00
|
|
|
linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout);
|
2011-08-18 19:19:55 +03:00
|
|
|
|
2012-09-30 21:58:01 +03:00
|
|
|
for (plane = 0; plane < 8 && samplesref->data[plane]; plane++) {
|
2011-08-18 19:19:55 +03:00
|
|
|
uint8_t *data = samplesref->data[plane];
|
|
|
|
|
|
|
|
plane_checksum[plane] = av_adler32_update(plane_checksum[plane],
|
|
|
|
data, linesize);
|
|
|
|
checksum = av_adler32_update(checksum, data, linesize);
|
|
|
|
}
|
|
|
|
|
|
|
|
av_get_channel_layout_string(chlayout_str, sizeof(chlayout_str), -1,
|
|
|
|
samplesref->audio->channel_layout);
|
|
|
|
|
|
|
|
av_log(ctx, AV_LOG_INFO,
|
2012-02-09 21:30:26 +03:00
|
|
|
"n:%d pts:%s pts_time:%s pos:%"PRId64" "
|
2012-05-12 18:38:47 +03:00
|
|
|
"fmt:%s chlayout:%s nb_samples:%d rate:%d "
|
2012-02-10 01:59:16 +03:00
|
|
|
"checksum:%08X plane_checksum[%08X",
|
2011-08-18 19:19:55 +03:00
|
|
|
showinfo->frame,
|
2012-02-09 21:30:26 +03:00
|
|
|
av_ts2str(samplesref->pts), av_ts2timestr(samplesref->pts, &inlink->time_base),
|
2011-08-18 19:19:55 +03:00
|
|
|
samplesref->pos,
|
|
|
|
av_get_sample_fmt_name(samplesref->format),
|
|
|
|
chlayout_str,
|
|
|
|
samplesref->audio->nb_samples,
|
|
|
|
samplesref->audio->sample_rate,
|
|
|
|
checksum,
|
2012-02-10 01:59:16 +03:00
|
|
|
plane_checksum[0]);
|
2011-08-18 19:19:55 +03:00
|
|
|
|
2012-09-30 21:58:01 +03:00
|
|
|
for (plane = 1; plane < 8 && samplesref->data[plane]; plane++)
|
2012-02-10 01:59:16 +03:00
|
|
|
av_log(ctx, AV_LOG_INFO, " %08X", plane_checksum[plane]);
|
|
|
|
av_log(ctx, AV_LOG_INFO, "]\n");
|
2011-08-18 19:19:55 +03:00
|
|
|
|
2012-02-10 01:59:16 +03:00
|
|
|
showinfo->frame++;
|
2012-07-09 23:10:38 +03:00
|
|
|
return ff_filter_samples(inlink->dst->outputs[0], samplesref);
|
2011-08-18 19:19:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
AVFilter avfilter_af_ashowinfo = {
|
|
|
|
.name = "ashowinfo",
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Show textual information for each audio frame."),
|
|
|
|
|
|
|
|
.priv_size = sizeof(ShowInfoContext),
|
|
|
|
.init = init,
|
|
|
|
|
2011-11-05 16:39:24 +03:00
|
|
|
.inputs = (const AVFilterPad[]) {{ .name = "default",
|
2011-08-18 19:19:55 +03:00
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
2012-05-10 23:41:29 +03:00
|
|
|
.get_audio_buffer = ff_null_get_audio_buffer,
|
2011-08-18 19:19:55 +03:00
|
|
|
.filter_samples = filter_samples,
|
|
|
|
.min_perms = AV_PERM_READ, },
|
|
|
|
{ .name = NULL}},
|
|
|
|
|
2011-11-05 16:39:24 +03:00
|
|
|
.outputs = (const AVFilterPad[]) {{ .name = "default",
|
2011-08-18 19:19:55 +03:00
|
|
|
.type = AVMEDIA_TYPE_AUDIO },
|
|
|
|
{ .name = NULL}},
|
|
|
|
};
|