]> git.sesse.net Git - vlc/blobdiff - modules/codec/omxil/omxil.c
omxil: move code to parse profile and level of H264 format to omx_utils.h
[vlc] / modules / codec / omxil / omxil.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"))
     {