Commit 3bdc428b authored by Felix Abecassis's avatar Felix Abecassis Committed by Jean-Baptiste Kempf

omxil: move code to parse profile and level of H264 format to omx_utils.h

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 91a4846e
......@@ -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"))
{
......
......@@ -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);
......@@ -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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment