Commit 15714d17 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Move h264_get_profile_level from OMX to the h264_nal helper file

parent c11981de
......@@ -38,7 +38,7 @@ static int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
}
/* Read infos in first 6 bytes */
i_profile = (p_buf[1] << 16) | (p_buf[2] << 8) | p_buf[3];
i_profile = (p_buf[1] << 16) | (p_buf[2] << 8) | p_buf[3];
if (p_nal_size)
*p_nal_size = (p_buf[4] & 0x03) + 1;
p_buf += 5;
......@@ -142,3 +142,35 @@ static void convert_h264_to_annexb( uint8_t *p_buf, uint32_t i_len,
}
}
}
/* Get level and Profile */
static 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;
}
......@@ -260,8 +260,6 @@ unsigned int GetAudioParamSize(OMX_INDEXTYPE index);
/*****************************************************************************
* 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);
size_t convert_omx_to_profile_idc(OMX_VIDEO_AVCPROFILETYPE profile_type);
size_t convert_omx_to_level_idc(OMX_VIDEO_AVCLEVELTYPE level_type);
......@@ -1044,35 +1044,6 @@ 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;
}
static const struct
{
OMX_VIDEO_AVCPROFILETYPE omx_profile;
......
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