[vlc-devel] [PATCH 1/4] es: move i_profile/i_level to audio and video format structs

Thomas Guillem thomas at gllm.fr
Fri Mar 30 15:15:22 CEST 2018


---
 include/vlc_es.h                   | 24 ++++++++++++++++++++++--
 lib/media.c                        | 19 +++++++++++++------
 modules/codec/avcodec/audio.c      |  4 ++--
 modules/codec/avcodec/directx_va.c |  4 ++--
 modules/codec/avcodec/vaapi.c      |  4 ++--
 modules/codec/avcodec/video.c      |  4 ++--
 modules/codec/omxil/mediacodec.c   |  5 ++++-
 modules/codec/spdif.c              |  2 +-
 modules/demux/avformat/mux.c       |  2 +-
 modules/demux/mp4/essetup.c        |  8 ++++----
 modules/demux/mpeg/ts_psi.c        | 14 +++++++-------
 modules/mux/mpeg/tables.c          |  2 +-
 modules/packetizer/dts.c           |  2 +-
 modules/packetizer/h264.c          |  4 ++--
 modules/packetizer/hevc.c          |  6 +++---
 modules/packetizer/mpegaudio.c     |  2 +-
 modules/stream_out/rtpfmt.c        |  4 ++--
 src/input/decoder.c                |  4 ++--
 src/misc/es_format.c               |  6 +++---
 19 files changed, 75 insertions(+), 45 deletions(-)

diff --git a/include/vlc_es.h b/include/vlc_es.h
index 718dfc42b1..4b5cdfe33b 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -111,6 +111,10 @@ struct audio_format_t
     unsigned     i_bitspersample;
     unsigned     i_blockalign;
     uint8_t      i_channels; /* must be <=32 */
+
+    int i_profile; /**< codec specific information (like dtshd extensions) */
+    int i_level;   /**< codec specific information: indicates maximum
+                        restrictions on the stream (bitrate, codec features ...) */
 };
 
 /* Values available for audio channels */
@@ -340,6 +344,11 @@ struct video_format_t
     unsigned int i_frame_rate;                     /**< frame rate numerator */
     unsigned int i_frame_rate_base;              /**< frame rate denominator */
 
+    int i_profile; /**< codec specific information (like h264/hevc profile) */
+    int i_level;   /**< codec specific information: indicates maximum
+                        restrictions on the stream (resolution, bitrate,
+                        codec features ...) */
+
     uint32_t i_rmask, i_gmask, i_bmask;      /**< color masks for RGB chroma */
     int i_rrshift, i_lrshift;
     int i_rgshift, i_lgshift;
