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
Best Regards,
Nicolas DEROUINEAU
Research Engineer
VITEC
T. +33 1 46 73 06 06
E. [email protected]
W. www.vitec.com
________________________________________
De : [email protected] <[email protected]> de la
part de Nicolas Derouineau <[email protected]>
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. [email protected]
W. www.vitec.com
________________________________________
De : Vittorio Giovara <[email protected]>
Envoyé : vendredi 26 juin 2015 02:56
À : FFmpeg development discussions and patches
Cc : Nicolas Derouineau; Yahia Benmoussa; Erwan Raffin; [email protected];
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
<[email protected]> 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. [email protected]<mailto:[email protected]>
>> 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 <[email protected]>
>> 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
From d742bb556f794a16e03305195b5826ba8d2931a2 Mon Sep 17 00:00:00 2001
From: NDE <nde@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
+
#if FF_API_DEBUG_MV
/**
* debug
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
} SEI_Type;
/**
@@ -267,6 +268,22 @@ typedef struct FPA {
int quincunx_sampling_flag;
} FPA;
+ /*
+ Green MetaData Information Type
+ */
+typedef struct GreenMetaData {
+ uint8_t green_metadata_type;
+ uint8_t period_type;
+ uint16_t num_seconds;
+ uint16_t num_pictures;
+ uint8_t percent_non_zero_macroblocks;
+ uint8_t percent_intra_coded_macroblocks;
+ uint8_t percent_six_tap_filtering;
+ uint8_t percent_alpha_point_deblocking_instance;
+ uint8_t xsd_metric_type;
+ uint16_t xsd_metric_value;
+} GreenMetaData;
+
/**
* Memory management control operation opcode.
*/
@@ -814,6 +831,9 @@ typedef struct H264Context {
/* Motion Estimation */
qpel_mc_func (*qpel_put)[16];
qpel_mc_func (*qpel_avg)[16];
+
+ /*Green Metadata */
+ 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 b6ec5c7..64222fe 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -285,6 +285,60 @@ static int decode_display_orientation(H264Context *h)
return 0;
}
+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.green_metadata_type=get_bits(&h->gb, 8);
+
+ if (h->avctx->debug & FF_DEBUG_GREEN_MD)
+ av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_type = %d\n", h->sei_green_metadata.green_metadata_type);
+
+ if (h->sei_green_metadata.green_metadata_type == 0){
+ h->sei_green_metadata.period_type=get_bits(&h->gb, 8);
+
+ if (h->avctx->debug & FF_DEBUG_GREEN_MD)
+ av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_period_type = %d\n", h->sei_green_metadata.period_type);
+
+ if ( h->sei_green_metadata.green_metadata_type == 2){
+ h->sei_green_metadata.num_seconds = get_bits(&h->gb, 16);
+ if (h->avctx->debug & FF_DEBUG_GREEN_MD)
+ av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_num_seconds = %d\n", h->sei_green_metadata.num_seconds);
+ }
+ else if ( h->sei_green_metadata.period_type == 3){
+ h->sei_green_metadata.num_pictures = get_bits(&h->gb, 16);
+ if (h->avctx->debug & FF_DEBUG_GREEN_MD)
+ av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_num_pictures = %d\n", h->sei_green_metadata.num_pictures);
+ }
+
+ h->sei_green_metadata.percent_non_zero_macroblocks=get_bits(&h->gb, 8);
+ h->sei_green_metadata.percent_intra_coded_macroblocks=get_bits(&h->gb, 8);
+ h->sei_green_metadata.percent_six_tap_filtering=get_bits(&h->gb, 8);
+ h->sei_green_metadata.percent_alpha_point_deblocking_instance=get_bits(&h->gb, 8);
+
+ if (h->avctx->debug & FF_DEBUG_GREEN_MD)
+ av_log(h->avctx, AV_LOG_DEBUG, "SEI GREEN Complexity Metrics = %f %f %f %f \n",
+ (float)h->sei_green_metadata.percent_non_zero_macroblocks/255,
+ (float)h->sei_green_metadata.percent_intra_coded_macroblocks/255,
+ (float)h->sei_green_metadata.percent_six_tap_filtering/255,
+ (float)h->sei_green_metadata.percent_alpha_point_deblocking_instance/255);
+
+ }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);
+
+ if (h->avctx->debug & FF_DEBUG_GREEN_MD)
+ av_log(h->avctx, AV_LOG_DEBUG, "xsd_metric_type = %d\n", h->sei_green_metadata.xsd_metric_type);
+ if ( h->sei_green_metadata.xsd_metric_type == 0){
+ if (h->avctx->debug & FF_DEBUG_GREEN_MD)
+ av_log(h->avctx, AV_LOG_DEBUG, "xsd_metric_value = %f\n", (float)h->sei_green_metadata.xsd_metric_value/100);
+ }
+ }
+
+ return 0;
+}
+
int ff_h264_decode_sei(H264Context *h)
{
while (get_bits_left(&h->gb) > 16 && show_bits(&h->gb, 16)) {
@@ -350,6 +404,11 @@ int ff_h264_decode_sei(H264Context *h)
if (ret < 0)
return ret;
break;
+ case SEI_TYPE_GREEN_METADATA:
+ ret = decode_GreenMetadata(h);
+ if (ret < 0)
+ return ret;
+ break;
default:
av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
}
--
1.7.9.5
From ceac0fcf76195cc6b94a91834458fd9d7ce3e8a7 Mon Sep 17 00:00:00 2001
From: Nicolas DEROUINEAU <[email protected]>
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"},
{"skip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_SKIP }, INT_MIN, INT_MAX, V|D, "debug"},
{"startcode", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_STARTCODE }, INT_MIN, INT_MAX, V|D, "debug"},
#if FF_API_UNUSED_MEMBERS
--
1.7.9.5
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel