[vlc-commits] omxil: Set an AMR band mode based on the AMR variant

Martin Storsjö git at videolan.org
Sun Feb 17 20:47:20 CET 2013


vlc | branch: master | Martin Storsjö <martin at martin.st> | Sun Feb 17 21:10:02 2013 +0200| [010dc8cd16e013b3185db6881916d7ae6b15876b] | committer: Martin Storsjö

omxil: Set an AMR band mode based on the AMR variant

This requires passing the original VLC codec id to the function,
since both variants are mapped to OMX_AUDIO_CodingAMR.

We don't set the actual correct band mode (since we don't know
what bitrate mode is used for each frame, since it can vary), but
we set mode 0. We could in principle set it more accurately based
on bitrate, but since it can vary from frame to frame, this should
be enough anyway.

This is required for OMX.SEC.amr.dec, which is one single codec
supporting both AMR variant roles, and this seems to be the way of
signalling what AMR variant it is. If setting
OMX_AUDIO_AMRBandModeUnused, the codec fails to initialize.

A codec can get this info either by having two separate OMX codecs,
such as OMX.google.amrnb.decoder vs OMX.google.amrwb.decoder, by
checking what the caller set via OMX_IndexParamStandardComponentRole
or via the band mode parameter - the samsung decoder seems to use
the band mode.

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 modules/codec/omxil/omxil.c       |    1 +
 modules/codec/omxil/omxil_utils.h |    4 ++--
 modules/codec/omxil/utils.c       |    9 ++++++---
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index b587a18..87be051 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -413,6 +413,7 @@ static OMX_ERRORTYPE SetPortDefinition(decoder_t *p_dec, OmxPort *p_port,
         omx_error = SetAudioParameters(p_port->omx_handle,
                                        &p_port->format_param, def->nPortIndex,
                                        def->format.audio.eEncoding,
+                                       p_fmt->i_codec,
                                        p_fmt->audio.i_channels,
                                        p_fmt->audio.i_rate,
                                        p_fmt->i_bitrate,
diff --git a/modules/codec/omxil/omxil_utils.h b/modules/codec/omxil/omxil_utils.h
index 677eab4..bc4c433 100644
--- a/modules/codec/omxil/omxil_utils.h
+++ b/modules/codec/omxil/omxil_utils.h
@@ -192,8 +192,8 @@ int GetVlcChromaSizes( vlc_fourcc_t i_fourcc,
  *****************************************************************************/
 OMX_ERRORTYPE SetAudioParameters(OMX_HANDLETYPE handle,
     OmxFormatParam *param, OMX_U32 i_port, OMX_AUDIO_CODINGTYPE encoding,
-    uint8_t i_channels, unsigned int i_samplerate, unsigned int i_bitrate,
-    unsigned int i_bps, unsigned int i_blocksize);
+    vlc_fourcc_t i_codec, uint8_t i_channels, unsigned int i_samplerate,
+    unsigned int i_bitrate, unsigned int i_bps, unsigned int i_blocksize);
 OMX_ERRORTYPE GetAudioParameters(OMX_HANDLETYPE handle,
     OmxFormatParam *param, OMX_U32 i_port, OMX_AUDIO_CODINGTYPE encoding,
     uint8_t *pi_channels, unsigned int *pi_samplerate,
diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 7f93dc7..069e2ff 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -623,8 +623,8 @@ unsigned int GetAudioParamSize(OMX_INDEXTYPE index)
 
 OMX_ERRORTYPE SetAudioParameters(OMX_HANDLETYPE handle,
     OmxFormatParam *param, OMX_U32 i_port, OMX_AUDIO_CODINGTYPE encoding,
-    uint8_t i_channels, unsigned int i_samplerate, unsigned int i_bitrate,
-    unsigned int i_bps, unsigned int i_blocksize)
+    vlc_fourcc_t i_codec, uint8_t i_channels, unsigned int i_samplerate,
+    unsigned int i_bitrate, unsigned int i_bps, unsigned int i_blocksize)
 {
     OMX_INDEXTYPE index;
 
@@ -657,7 +657,10 @@ OMX_ERRORTYPE SetAudioParameters(OMX_HANDLETYPE handle,
         OMX_INIT_STRUCTURE(param->amr);
         param->amr.nChannels = i_channels;
         param->amr.nBitRate = i_bitrate;
-        param->amr.eAMRBandMode = OMX_AUDIO_AMRBandModeUnused;
+        if (i_codec == VLC_CODEC_AMR_WB)
+            param->amr.eAMRBandMode = OMX_AUDIO_AMRBandModeWB0;
+        else
+            param->amr.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0;
         param->amr.eAMRDTXMode = OMX_AUDIO_AMRDTXModeOff;
         param->amr.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
         break;



More information about the vlc-commits mailing list