@@ -380,10 +389,23 @@ static inline void video_format_Init( video_format_t *p_src, vlc_fourcc_t i_chro
 {
     memset( p_src, 0, sizeof( video_format_t ) );
     p_src->i_chroma = i_chroma;
+    p_src->i_profile = -1;
+    p_src->i_level   = -1;
     vlc_viewpoint_init( &p_src->pose );
 }
 
 /**
+ * Initialize a audio_format_t structure
+ * \param p_src pointer to audio_format_t structure
+ */
+static inline void audio_format_Init( audio_format_t *p_src )
+{
+    memset( p_src, 0, sizeof( audio_format_t ) );
+    p_src->i_profile = -1;
+    p_src->i_level   = -1;
+}
+
+/**
  * Copy video_format_t including the palette
  * \param p_dst video_format_t to copy to
  * \param p_src video_format_t to copy from
@@ -608,8 +630,6 @@ struct es_format_t
     };
 
     unsigned int   i_bitrate; /**< bitrate of this ES */
-    int      i_profile;       /**< codec specific information (like real audio flavor, mpeg audio layer, h264 profile ...) */
-    int      i_level;         /**< codec specific information: indicates maximum restrictions on the stream (resolution, bitrate, codec features ...) */
 
     bool     b_packetized;  /**< whether the data is packetized (ie. not truncated) */
     int     i_extra;        /**< length in bytes of extra data pointer */
diff --git a/lib/media.c b/lib/media.c
index 58881e315f..2a9b8e2b5b 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -931,27 +931,31 @@ libvlc_media_get_tracks_info( libvlc_media_t *p_md, libvlc_media_track_info_t **
         p_mes->i_codec = p_es->i_codec;
         p_mes->i_id = p_es->i_id;
 
-        p_mes->i_profile = p_es->i_profile;
-        p_mes->i_level = p_es->i_level;
-
         switch(p_es->i_cat)
         {
         case UNKNOWN_ES:
         default:
             p_mes->i_type = libvlc_track_unknown;
+            p_mes->i_profile = p_mes->i_level = -1;
             break;
         case VIDEO_ES:
             p_mes->i_type = libvlc_track_video;
             p_mes->u.video.i_height = p_es->video.i_visible_height;
             p_mes->u.video.i_width = p_es->video.i_visible_width;
+            p_mes->i_profile = p_es->video.i_profile;
+            p_mes->i_level = p_es->video.i_level;
+
             break;
         case AUDIO_ES:
             p_mes->i_type = libvlc_track_audio;
             p_mes->u.audio.i_channels = p_es->audio.i_channels;
             p_mes->u.audio.i_rate = p_es->audio.i_rate;
+            p_mes->i_profile = p_es->audio.i_profile;
+            p_mes->i_level = p_es->audio.i_level;
             break;
         case SPU_ES:
             p_mes->i_type = libvlc_track_text;
+            p_mes->i_profile = p_mes->i_level = -1;
             break;
         }
     }
@@ -1003,9 +1007,6 @@ libvlc_media_tracks_get( libvlc_media_t *p_md, libvlc_media_track_t *** pp_es )
         p_mes->i_original_fourcc = p_es->i_original_fourcc;
         p_mes->i_id = p_es->i_id;
 
-        p_mes->i_profile = p_es->i_profile;
-        p_mes->i_level = p_es->i_level;
-
         p_mes->i_bitrate = p_es->i_bitrate;
         p_mes->psz_language = p_es->psz_language != NULL ? strdup(p_es->psz_language) : NULL;
         p_mes->psz_description = p_es->psz_description != NULL ? strdup(p_es->psz_description) : NULL;
@@ -1015,6 +1016,7 @@ libvlc_media_tracks_get( libvlc_media_t *p_md, libvlc_media_track_t *** pp_es )
         case UNKNOWN_ES:
         default:
             p_mes->i_type = libvlc_track_unknown;
+            p_mes->i_profile = p_mes->i_level = -1;
             break;
         case VIDEO_ES:
             p_mes->i_type = libvlc_track_video;
@@ -1024,6 +1026,8 @@ libvlc_media_tracks_get( libvlc_media_t *p_md, libvlc_media_track_t *** pp_es )
             p_mes->video->i_sar_den = p_es->video.i_sar_den;
             p_mes->video->i_frame_rate_num = p_es->video.i_frame_rate;
             p_mes->video->i_frame_rate_den = p_es->video.i_frame_rate_base;
+            p_mes->i_profile = p_es->video.i_profile;
+            p_mes->i_level = p_es->video.i_level;
 
             assert( p_es->video.orientation >= ORIENT_TOP_LEFT &&
                     p_es->video.orientation <= ORIENT_RIGHT_BOTTOM );
@@ -1043,11 +1047,14 @@ libvlc_media_tracks_get( libvlc_media_t *p_md, libvlc_media_track_t *** pp_es )
             p_mes->i_type = libvlc_track_audio;
             p_mes->audio->i_channels = p_es->audio.i_channels;
             p_mes->audio->i_rate = p_es->audio.i_rate;
+            p_mes->i_profile = p_es->audio.i_profile;
+            p_mes->i_level = p_es->audio.i_level;
             break;
         case SPU_ES:
             p_mes->i_type = libvlc_track_text;
             p_mes->subtitle->psz_encoding = p_es->subs.psz_encoding != NULL ?
                                             strdup(p_es->subs.psz_encoding) : NULL;
+            p_mes->i_profile = p_mes->i_level = -1;
             break;
         }
     }
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index b9eb7d5856..a3a25e62d5 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -263,9 +263,9 @@ int InitAudioDec( vlc_object_t *obj )
 
     /* XXX: Writing input format makes little sense. */
     if( avctx->profile != FF_PROFILE_UNKNOWN )
-        p_dec->fmt_in.i_profile = avctx->profile;
+        p_dec->fmt_in.audio.i_profile = avctx->profile;
     if( avctx->level != FF_LEVEL_UNKNOWN )
-        p_dec->fmt_in.i_level = avctx->level;
+        p_dec->fmt_in.audio.i_level = avctx->level;
 
     return VLC_SUCCESS;
 }
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 0c62644581..e28197d12e 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -357,7 +357,7 @@ static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *
     bool is_supported = mode->p_profiles == NULL || !mode->p_profiles[0];
     if (!is_supported)
     {
-        int profile = fmt->i_profile >= 0 ? fmt->i_profile : avctx->profile;
+        int profile = fmt->video.i_profile >= 0 ? fmt->video.i_profile : avctx->profile;
         if (mode->codec == AV_CODEC_ID_H264)
         {
             uint8_t h264_profile;
@@ -427,7 +427,7 @@ static int FindVideoServiceConversion(vlc_va_t *va, directx_sys_t *dx_sys,
             {
                 char *psz_name = directx_va_GetDecoderName(mode->guid);
                 msg_Warn( va, "Unsupported profile %d for %s ",
-                          fmt->i_profile, psz_name );
+                          fmt->video.i_profile, psz_name );
                 free( psz_name );
             }
         }
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index dccdefe772..fea17b62ce 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -87,9 +87,9 @@ static int GetVaProfile(AVCodecContext *ctx, const es_format_t *fmt,
         count = 18;
         break;
     case AV_CODEC_ID_HEVC:
-        if (fmt->i_profile == FF_PROFILE_HEVC_MAIN)
+        if (fmt->video.i_profile == FF_PROFILE_HEVC_MAIN)
             i_profile = VAProfileHEVCMain;
-        else if (fmt->i_profile == FF_PROFILE_HEVC_MAIN_10)
+        else if (fmt->video.i_profile == FF_PROFILE_HEVC_MAIN_10)
         {
             i_profile = VAProfileHEVCMain10;
             i_vlc_chroma = VLC_CODEC_VAAPI_420_10BPP;
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index b505d34846..f15c31cdb9 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -632,9 +632,9 @@ int InitVideoDec( vlc_object_t *obj )
 
     /* XXX: Writing input format makes little sense. */
     if( p_context->profile != FF_PROFILE_UNKNOWN )
-        p_dec->fmt_in.i_profile = p_context->profile;
+        p_dec->fmt_in.video.i_profile = p_context->profile;
     if( p_context->level != FF_LEVEL_UNKNOWN )
-        p_dec->fmt_in.i_level = p_context->level;
+        p_dec->fmt_in.video.i_level = p_context->level;
     return VLC_SUCCESS;
 }
 
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 455f0fc7f4..c8cb5d0bbc 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -536,7 +536,7 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
     decoder_t *p_dec = (decoder_t *)p_this;
     decoder_sys_t *p_sys;
     int i_ret;
-    int i_profile = p_dec->fmt_in.i_profile;
+    int i_profile;
     const char *mime = NULL;
 
     /* Video or Audio if "mediacodec-audio" bool is true */
@@ -550,6 +550,7 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
 
     if (p_dec->fmt_in.i_cat == VIDEO_ES)
     {
+        i_profile = p_dec->fmt_in.video.i_profile;
         /* Not all mediacodec versions can handle a size of 0. Hopefully, the
          * packetizer will trigger a decoder restart when a new video size is
          * found. */
@@ -589,6 +590,8 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
     }
     else
     {
+        i_profile = p_dec->fmt_in.audio.i_profile;
+
         switch (p_dec->fmt_in.i_codec) {
         case VLC_CODEC_AMR_NB: mime = "audio/3gpp"; break;
         case VLC_CODEC_AMR_WB: mime = "audio/amr-wb"; break;
diff --git a/modules/codec/spdif.c b/modules/codec/spdif.c
index edb3e899e4..17e23d8531 100644
--- a/modules/codec/spdif.c
+++ b/modules/codec/spdif.c
@@ -75,7 +75,7 @@ OpenDecoder(vlc_object_t *p_this)
     /* Set output properties */
     p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;
     p_dec->fmt_out.audio = p_dec->fmt_in.audio;
-    p_dec->fmt_out.i_profile = p_dec->fmt_in.i_profile;
+    p_dec->fmt_out.audio.i_profile = p_dec->fmt_in.audio.i_profile;
     p_dec->fmt_out.audio.i_format = p_dec->fmt_out.i_codec;
 
     if (decoder_UpdateAudioFormat(p_dec))
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 9500c915b4..4949dc614c 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -213,7 +213,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             return VLC_EGENERIC;
         }
     }
-    else if( fmt->i_codec == VLC_CODEC_MPGA && fmt->i_profile == 3 )
+    else if( fmt->i_codec == VLC_CODEC_MPGA && fmt->audio.i_profile == 3 )
     {
         i_codec_id = AV_CODEC_ID_MP3;
     }
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 38a2cab858..de63ae80e5 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -118,7 +118,7 @@ static void SetupESDS( demux_t *p_demux, mp4_track_t *p_track, const MP4_descrip
         break;
     case( 0xaa ): /* DTS-HD HRA */
     case( 0xab ): /* DTS-HD Master Audio */
-        p_track->fmt.i_profile = PROFILE_DTS_HD;
+        p_track->fmt.audio.i_profile = PROFILE_DTS_HD;
         /* fallthrough */
     case( 0xa9 ): /* dts */
         p_track->fmt.i_codec = VLC_CODEC_DTS;
@@ -661,8 +661,8 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
                     p_track->fmt.i_codec = VLC_CODEC_VP9;
                 else
                     p_track->fmt.i_codec = VLC_CODEC_VP8;
-                p_track->fmt.i_profile = p_data->i_profile;
-                p_track->fmt.i_level = p_data->i_level;
+                p_track->fmt.video.i_profile = p_data->i_profile;
+                p_track->fmt.video.i_level = p_data->i_level;
 
                 if( p_data->i_version == 0 ) /* old deprecated */
                 {
@@ -1030,7 +1030,7 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
         case ATOM_dtsl: /* DTS‐HD Lossless formats */
         {
             p_track->fmt.i_codec = VLC_CODEC_DTS;
-            p_track->fmt.i_profile = PROFILE_DTS_HD;
+            p_track->fmt.audio.i_profile = PROFILE_DTS_HD;
             break;
         }
 
diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index c277a08154..88180bb853 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -650,10 +650,10 @@ static void SetupAVCDescriptors( demux_t *p_demux, ts_es_t *p_es, const dvbpsi_p
     const dvbpsi_descriptor_t *p_dr = PMTEsFindDescriptor( p_dvbpsies, 0x28 );
     if( p_dr && p_dr->i_length >= 4 )
     {
-        p_es->fmt.i_profile = p_dr->p_data[0];
-        p_es->fmt.i_level = p_dr->p_data[2];
+        p_es->fmt.video.i_profile = p_dr->p_data[0];
+        p_es->fmt.video.i_level = p_dr->p_data[2];
         msg_Dbg( p_demux, "     - found AVC_video_descriptor profile=0x%"PRIx8" level=0x%"PRIx8,
-                 p_es->fmt.i_profile, p_es->fmt.i_level );
+                 p_es->fmt.video.i_profile, p_es->fmt.video.i_level );
     }
 }
 
@@ -663,8 +663,8 @@ static void SetupJ2KDescriptors( demux_t *p_demux, ts_es_t *p_es, const dvbpsi_p
     if( p_dr && p_dr->i_length >= 24 )
     {
         es_format_Change( &p_es->fmt, VIDEO_ES, VLC_CODEC_JPEG2000 );
-        p_es->fmt.i_profile = p_dr->p_data[0];
-        p_es->fmt.i_level = p_dr->p_data[1];
+        p_es->fmt.video.i_profile = p_dr->p_data[0];
+        p_es->fmt.video.i_level = p_dr->p_data[1];
         p_es->fmt.video.i_width = GetDWBE(&p_dr->p_data[2]);
         p_es->fmt.video.i_height = GetDWBE(&p_dr->p_data[6]);
         p_es->fmt.video.i_frame_rate_base = GetWBE(&p_dr->p_data[18]);
@@ -681,7 +681,7 @@ static void SetupJ2KDescriptors( demux_t *p_demux, ts_es_t *p_es, const dvbpsi_p
                 p_es->fmt.i_extra = p_dr->i_length - 24;
         }
         msg_Dbg( p_demux, "     - found J2K_video_descriptor profile=0x%"PRIx8" level=0x%"PRIx8,
-                 p_es->fmt.i_profile, p_es->fmt.i_level );
+                 p_es->fmt.video.i_profile, p_es->fmt.video.i_level );
     }
 }
 
@@ -1350,7 +1350,7 @@ static bool PMTSetupEsHDMV( demux_t *p_demux, ts_es_t *p_es,
     case 0x85: /* DTS-HD High resolution audio */
     case 0x86: /* DTS-HD Master audio */
         es_format_Change( p_fmt, AUDIO_ES, VLC_CODEC_DTS );
-        p_fmt->i_profile = PROFILE_DTS_HD;
+        p_fmt->audio.i_profile = PROFILE_DTS_HD;
         break;
     case 0x82:
     case 0xA2: /* Secondary DTS audio */
diff --git a/modules/mux/mpeg/tables.c b/modules/mux/mpeg/tables.c
index 0d0580ed68..30a8fc42a0 100644
--- a/modules/mux/mpeg/tables.c
+++ b/modules/mux/mpeg/tables.c
@@ -546,7 +546,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
         {
             uint8_t i_ver;
             /* DTS registration descriptor (ETSI TS 101 154 Annex F) */
-            if( p_stream->fmt->i_profile == PROFILE_DTS_HD )
+            if( p_stream->fmt->audio.i_profile == PROFILE_DTS_HD )
             {
                 i_ver = 'H';
             }
diff --git a/modules/packetizer/dts.c b/modules/packetizer/dts.c
index e9ca41d267..cc72c738ba 100644
--- a/modules/packetizer/dts.c
+++ b/modules/packetizer/dts.c
@@ -276,7 +276,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
                                               VLC_DTS_HEADER_SIZE )
                         == VLC_SUCCESS && next_header.b_substream )
                     {
-                        p_dec->fmt_out.i_profile = PROFILE_DTS_HD;
+                        p_dec->fmt_out.audio.i_profile = PROFILE_DTS_HD;
                         p_sys->i_input_size += next_header.i_frame_size;
                     }
                 }
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 76b6ed5286..98408509a1 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -197,8 +197,8 @@ static void ActivateSets( decoder_t *p_dec, const h264_sequence_parameter_set_t
 
     if( p_sps )
     {
-        p_dec->fmt_out.i_profile = p_sps->i_profile;
-        p_dec->fmt_out.i_level = p_sps->i_level;
+        p_dec->fmt_out.video.i_profile = p_sps->i_profile;
+        p_dec->fmt_out.video.i_level = p_sps->i_level;
 
         (void) h264_get_picture_size( p_sps, &p_dec->fmt_out.video.i_width,
                                       &p_dec->fmt_out.video.i_height,
diff --git a/modules/packetizer/hevc.c b/modules/packetizer/hevc.c
index ec8873af7c..865ffe31fe 100644
--- a/modules/packetizer/hevc.c
+++ b/modules/packetizer/hevc.c
@@ -580,13 +580,13 @@ static void ActivateSets(decoder_t *p_dec,
             }
         }
 
-        if(p_dec->fmt_in.i_profile == -1)
+        if(p_dec->fmt_in.video.i_profile == -1)
         {
             uint8_t i_profile, i_level;
             if( hevc_get_sps_profile_tier_level( p_sps, &i_profile, &i_level ) )
             {
-                p_dec->fmt_out.i_profile = i_profile;
-                p_dec->fmt_out.i_level = i_level;
+                p_dec->fmt_out.video.i_profile = i_profile;
+                p_dec->fmt_out.video.i_level = i_level;
             }
         }
 
diff --git a/modules/packetizer/mpegaudio.c b/modules/packetizer/mpegaudio.c
index 9e6d357b3c..13323b12fd 100644
--- a/modules/packetizer/mpegaudio.c
+++ b/modules/packetizer/mpegaudio.c
@@ -123,7 +123,7 @@ static uint8_t *GetOutBuffer( decoder_t *p_dec, block_t **pp_out_buffer )
         date_Set( &p_sys->end_date, p_sys->i_pts );
     }
 
-    p_dec->fmt_out.i_profile        = p_sys->i_layer;
+    p_dec->fmt_out.audio.i_profile        = p_sys->i_layer;
     p_dec->fmt_out.audio.i_rate     = p_sys->i_rate;
     p_dec->fmt_out.audio.i_channels = p_sys->i_channels;
     p_dec->fmt_out.audio.i_frame_length = p_sys->i_frame_length;
diff --git a/modules/stream_out/rtpfmt.c b/modules/stream_out/rtpfmt.c
index c5b178f514..f7ed59ec46 100644
--- a/modules/stream_out/rtpfmt.c
+++ b/modules/stream_out/rtpfmt.c
@@ -342,8 +342,8 @@ int rtp_get_fmt( vlc_object_t *obj, const es_format_t *p_fmt, const char *mux,
             rtp_fmt->pf_packetize = rtp_packetize_h265;
             rtp_fmt->fmtp = NULL;
 
-            int i_profile = p_fmt->i_profile;
-            int i_level = p_fmt->i_level;
+            int i_profile = p_fmt->video.i_profile;
+            int i_level = p_fmt->video.i_level;
             int i_tiers = -1;
             int i_space = -1;
 
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 2aec72814b..c1037c031e 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -313,7 +313,7 @@ static int aout_update_format( decoder_t *p_dec )
     if( p_owner->p_aout &&
        ( !AOUT_FMTS_IDENTICAL(&p_dec->fmt_out.audio, &p_owner->fmt.audio) ||
          p_dec->fmt_out.i_codec != p_dec->fmt_out.audio.i_format ||
-         p_dec->fmt_out.i_profile != p_owner->fmt.i_profile ) )
+         p_dec->fmt_out.audio.i_profile != p_owner->fmt.audio.i_profile ) )
     {
         audio_output_t *p_aout = p_owner->p_aout;
 
@@ -367,7 +367,7 @@ static int aout_update_format( decoder_t *p_dec )
             /* TODO: 3.0 HACK: we need to put i_profile inside audio_format_t
              * for 4.0 */
             if( p_dec->fmt_out.i_codec == VLC_CODEC_DTS )
-                var_SetBool( p_aout, "dtshd", p_dec->fmt_out.i_profile > 0 );
+                var_SetBool( p_aout, "dtshd", p_dec->fmt_out.audio.i_profile > 0 );
 
             if( aout_DecNew( p_aout, p_dec->fmt_in.i_codec, &format,
                              &p_dec->fmt_out.audio_replay_gain,
diff --git a/src/misc/es_format.c b/src/misc/es_format.c
index b8bef340e8..3283db879c 100644
--- a/src/misc/es_format.c
+++ b/src/misc/es_format.c
@@ -439,8 +439,6 @@ void es_format_Init( es_format_t *fmt,
     memset(fmt, 0, sizeof (*fmt));
     fmt->i_cat                  = i_cat;
     fmt->i_codec                = i_codec;
-    fmt->i_profile              = -1;
-    fmt->i_level                = -1;
     fmt->i_id                   = -1;
     fmt->i_priority             = ES_PRIORITY_SELECTABLE_MIN;
     fmt->psz_language           = NULL;
@@ -449,6 +447,8 @@ void es_format_Init( es_format_t *fmt,
 
     if (fmt->i_cat == VIDEO_ES)
         video_format_Init(&fmt->video, 0);
+    else
+        audio_format_Init(&fmt->audio);
 
     fmt->b_packetized           = true;
     fmt->p_extra                = NULL;
@@ -578,7 +578,7 @@ bool es_format_IsSimilar( const es_format_t *p_fmt1, const es_format_t *p_fmt2 )
             a1.i_physical_channels != a2.i_physical_channels ||
             a1.i_chan_mode != a2.i_chan_mode )
             return false;
-        if( p_fmt1->i_profile != p_fmt2->i_profile )
+        if( a1.i_profile != a2.i_profile )
             return false;
         return true;
     }
-- 
2.11.0



More information about the vlc-devel mailing list