Please find here attached the updated patch with the suggested modifications.
Best regards, Nicolas DEROUINEAU ________________________________________ De : ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> de la part de Michael Niedermayer <mich...@niedermayer.cc> Envoyé : mercredi 23 décembre 2015 14:49 À : FFmpeg development discussions and patches Objet : Re: [FFmpeg-devel] [PATCH] Adding frame side data about green metadata On Wed, Dec 23, 2015 at 12:43:48PM +0000, Nicolas Derouineau wrote: > > 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. [...] > 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> libavutil should not include stuff from libavcodec also it would be "libavcodec/h264.h" not <libavcodec/h264.h> [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Breaking DRM is a little like attempting to break through a door even though the window is wide open and the only thing in the house is a bunch of things you dont want and which you would get tomorrow for free anyway
From 04e33840a5a9f16411527f6129ab9dcaee2e33ba Mon Sep 17 00:00:00 2001 From: Nicolas DEROUINEAU <nicolas.derouin...@vitec.com> Date: Thu, 24 Dec 2015 11:16:57 +0100 Subject: [PATCH] Add frame side data when SEI green metadata are detected --- libavcodec/h264.c | 21 +++++++++++++++++++++ libavcodec/h264.h | 1 + libavcodec/h264_sei.c | 3 +++ libavutil/frame.h | 8 ++++++++ 4 files changed, 33 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 089a86f..e90bcc0 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -879,6 +879,27 @@ 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) { + memset((uint8_t*)Greenmd->data, 0, sizeof(GreenMetaData)); + Greenmd->data[0] = h->sei_green_metadata.green_metadata_type; + Greenmd->data[1] = h->sei_green_metadata.period_type; + Greenmd->data[2] = (uint8_t)(h->sei_green_metadata.num_seconds>>8); + Greenmd->data[3] = (uint8_t)(h->sei_green_metadata.num_seconds&0xFF); + Greenmd->data[4] = (uint8_t)(h->sei_green_metadata.num_pictures>>8); + Greenmd->data[5] = (uint8_t)(h->sei_green_metadata.num_pictures&0xFF); + Greenmd->data[6] = h->sei_green_metadata.percent_non_zero_macroblocks; + Greenmd->data[7] = h->sei_green_metadata.percent_intra_coded_macroblocks; + Greenmd->data[8] = h->sei_green_metadata.percent_six_tap_filtering; + Greenmd->data[9] = h->sei_green_metadata.percent_alpha_point_deblocking_instance; + Greenmd->data[10] = h->sei_green_metadata.xsd_metric_type; + Greenmd->data[11] = (uint8_t)(h->sei_green_metadata.xsd_metric_value>>8); + Greenmd->data[12] = (uint8_t)(h->sei_green_metadata.xsd_metric_value&0xFF); + } + } + 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..51490d6 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -839,6 +839,7 @@ typedef struct H264Context { qpel_mc_func (*qpel_avg)[16]; /*Green Metadata */ + int sei_green_metadata_present; GreenMetaData sei_green_metadata; } H264Context; diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 0411b87..4a021b8 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); @@ -363,6 +364,8 @@ static int decode_GreenMetadata(H264Context *h) if (h->avctx->debug & FF_DEBUG_GREEN_MD) av_log(h->avctx, AV_LOG_DEBUG, "Green Metadata Info SEI message\n"); + h->sei_green_metadata_present = 1; + h->sei_green_metadata.green_metadata_type=get_bits(&h->gb, 8); if (h->avctx->debug & FF_DEBUG_GREEN_MD) diff --git a/libavutil/frame.h b/libavutil/frame.h index 9c6061a..89a57ad 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -112,6 +112,14 @@ enum AVFrameSideDataType { * enum AVAudioServiceType defined in avcodec.h. */ AV_FRAME_DATA_AUDIO_SERVICE_TYPE, + + + /** + * This side data must be associated with a video frame and corresponds to + * struct GreenMDataType defined in avcodec.h. The green metadata specification + * is given in ISO/IEC 23001. + */ + AV_FRAME_DATA_GREENMD, }; enum AVActiveFormatDescription { -- 1.9.1
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel