> Sorry if I missed something: > What is green metadata? Greenmetadata is a set of metrics specified in ISO/IEC 23001-11.
They are used to predict the decoding complexity (in terms of cycles) of AVC frames. It is useful to perform DVFS (ie: CPU frequency scaling) in order to reduce decoder power consumption. By the way, I'm not sure the patch was correctly attached. I'm trying one more time to attach it. Nicolas DEROUINEAU Research Engineer VITEC T. +33 1 46 73 06 06 E. nicolas.derouin...@vitec.com W. www.vitec.com ________________________________________ De : ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> de la part de Carl Eugen Hoyos <ceho...@ag.or.at> Envoyé : mercredi 23 décembre 2015 12:38 À : ffmpeg-devel@ffmpeg.org Objet : Re: [FFmpeg-devel] [PATCH] Adding frame side data about green metadata Nicolas Derouineau <nicolas.derouineau <at> vitec.com> writes: > Please find here enclosed a patch adding frame > side data information about green metadata. Sorry if I missed something: What is green metadata? Carl Eugen _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
From c2959f8482065dc400d2e09002363fc8295d5400 Mon Sep 17 00:00:00 2001 From: Nicolas DEROUINEAU <nicolas.derouin...@vitec.com> Date: Wed, 23 Dec 2015 12:19:03 +0100 Subject: [PATCH 2/2] Adding frame side data about green metadata - second part --- libavcodec/h264.c | 12 ++++++++++++ libavcodec/h264.h | 2 ++ libavcodec/h264_sei.c | 3 +++ libavutil/Makefile | 2 ++ libavutil/frame.h | 7 +++++++ libavutil/greenmetadata.c | 23 +++++++++++++++++++++++ libavutil/greenmetadata.h | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 87 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 089a86f..7b28dd2 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -29,6 +29,7 @@ #include "libavutil/avassert.h" #include "libavutil/display.h" +#include "libavutil/greenmetadata.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/stereo3d.h" @@ -879,6 +880,17 @@ static void decode_postinit(H264Context *h, int setup_finished) } } + if ( h->sei_green_metadata_present){ + AVFrameSideData *Greenmd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_GREENMD, + sizeof(GreenMetaData)); + + if(Greenmd){ + av_greenmetadata_set((uint8_t *)Greenmd->data, h->sei_green_metadata); + av_freep(&h->sei_green_metadata); + h->sei_green_metadata_present = 0; + } + } + if (h->sei_reguserdata_afd_present) { AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, sizeof(uint8_t)); diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 5d9aecd..e6eb7c8 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -839,8 +839,10 @@ typedef struct H264Context { qpel_mc_func (*qpel_avg)[16]; /*Green Metadata */ + int sei_green_metadata_present; GreenMetaData sei_green_metadata; + } H264Context; extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1]; ///< One chroma qp table for each possible bit depth (8-14). diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 0411b87..1ced948 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -43,6 +43,7 @@ void ff_h264_reset_sei(H264Context *h) h->sei_frame_packing_present = 0; h->sei_display_orientation_present = 0; h->sei_reguserdata_afd_present = 0; + h->sei_green_metadata_present = 0 ; h->a53_caption_size = 0; av_freep(&h->a53_caption); @@ -401,6 +402,8 @@ static int decode_GreenMetadata(H264Context *h) (float)h->sei_green_metadata.percent_six_tap_filtering/255, (float)h->sei_green_metadata.percent_alpha_point_deblocking_instance/255); + h->sei_green_metadata_present=1; + }else if( h->sei_green_metadata.green_metadata_type==1){ h->sei_green_metadata.xsd_metric_type=get_bits(&h->gb, 8); h->sei_green_metadata.xsd_metric_value=get_bits(&h->gb, 16); diff --git a/libavutil/Makefile b/libavutil/Makefile index bf8c713..c3cae53 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -29,6 +29,7 @@ HEADERS = adler32.h \ fifo.h \ file.h \ frame.h \ + greenmetadata.h \ hash.h \ hmac.h \ imgutils.h \ @@ -105,6 +106,7 @@ OBJS = adler32.o \ float_dsp.o \ fixed_dsp.o \ frame.o \ + greenmetadata.o \ hash.o \ hmac.o \ imgutils.o \ diff --git a/libavutil/frame.h b/libavutil/frame.h index 9c6061a..a6a7fa7 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -112,6 +112,13 @@ enum AVFrameSideDataType { * enum AVAudioServiceType defined in avcodec.h. */ AV_FRAME_DATA_AUDIO_SERVICE_TYPE, + + /** + * This side data must be associated with an video frame and corresponds to + * enum GreenMDataType defined in avcodec.h. The green metadata specicification + * is given in ISO/IEC 23001. + */ + AV_FRAME_DATA_GREENMD, }; enum AVActiveFormatDescription { diff --git a/libavutil/greenmetadata.c b/libavutil/greenmetadata.c index e69de29..9e448c8 100644 --- a/libavutil/greenmetadata.c +++ b/libavutil/greenmetadata.c @@ -0,0 +1,23 @@ +#include <libavutil/greenmetadata.h> + +void av_greenmetadata_set(uint8_t allocated_md[sizeof(GreenMetaData)], + GreenMetaData GreenInfo) +{ + memset(allocated_md, 0, sizeof(GreenMetaData)); + + allocated_md[0]=GreenInfo.green_metadata_type; + allocated_md[1]=GreenInfo.period_type; + allocated_md[2]=(uint8_t)(GreenInfo.num_seconds>>8); + allocated_md[3]=(uint8_t)(GreenInfo.num_seconds&0xFF); + allocated_md[4]=(uint8_t)(GreenInfo.num_pictures>>8); + allocated_md[5]=(uint8_t)(GreenInfo.num_pictures&0xFF); + allocated_md[6]=GreenInfo.percent_non_zero_macroblocks; + allocated_md[7]=GreenInfo.percent_intra_coded_macroblocks; + allocated_md[8]=GreenInfo.percent_six_tap_filtering; + allocated_md[9]=GreenInfo.percent_alpha_point_deblocking_instance; + allocated_md[10]=GreenInfo.xsd_metric_type; + allocated_md[11]=(uint8_t)(GreenInfo.xsd_metric_value>>8); + allocated_md[12]=(uint8_t)(GreenInfo.xsd_metric_value&0xFF); + + return; +} diff --git a/libavutil/greenmetadata.h b/libavutil/greenmetadata.h index e69de29..7b383e7 100644 --- a/libavutil/greenmetadata.h +++ b/libavutil/greenmetadata.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 Nicolas DEROUINEAU <nicolas.derouin...@vitec.com> + * + * 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 + */ + +#ifndef AVUTIL_GREENMD_H +#define AVUTIL_GREENMD_H + +#include <stdint.h> +#include <libavcodec/h264.h> +#include <string.h> + +/** + * Initialize a metadata structure containing frame information concerning its decoding complexity + * + * @param an allocated metadata structure (will be fully overwritten + * by this function) + * @param GreenMetadataInformation. + */ + +void av_greenmetadata_set(uint8_t allocated_md[sizeof(GreenMetaData)], GreenMetaData GreenInfo); + +#endif /* AVUTIL_GREENMD_H */ -- 1.9.1
From 082065e3f9950d4475d20fc4613eaddb6bc66b1a Mon Sep 17 00:00:00 2001 From: Nicolas DEROUINEAU <nicolas.derouin...@vitec.com> Date: Wed, 23 Dec 2015 12:15:17 +0100 Subject: [PATCH 1/2] Adding frame side data about green metadata --- libavutil/greenmetadata.c | 0 libavutil/greenmetadata.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 libavutil/greenmetadata.c create mode 100644 libavutil/greenmetadata.h diff --git a/libavutil/greenmetadata.c b/libavutil/greenmetadata.c new file mode 100644 index 0000000..e69de29 diff --git a/libavutil/greenmetadata.h b/libavutil/greenmetadata.h new file mode 100644 index 0000000..e69de29 -- 1.9.1
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel