[vlc-commits] Allowed to use mp2/mp3 to specify layer 2/3 for mpeg audio encoder.

Laurent Aimar git at videolan.org
Tue Nov 1 14:53:54 CET 2011


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Nov  1 14:34:24 2011 +0100| [16aec732663892527bc84f907d9b19fb784d9e1f] | committer: Laurent Aimar

Allowed to use mp2/mp3 to specify layer 2/3 for mpeg audio encoder.

It might be better (dunno if it would be simpler) to have a way to
specify some kind of profile.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=16aec732663892527bc84f907d9b19fb784d9e1f
---

 include/vlc_fourcc.h                     |    2 ++
 modules/codec/avcodec/encoder.c          |   14 +++++++++++++-
 modules/codec/shine/shine_mod.c          |    4 ++--
 modules/codec/twolame.c                  |    5 ++---
 modules/stream_out/transcode/transcode.c |    3 ++-
 5 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/vlc_fourcc.h b/include/vlc_fourcc.h
index 83ad3d3..32e113f 100644
--- a/include/vlc_fourcc.h
+++ b/include/vlc_fourcc.h
@@ -374,6 +374,8 @@
 #define VLC_CODEC_MP1V      VLC_FOURCC('m','p','1','v')
 /* MPEG-2 video */
 #define VLC_CODEC_MP2V      VLC_FOURCC('m','p','2','v')
+/* MPEG-I/II layer 2 audio */
+#define VLC_CODEC_MP2       VLC_FOURCC('m','p','2',' ')
 /* MPEG-I/II layer 3 audio */
 #define VLC_CODEC_MP3       VLC_FOURCC('m','p','3',' ')
 
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index d038673..0823369 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -203,7 +203,19 @@ int OpenEncoder( vlc_object_t *p_this )
     char *psz_val;
     int i_val;
 
-    if( !GetFfmpegCodec( p_enc->fmt_out.i_codec, &i_cat, &i_codec_id,
+    if( p_enc->fmt_out.i_codec == VLC_CODEC_MP3 )
+    {
+        i_cat = AUDIO_ES;
+        i_codec_id = CODEC_ID_MP3;
+        psz_namecodec = "MPEG I/II Layer 3";
+    }
+    else if( p_enc->fmt_out.i_codec == VLC_CODEC_MP2 )
+    {
+        i_cat = AUDIO_ES;
+        i_codec_id = CODEC_ID_MP2;
+        psz_namecodec = "MPEG I/II Layer 2";
+    }
+    else if( !GetFfmpegCodec( p_enc->fmt_out.i_codec, &i_cat, &i_codec_id,
                              &psz_namecodec ) )
     {
         if( TestFfmpegChroma( -1, p_enc->fmt_out.i_codec ) != VLC_SUCCESS )
diff --git a/modules/codec/shine/shine_mod.c b/modules/codec/shine/shine_mod.c
index 37e2e98..54491ec 100644
--- a/modules/codec/shine/shine_mod.c
+++ b/modules/codec/shine/shine_mod.c
@@ -79,8 +79,8 @@ static int OpenEncoder( vlc_object_t *p_this )
     encoder_t *p_enc = (encoder_t*)p_this;
     encoder_sys_t *p_sys;
 
-    /* FIXME: what about layers 1 and 2 ? shine is an 'MP3' encoder */
-    if( p_enc->fmt_out.i_codec != VLC_CODEC_MP3 ||
+    /* shine is an 'MP3' encoder */
+    if( (p_enc->fmt_out.i_codec != VLC_CODEC_MP3 && p_enc->fmt_out.i_codec != VLC_CODEC_MPGA) ||
         p_enc->fmt_out.audio.i_channels > 2 )
         return VLC_EGENERIC;
 
diff --git a/modules/codec/twolame.c b/modules/codec/twolame.c
index 91bd55b..440e152 100644
--- a/modules/codec/twolame.c
+++ b/modules/codec/twolame.c
@@ -130,9 +130,8 @@ static int OpenEncoder( vlc_object_t *p_this )
     encoder_sys_t *p_sys;
     int i_frequency;
 
-    if( p_enc->fmt_out.i_codec != VLC_CODEC_MPGA &&
-        p_enc->fmt_out.i_codec != VLC_FOURCC('m','p','2','a') &&
-        p_enc->fmt_out.i_codec != VLC_FOURCC('m','p','2',' ') &&
+    if( p_enc->fmt_out.i_codec != VLC_CODEC_MP2 &&
+        p_enc->fmt_out.i_codec != VLC_CODEC_MPGA &&
         !p_enc->b_force )
     {
         return VLC_EGENERIC;
diff --git a/modules/stream_out/transcode/transcode.c b/modules/stream_out/transcode/transcode.c
index 8df202a..1c81007 100644
--- a/modules/stream_out/transcode/transcode.c
+++ b/modules/stream_out/transcode/transcode.c
@@ -299,9 +299,10 @@ static int Open( vlc_object_t *p_this )
     if( p_sys->i_acodec )
     {
         if( ( p_sys->i_acodec == VLC_CODEC_MP3 ||
+              p_sys->i_acodec == VLC_CODEC_MP2 ||
               p_sys->i_acodec == VLC_CODEC_MPGA ) && p_sys->i_channels > 2 )
         {
-            msg_Warn( p_stream, "%d channels invalid for mp3, forcing to 2",
+            msg_Warn( p_stream, "%d channels invalid for mp2/mp3, forcing to 2",
                       p_sys->i_channels );
             p_sys->i_channels = 2;
         }



More information about the vlc-commits mailing list