From e2efb4b7d5885112a32b5b710958fe9fa5458bbf Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Tue, 22 Feb 2005 22:08:07 +0000 Subject: [PATCH] Write x264's version in a SEI message. git-svn-id: svn://svn.videolan.org/x264/trunk@136 df754926-b1dd-0310-bc7b-ec298dee348c --- common/common.h | 2 +- encoder/encoder.c | 13 +++++++++++++ encoder/set.c | 26 ++++++++++++++++++++++++++ encoder/set.h | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/common/common.h b/common/common.h index 2dab995e..8667c76e 100644 --- a/common/common.h +++ b/common/common.h @@ -179,7 +179,7 @@ struct x264_t struct { int i_nal; - x264_nal_t nal[3]; /* for now 3 is enought */ + x264_nal_t nal[4]; /* for now 4 is enough */ int i_bitstream; /* size of p_bitstream */ uint8_t *p_bitstream; /* will hold data for all nal */ bs_t bs; diff --git a/encoder/encoder.c b/encoder/encoder.c index 65e40d36..78932774 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -526,6 +526,11 @@ int x264_encoder_headers( x264_t *h, x264_nal_t **pp_nal, int *pi_nal ) /* Put SPS and PPS */ if( h->i_frame == 0 ) { + /* identify ourself */ + x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE ); + x264_sei_version_write( &h->out.bs ); + x264_nal_end( h ); + /* generate sequence parameters */ x264_nal_start( h, NAL_SPS, NAL_PRIORITY_HIGHEST ); x264_sps_write( &h->out.bs, h->sps ); @@ -1103,6 +1108,14 @@ do_encode: /* Write SPS and PPS */ if( i_nal_type == NAL_SLICE_IDR ) { + if( h->fenc->i_frame == 0 ) + { + /* identify ourself */ + x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE ); + x264_sei_version_write( &h->out.bs ); + x264_nal_end( h ); + } + /* generate sequence parameters */ x264_nal_start( h, NAL_SPS, NAL_PRIORITY_HIGHEST ); x264_sps_write( &h->out.bs, h->sps ); diff --git a/encoder/set.c b/encoder/set.c index 841ec763..c0bfa08b 100644 --- a/encoder/set.c +++ b/encoder/set.c @@ -377,3 +377,29 @@ void x264_pps_write( bs_t *s, x264_pps_t *pps ) bs_rbsp_trailing( s ); } +void x264_sei_version_write( bs_t *s ) +{ + int i; + // random ID number generated according to ISO-11578 + const uint8_t uuid[16] = { + 0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7, + 0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef + }; + char version[256]; + int length; + sprintf( version, "x264 - core 0x%x - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html", + X264_BUILD ); + length = strlen(version)+1+16; + + bs_write( s, 8, 0x5 ); // payload_type = user_data_unregistered + while( length > 255 ) + bs_write( s, 8, 255 ), length -= 255; + bs_write( s, 8, length ); // payload_size + + for( i = 0; i < 16; i++ ) + bs_write( s, 8, uuid[i] ); + for( i = 0; i < length-16; i++ ) + bs_write( s, 8, version[i] ); + + bs_rbsp_trailing( s ); +} diff --git a/encoder/set.h b/encoder/set.h index 44cae088..62f3540e 100644 --- a/encoder/set.h +++ b/encoder/set.h @@ -28,5 +28,6 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param ); void x264_sps_write( bs_t *s, x264_sps_t *sps ); void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *sps ); void x264_pps_write( bs_t *s, x264_pps_t *pps ); +void x264_sei_version_write( bs_t *s ); #endif -- 2.40.0