[FFmpeg-devel] Patch to parse H264 SEI Green Metadata
Michael Niedermayer
michael at niedermayer.cc
Thu Jun 25 18:30:42 CEST 2015
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;
> + 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;
> } 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 8e1697a..884301f 100644
> --- a/libavcodec/h264_sei.c
> +++ b/libavcodec/h264_sei.c
> @@ -279,6 +279,68 @@ static int decode_display_orientation(H264Context *h)
> return 0;
> }
>
> +static int decode_GreenMetadata(H264Context *h)
> +{
> + if (h->avctx->debug)
> + av_log(h->avctx, AV_LOG_DEBUG, "Green Metadata Info SEI message\n");
h->avctx->debug are flags so this should look like
if (h->avctx->debug & FF_DEBUG_...)
> +
> + h->sei_GreenMetaData.green_metadata_type=(unsigned char)get_bits(&h->gb, 8);
unneeded cast, also many others are
> +
> + if (h->avctx->debug)
> + av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_type = %d\n", h->sei_GreenMetaData.green_metadata_type);
> +
> + if ( h->sei_GreenMetaData.green_metadata_type == 0)
> + {
please use the same {} placement style as elsewhere in the file,
not that i mind personally but others do care about this
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150625/a886fd14/attachment.asc>
More information about the ffmpeg-devel
mailing list