aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-07-08 20:13:14 +0000
committerPaul B Mahol <onemda@gmail.com>2013-07-08 20:13:56 +0000
commita03e79ed5a71f77819e5242f69c16d43429fab09 (patch)
treeb722ab7e8ebb65df609a4d7f4f0332e416b6430d
parent970c8df73528659925819dec31c4c8c0887f0321 (diff)
downloadffmpeg-a03e79ed5a71f77819e5242f69c16d43429fab09.tar.gz
lavfi: fix broken logic in metadata handling
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r--libavfilter/vf_bbox.c2
-rw-r--r--libavfilter/vf_cropdetect.c2
-rw-r--r--libavfilter/vf_psnr.c24
3 files changed, 18 insertions, 10 deletions
diff --git a/libavfilter/vf_bbox.c b/libavfilter/vf_bbox.c
index a5f0204a5c..a29627d4d4 100644
--- a/libavfilter/vf_bbox.c
+++ b/libavfilter/vf_bbox.c
@@ -62,7 +62,7 @@ static int query_formats(AVFilterContext *ctx)
#define SET_META(key, value) \
snprintf(buf, sizeof(buf), "%d", value); \
- av_dict_set(metadata, #key, buf, 0); \
+ av_dict_set(metadata, key, buf, 0);
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 68d683a4ad..184b769922 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -114,7 +114,7 @@ static int config_input(AVFilterLink *inlink)
#define SET_META(key, value) \
snprintf(buf, sizeof(buf), "%d", value); \
- av_dict_set(metadata, #key, buf, 0) \
+ av_dict_set(metadata, key, buf, 0)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 6b4fecb3cf..37bfde4c46 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -98,16 +98,24 @@ void compute_images_mse(const uint8_t *main_data[4], const int main_linesizes[4]
}
}
-#define SET_META(key, comp, value) \
- snprintf(buf, sizeof(buf), "%0.2f", value); \
- av_dict_set(metadata, #key #comp, buf, 0); \
+static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
+{
+ char value[128];
+ snprintf(value, sizeof(value), "%0.2f", d);
+ if (comp) {
+ char key2[128];
+ snprintf(key2, sizeof(key2), "%s%c", key, comp);
+ av_dict_set(metadata, key2, value, 0);
+ } else {
+ av_dict_set(metadata, key, value, 0);
+ }
+}
static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame *main,
const AVFrame *ref)
{
PSNRContext *s = ctx->priv;
double comp_mse[4], mse = 0;
- char buf[32];
int j, c;
AVDictionary **metadata = avpriv_frame_get_metadatap(main);
@@ -127,10 +135,10 @@ static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame *main,
for (j = 0; j < s->desc->nb_components; j++) {
c = s->is_rgb ? s->rgba_map[j] : j;
- SET_META("lavfi.psnr.mse.", s->comps[j], comp_mse[c]);
- SET_META("lavfi.psnr.mse_avg", "", mse);
- SET_META("lavfi.psnr.s.", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c]));
- SET_META("lavfi.psnr.s_avg", "", get_psnr(mse, 1, s->average_max));
+ set_meta(metadata, "lavfi.psnr.mse.", s->comps[j], comp_mse[c]);
+ set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse);
+ set_meta(metadata, "lavfi.psnr.s.", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c]));
+ set_meta(metadata, "lavfi.psnr.s_avg", 0, get_psnr(mse, 1, s->average_max));
}
if (s->stats_file) {