[FFmpeg-devel] Patch to parse H264 SEI Green Metadata

Nicolas Derouineau nicolas.derouineau at vitec.com
Tue Jun 30 11:38:03 CEST 2015


Hello, 
Thanks for your comments. Here's an updated version of the patch.
Did you have any troubles opening the bitstreams ?

BR,



Nicolas DEROUINEAU
Research Engineer
VITEC

T.  +33 1 46 73 06 06
E.  nicolas.derouineau at vitec.com
W. www.vitec.com

________________________________________
De : Michael Niedermayer <michaelni at gmx.at>
Envoyé : lundi 29 juin 2015 15:49
À : FFmpeg development discussions and patches; Nicolas Derouineau
Cc : Nicolas Tizon; Erwan Raffin; Didier Nicholson; Yahia Benmoussa
Objet : Re: [FFmpeg-devel] Patch to parse H264 SEI Green Metadata

Hi

On Mon, Jun 29, 2015 at 01:01:48PM +0000, Nicolas Derouineau wrote:
> Two patches are now here enclosed:
>
> The first one enable metadata parsing. The second one add a new options in the file avcodec/options_table.h
>
> Tested with:
>
> ./ffplay -debug green_metadata ~/GreenMetaDataSEI.264

Where can we find the sample file ?


>
> Best Regards,
>
> Nicolas DEROUINEAU
> Research Engineer
> VITEC
>
> T.  +33 1 46 73 06 06
> E.  nicolas.derouineau at vitec.com
> W. www.vitec.com
>
> ________________________________________
> De : ffmpeg-devel-bounces at ffmpeg.org <ffmpeg-devel-bounces at ffmpeg.org> de la part de Nicolas Derouineau <nicolas.derouineau at vitec.com>
> Envoyé : lundi 29 juin 2015 14:20
> À : FFmpeg development discussions and patches
> Objet : Re: [FFmpeg-devel] Patch to parse H264 SEI Green Metadata
>
> Hello,
> Thank you for your comments.
>
> Please find enclosed the updated patch.
>
> I have tested it with the following cmdline:
>
> ./ffplay -debug 1048576 ~/GreenMetaDataSEI.264
>
> I know that this debug flag should be define somewhere as a string in order to display it with:
>
> ./ffplay --help
>
> Could someone point me to the correct location to do this ?
>
> Ps: Reference Bitstreams are still available here: ftp-public-greenvideo.insa-rennes.fr
>
> Ps 2: This message may look like a duplicate, but I have been experiencing issues to subscribe to the mailing list.
>
>
>
> Best regards,
> Nicolas DEROUINEAU
> Research Engineer
> VITEC
>
> T.  +33 1 46 73 06 06
> E.  nicolas.derouineau at vitec.com
> W. www.vitec.com
>
> ________________________________________
> De : Vittorio Giovara <vittorio.giovara at gmail.com>
> Envoyé : vendredi 26 juin 2015 02:56
> À : FFmpeg development discussions and patches
> Cc : Nicolas Derouineau; Yahia Benmoussa; Erwan Raffin; michaelni at gmx.at; Didier Nicholson; Nicolas Tizon
> Objet : Re: [FFmpeg-devel] Patch to parse H264 SEI Green Metadata
>
> On Thu, Jun 25, 2015 at 5:30 PM, Michael Niedermayer
> <michael at niedermayer.cc> wrote:
> > On Thu, Jun 25, 2015 at 11:13:53AM +0000, Nicolas Derouineau wrote:
> >> Hello,
> >> Please find here enclosed a patch enabling h264 Green Metada SEI parsing for FFMPEG. You'll be able to find reference bitstreams containing the metadata at the following adress:
> >>
> >> ftp-public-greenvideo.insa-rennes.fr
> >>
> >>
> >> The Nal SEI syntax is the same as the one used in the last JM release (19.0).
> >>
> >>
> >> Best Regards,
> >>
> >>
> >>
> >> Nicolas DEROUINEAU
> >> Research Engineer
> >> VITEC
> >>
> >> T.  +33 1 46 73 06 06
> >> E.  nicolas.derouineau at vitec.com<mailto:nicolas.derouineau at vitec.com>
> >> W. www.vitec.com<http://www.vitec.com/>;
> >
> >>  h264.h     |   20 ++++++++++++++++++
> >>  h264_sei.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>  2 files changed, 87 insertions(+)
> >> feb39a55dd6afbaf341df765eafc02266c00a588  0002-Enabling-GreenMetadata-SEI-parsing-for-H264-decoder.patch
> >> From 60903bff6429182c84dc5daef0d26695d3f71861 Mon Sep 17 00:00:00 2001
> >> From: Nicolas DEROUINEAU <nicolas.derouineau at vitec.com>
> >> Date: Thu, 25 Jun 2015 13:02:39 +0200
> >> Subject: [PATCH 2/2] Enabling GreenMetadata SEI parsing for H264 decoder
> >>
> >> ---
> >>  libavcodec/h264.h     | 20 +++++++++++++++
> >>  libavcodec/h264_sei.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >>  2 files changed, 87 insertions(+)
> >>
> >> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> >> index 548510d..0324dc1 100644
> >> --- a/libavcodec/h264.h
> >> +++ b/libavcodec/h264.h
> >> @@ -137,6 +137,7 @@ typedef enum {
> >>      SEI_TYPE_RECOVERY_POINT         = 6,   ///< recovery point (frame # to decoder sync)
> >>      SEI_TYPE_FRAME_PACKING          = 45,  ///< frame packing arrangement
> >>      SEI_TYPE_DISPLAY_ORIENTATION    = 47,  ///< display orientation
> >> +    SEI_TYPE_GREEN_METADATA  = 56  ///< GreenMPEG information
> >>  } SEI_Type;
> >>
> >>  /**
> >> @@ -268,6 +269,22 @@ typedef struct FPA {
> >>  } FPA;
> >>
> >>  /**
> >> + * Green MetaData Information Type
> >> + */
> >> +typedef struct GreenMetaData {
> >> +    unsigned char  green_metadata_type;
> >> +    unsigned char  period_type;
> >> +    unsigned short num_seconds;
> >> +    unsigned short num_pictures;
>
> uint16_t and uint8_t would probably be more appropriate here
>
> >> +    unsigned char percent_non_zero_macroblocks;
> >> +    unsigned char percent_intra_coded_macroblocks;
> >> +    unsigned char percent_six_tap_filtering;
> >> +    unsigned char percent_alpha_point_deblocking_instance;
> >> +    unsigned char xsd_metric_type;
> >> +    unsigned short xsd_metric_value;
> >> +} GreenMetaData;
> >> +
> >> +/**
> >>   * Memory management control operation opcode.
> >>   */
> >>  typedef enum MMCOOpcode {
> >> @@ -804,6 +821,9 @@ typedef struct H264Context {
> >>      /* Motion Estimation */
> >>      qpel_mc_func (*qpel_put)[16];
> >>      qpel_mc_func (*qpel_avg)[16];
> >> +
> >> +    /*Green Metadata */
> >> +    GreenMetaData sei_GreenMetaData;
>
> This is mostly a nit, but could you maybe avoid using CamelCase naming
> in function and variable names?
> eg GreenMetaData sei_green_metadata would reflect more the rest of the code.
>
> thanks
> --
> Vittorio

>  avcodec.h  |    2 ++
>  h264.h     |   20 ++++++++++++++++++++
>  h264_sei.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+)
> 1453ba266a63744aa16e59d4c18bcc1081d6e65f  0002-Enabling-GreenMetadata-SEI-parsing-for-H264-decoder.patch
> From d742bb556f794a16e03305195b5826ba8d2931a2 Mon Sep 17 00:00:00 2001
> From: NDE <nde at nde-OptiPlex-980.(none)>
> Date: Mon, 29 Jun 2015 12:13:16 +0200
> Subject: [PATCH 2/4] Enabling GreenMetadata SEI parsing for H264 decoder
>
> ---
>  libavcodec/avcodec.h  |    2 ++
>  libavcodec/h264.h     |   20 +++++++++++++++++
>  libavcodec/h264_sei.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index ddbf0a3..7000145 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2616,8 +2616,10 @@ typedef struct AVCodecContext {
>  #endif
>  #define FF_DEBUG_BUFFERS     0x00008000
>  #define FF_DEBUG_THREADS     0x00010000

> +#define FF_DEBUG_GREEN_MD    0x00100000
>  #define FF_DEBUG_NOMC        0x01000000

please use
#define FF_DEBUG_GREEN_MD    0x00800000
unless this value is already used
i think we should not add new holes in the list

>
> +
>  #if FF_API_DEBUG_MV
>      /**
>       * debug

stray change


> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> index 15b9a5d..2cc3e50 100644
> --- a/libavcodec/h264.h
> +++ b/libavcodec/h264.h
> @@ -137,6 +137,7 @@ typedef enum {
>      SEI_TYPE_RECOVERY_POINT         = 6,   ///< recovery point (frame # to decoder sync)
>      SEI_TYPE_FRAME_PACKING          = 45,  ///< frame packing arrangement
>      SEI_TYPE_DISPLAY_ORIENTATION    = 47,  ///< display orientation
> +    SEI_TYPE_GREEN_METADATA  = 56  ///< GreenMPEG information

please keep this similarly formated as the surrounding code ("=" below
each previous)


[...]
>  options_table.h |    1 +
>  1 file changed, 1 insertion(+)
> 80ad6cb3a931768cb22d9349770fde6897eaa50c  0004-Update-for-libavcodec-debug-options-enabling-GreenMe.patch
> From ceac0fcf76195cc6b94a91834458fd9d7ce3e8a7 Mon Sep 17 00:00:00 2001
> From: Nicolas DEROUINEAU <nicolas.derouineau at vitec.com>
> Date: Mon, 29 Jun 2015 14:41:15 +0200
> Subject: [PATCH 4/4] Update for libavcodec debug options enabling
>  GreenMetadata SEI display on stdout
>
> ---
>  libavcodec/options_table.h |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> index a906864..76ae81f 100644
> --- a/libavcodec/options_table.h
> +++ b/libavcodec/options_table.h
> @@ -253,6 +253,7 @@ static const AVOption avcodec_options[] = {
>  {"mv", "motion vector", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MV }, INT_MIN, INT_MAX, V|D, "debug"},
>  #endif
>  {"dct_coeff", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_DCT_COEFF }, INT_MIN, INT_MAX, V|D, "debug"},
> +{"green_metadata", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_GREEN_MD }, INT_MIN, INT_MAX, V|D, "debug"},

this also needs a update to
doc/codecs.texi

thanks

[...]

--
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Patch-to-parse-SEI-GreenMetadata.patch
Type: text/x-patch
Size: 7355 bytes
Desc: 0001-Patch-to-parse-SEI-GreenMetadata.patch
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150630/283ec21b/attachment.bin>


More information about the ffmpeg-devel mailing list