@ -672,11 +672,11 @@ struct mpeg4_bit_rate_values {
static struct mpeg4_bit_rate_values calculate_mpeg4_bit_rates ( MOVTrack * track )
{
AVCPBProperties * props = track - > st ?
( AVCPBProperties * ) av_stream_get_side_data ( track - > st ,
AV_PKT_DATA_CPB_PROPERTIES ,
NULL ) :
NULL ;
const AVPacketSideData * sd = track - > st ?
av_packet_side_data_get ( track - > st - > codecpar - > coded_ side_da ta ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_CPB_PROPERTIES ) : NULL ;
AVCPBProperties * props = sd ? ( AVCPBProperties * ) sd - > data : NULL ;
struct mpeg4_bit_rate_values bit_rates = { 0 } ;
bit_rates . avg_bit_rate = compute_avg_bitrate ( track ) ;
@ -2129,18 +2129,17 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc)
// Ref (MOV): https://developer.apple.com/library/mac/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG9
// Ref (MP4): ISO/IEC 14496-12:2012
const uint8_t * icc_profile ;
size_t icc_profile_size ;
if ( prefer_icc ) {
icc_profile = av_stream_get_side_data ( track - > st , AV_PKT_DATA_ICC_PROFILE , & icc_profile_size ) ;
const AVPacketSideData * sd = av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_ICC_PROFILE ) ;
if ( icc_profile ) {
avio_wb32 ( pb , 12 + icc_profile_ size) ;
if ( sd ) {
avio_wb32 ( pb , 12 + sd - > size ) ;
ffio_wfourcc ( pb , " colr " ) ;
ffio_wfourcc ( pb , " prof " ) ;
avio_write ( pb , icc_profile , icc_profile_ size) ;
return 12 + icc_profile_ size;
avio_write ( pb , sd - > data , sd - > size ) ;
return 12 + sd - > size ;
}
else {
av_log ( NULL , AV_LOG_INFO , " no ICC profile found, will write nclx/nclc colour info instead \n " ) ;
@ -2173,14 +2172,16 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc)
static int mov_write_clli_tag ( AVIOContext * pb , MOVTrack * track )
{
const uint8_t * side_data ;
const AVPacketSideData * side_data ;
const AVContentLightMetadata * content_light_metadata ;
side_data = av_stream_get_side_data ( track - > st , AV_PKT_DATA_CONTENT_LIGHT_LEVEL , NULL ) ;
side_data = av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_CONTENT_LIGHT_LEVEL ) ;
if ( ! side_data ) {
return 0 ;
}
content_light_metadata = ( const AVContentLightMetadata * ) side_data ;
content_light_metadata = ( const AVContentLightMetadata * ) side_data - > data ;
avio_wb32 ( pb , 12 ) ; // size
ffio_wfourcc ( pb , " clli " ) ;
@ -2198,11 +2199,14 @@ static int mov_write_mdcv_tag(AVIOContext *pb, MOVTrack *track)
{
const int chroma_den = 50000 ;
const int luma_den = 10000 ;
const uint8_t * side_data ;
const AVMasteringDisplayMetadata * metadata ;
side_data = av_stream_get_side_data ( track - > st , AV_PKT_DATA_MASTERING_DISPLAY_METADATA , NULL ) ;
metadata = ( const AVMasteringDisplayMetadata * ) side_data ;
const AVPacketSideData * side_data ;
const AVMasteringDisplayMetadata * metadata = NULL ;
side_data = av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_MASTERING_DISPLAY_METADATA ) ;
if ( side_data )
metadata = ( const AVMasteringDisplayMetadata * ) side_data - > data ;
if ( ! metadata | | ! metadata - > has_primaries | | ! metadata - > has_luminance ) {
return 0 ;
}
@ -2421,7 +2425,8 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
track - > par - > color_trc ! = AVCOL_TRC_UNSPECIFIED & &
track - > par - > color_space ! = AVCOL_SPC_UNSPECIFIED ;
if ( has_color_info | | mov - > flags & FF_MOV_FLAG_WRITE_COLR | |
av_stream_get_side_data ( track - > st , AV_PKT_DATA_ICC_PROFILE , NULL ) ) {
av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data , track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_ICC_PROFILE ) ) {
int prefer_icc = mov - > flags & FF_MOV_FLAG_PREFER_ICC | | ! has_color_info ;
mov_write_colr_tag ( pb , track , prefer_icc ) ;
}
@ -2435,17 +2440,22 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
}
if ( track - > mode = = MODE_MP4 & & mov - > fc - > strict_std_compliance < = FF_COMPLIANCE_UNOFFICIAL ) {
AVStereo3D * stereo_3d = ( AVStereo3D * ) av_stream_get_side_data ( track - > st , AV_PKT_DATA_STEREO3D , NULL ) ;
AVSphericalMapping * spherical_mapping = ( AVSphericalMapping * ) av_stream_get_side_data ( track - > st , AV_PKT_DATA_SPHERICAL , NULL ) ;
AVDOVIDecoderConfigurationRecord * dovi = ( AVDOVIDecoderConfigurationRecord * )
av_stream_get_side_data ( track - > st , AV_PKT_DATA_DOVI_CONF , NULL ) ;
const AVPacketSideData * stereo_3d = av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_STEREO3D ) ;
const AVPacketSideData * spherical_mapping = av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_SPHERICAL ) ;
const AVPacketSideData * dovi = av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_DOVI_CONF ) ;
if ( stereo_3d )
mov_write_st3d_tag ( s , pb , stereo_3d ) ;
mov_write_st3d_tag ( s , pb , ( AVStereo3D * ) stereo_3d - > data ) ;
if ( spherical_mapping )
mov_write_sv3d_tag ( mov - > fc , pb , spherical_mapping ) ;
mov_write_sv3d_tag ( mov - > fc , pb , ( AVSphericalMapping * ) spherical_mapping - > data ) ;
if ( dovi )
mov_write_dvcc_dvvc_tag ( s , pb , dovi ) ;
mov_write_dvcc_dvvc_tag ( s , pb , ( AVDOVIDecoderConfigurationRecord * ) dovi - > data ) ;
}
if ( track - > par - > sample_aspect_ratio . den & & track - > par - > sample_aspect_ratio . num ) {
@ -3392,7 +3402,6 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
int group = 0 ;
uint32_t * display_matrix = NULL ;
size_t display_matrix_size ;
int i ;
if ( mov - > mode = = MODE_AVIF )
@ -3402,15 +3411,17 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
duration * = mov - > avif_loop_count ;
if ( st ) {
const AVPacketSideData * sd ;
if ( mov - > per_stream_grouping )
group = st - > index ;
else
group = st - > codecpar - > codec_type ;
display_matrix = ( uint32_t * ) av_stream_get_side_data ( st , AV_PKT_DATA_DISPLAYMATRIX ,
& display_matrix_size ) ;
if ( display_matrix & & display_matrix_size < 9 * sizeof ( * display_matrix ) )
display_matrix = NULL ;
sd = av_packet_side_data_get ( st - > codecpar - > coded_side_data ,
st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_DISPLAYMATRIX ) ;
if ( sd & & sd - > size = = 9 * sizeof ( * display_matrix ) )
display_matrix = ( uint32_t * ) sd - > data ;
}
if ( track - > flags & MOV_TRACK_ENABLED )
@ -4608,12 +4619,11 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
track - > tref_tag = MKTAG ( ' h ' , ' i ' , ' n ' , ' t ' ) ;
track - > tref_id = mov - > tracks [ track - > src_track ] . track_id ;
} else if ( track - > par - > codec_type = = AVMEDIA_TYPE_AUDIO ) {
size_t size ;
int * fallback ;
fallback = ( int * ) av_stream_get_side_data ( track - > st ,
AV_PKT_DATA_FALLBACK_TRACK ,
& size ) ;
if ( fallback ! = NULL & & size = = sizeof ( int ) ) {
const AVPacketSideData * sd = av_packet_side_data_get ( track - > st - > codecpar - > coded_side_data ,
track - > st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_FALLBACK_TRACK ) ;
if ( sd & & sd - > size = = sizeof ( int ) ) {
int * fallback = ( int * ) sd - > data ;
if ( * fallback > = 0 & & * fallback < mov - > nb_streams ) {
track - > tref_tag = MKTAG ( ' f ' , ' a ' , ' l ' , ' l ' ) ;
track - > tref_id = mov - > tracks [ * fallback ] . track_id ;
@ -5446,7 +5456,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
if ( st - > codecpar - > codec_id = = AV_CODEC_ID_AC3 | |
st - > codecpar - > codec_id = = AV_CODEC_ID_EAC3 | |
st - > codecpar - > codec_id = = AV_CODEC_ID_TRUEHD | |
av_stream_get_side_data ( st , AV_PKT_DATA_DOVI_CONF , NULL ) )
av_packet_side_data_get ( st - > codecpar - > coded_side_data ,
st - > codecpar - > nb_coded_side_data ,
AV_PKT_DATA_DOVI_CONF ) )
has_dolby = 1 ;
}