[vlc-devel] [PATCH 3/4] omxil: move code to parse profile and level of H264 format to omx_utils.h
Felix Abecassis
felix.abecassis at gmail.com
Sun Feb 9 18:22:28 CET 2014
---
modules/codec/omxil/omxil.c | 35 ++++-------------------------------
modules/codec/omxil/omxil_utils.h | 5 +++++
modules/codec/omxil/utils.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 2800e44..e3e34c4 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -108,39 +108,12 @@ static OMX_ERRORTYPE ImplementationSpecificWorkarounds(decoder_t *p_dec,
{
decoder_sys_t *p_sys = p_dec->p_sys;
OMX_PARAM_PORTDEFINITIONTYPE *def = &p_port->definition;
- int i_profile = 0xFFFF, i_level = 0xFFFF;
+ size_t i_profile = 0xFFFF, i_level = 0xFFFF;
/* Try to find out the profile of the video */
- while(p_fmt->i_cat == VIDEO_ES && def->eDir == OMX_DirInput &&
- p_fmt->i_codec == VLC_CODEC_H264)
- {
- uint8_t *p = (uint8_t*)p_dec->fmt_in.p_extra;
- if(!p || !p_dec->fmt_in.p_extra) break;
-
- /* Check the profile / level */
- if(p_dec->fmt_in.i_original_fourcc == VLC_FOURCC('a','v','c','1') &&
- p[0] == 1)
- {
- if(p_dec->fmt_in.i_extra < 12) break;
- p_sys->i_nal_size_length = 1 + (p[4]&0x03);
- if( !(p[5]&0x1f) ) break;
- p += 8;
- }
- else
- {
- if(p_dec->fmt_in.i_extra < 8) break;
- if(!p[0] && !p[1] && !p[2] && p[3] == 1) p += 4;
- else if(!p[0] && !p[1] && p[2] == 1) p += 3;
- else break;
- }
-
- if( ((*p++)&0x1f) != 7) break;
-
- /* Get profile/level out of first SPS */
- i_profile = p[0];
- i_level = p[2];
- break;
- }
+ if(p_fmt->i_cat == VIDEO_ES && def->eDir == OMX_DirInput &&
+ p_fmt->i_codec == VLC_CODEC_H264)
+ h264_get_profile_level(&p_dec->fmt_in, &i_profile, &i_level, &p_sys->i_nal_size_length);
if(!strcmp(p_sys->psz_component, "OMX.TI.Video.Decoder"))
{
diff --git a/modules/codec/omxil/omxil_utils.h b/modules/codec/omxil/omxil_utils.h
index 6aa9e12..78f05da 100644
--- a/modules/codec/omxil/omxil_utils.h
+++ b/modules/codec/omxil/omxil_utils.h
@@ -256,3 +256,8 @@ unsigned int GetAudioParamSize(OMX_INDEXTYPE index);
#define QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka 0x7FA30C03
#define OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m 0x7FA30C04
#define OMX_IndexVendorSetYUV420pMode 0x7f000003
+
+/*****************************************************************************
+ * H264 specific code
+ *****************************************************************************/
+bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile, size_t *p_level, size_t *p_nal_size);
diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 56563da..f2ef79c 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -1043,3 +1043,33 @@ void PrintOmx(decoder_t *p_dec, OMX_HANDLETYPE omx_handle, OMX_U32 i_port)
}
}
}
+
+bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile, size_t *p_level, size_t *p_nal_size)
+{
+ uint8_t *p = (uint8_t*)p_fmt->p_extra;
+ if(!p || !p_fmt->p_extra) return false;
+
+ /* Check the profile / level */
+ if(p_fmt->i_original_fourcc == VLC_FOURCC('a','v','c','1') &&
+ p[0] == 1)
+ {
+ if(p_fmt->i_extra < 12) return false;
+ if (p_nal_size) *p_nal_size = 1 + (p[4]&0x03);
+ if( !(p[5]&0x1f) ) return false;
+ p += 8;
+ }
+ else
+ {
+ if(p_fmt->i_extra < 8) return false;
+ if(!p[0] && !p[1] && !p[2] && p[3] == 1) p += 4;
+ else if(!p[0] && !p[1] && p[2] == 1) p += 3;
+ else return false;
+ }
+
+ if( ((*p++)&0x1f) != 7) return false;
+
+ /* Get profile/level out of first SPS */
+ if (p_profile) *p_profile = p[0];
+ if (p_level) *p_level = p[2];
+ return true;
+}
--
1.8.3.2
More information about the vlc-devel
mailing list