]> git.sesse.net Git - vlc/commitdiff
omxil: move code to parse profile and level of H264 format to omx_utils.h
authorFelix Abecassis <felix.abecassis@gmail.com>
Sun, 9 Feb 2014 17:22:28 +0000 (18:22 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 9 Feb 2014 19:21:25 +0000 (20:21 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/omxil/omxil.c
modules/codec/omxil/omxil_utils.h
modules/codec/omxil/utils.c

index 2800e448da85d8a52d3760ca4f68de0b67000324..e3e34c485242e2c7734b250e4374d1b980fd8738 100644 (file)
@@ -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"))
     {
index 6aa9e12e921673e81868940c002429d73f3b69d2..78f05da2a9ddd82106c59bab6538ec20d30d81b2 100644 (file)
@@ -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);
index 56563daee4cd966bbad5dcbc874907411c82f27c..f2ef79cc972ebb94cd21e424632f880fcc5a5d46 100644 (file)
@@ -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;
+}