Commit c3dec45d authored by Thomas Guillem's avatar Thomas Guillem

h264_nal: remove unused H264ConvertState

parent 0706192d
......@@ -575,8 +575,7 @@ static int ProcessInputStream(decoder_t *p_dec, DWORD stream_id, block_t *p_bloc
if (p_dec->fmt_in.i_codec == VLC_CODEC_H264)
{
/* in-place NAL to annex B conversion. */
struct H264ConvertState convert_state = { 0, 0 };
convert_h264_to_annexb(buffer_start, p_block->i_buffer, p_sys->nal_size, &convert_state);
convert_h264_to_annexb(buffer_start, p_block->i_buffer, p_sys->nal_size);
}
hr = IMFMediaBuffer_Unlock(input_media_buffer);
......
......@@ -1126,14 +1126,13 @@ static void H264ProcessBlock(decoder_t *p_dec, block_t *p_block,
bool *p_csd_changed, bool *p_size_changed)
{
decoder_sys_t *p_sys = p_dec->p_sys;
struct H264ConvertState convert_state = { 0, 0 };
assert(p_dec->fmt_in.i_codec == VLC_CODEC_H264 && p_block);
if (p_sys->u.video.i_nal_size)
{
convert_h264_to_annexb(p_block->p_buffer, p_block->i_buffer,
p_sys->u.video.i_nal_size, &convert_state);
p_sys->u.video.i_nal_size);
} else if (H264SetCSD(p_dec, p_block->p_buffer, p_block->i_buffer,
p_size_changed) == VLC_SUCCESS)
{
......@@ -1145,14 +1144,13 @@ static void HEVCProcessBlock(decoder_t *p_dec, block_t *p_block,
bool *p_csd_changed, bool *p_size_changed)
{
decoder_sys_t *p_sys = p_dec->p_sys;
struct H264ConvertState convert_state = { 0, 0 };
assert(p_dec->fmt_in.i_codec == VLC_CODEC_HEVC && p_block);
if (p_sys->u.video.i_nal_size)
{
convert_h264_to_annexb(p_block->p_buffer, p_block->i_buffer,
p_sys->u.video.i_nal_size, &convert_state);
p_sys->u.video.i_nal_size);
}
/* TODO */
......
......@@ -1430,7 +1430,6 @@ static int DecodeVideoInput( decoder_t *p_dec, OmxPort *p_port, block_t **pp_blo
{
decoder_sys_t *p_sys = p_dec->p_sys;
OMX_BUFFERHEADERTYPE *p_header;
struct H264ConvertState convert_state = { 0, 0 };
block_t *p_block = *pp_block;
/* Send the input buffer to the component */
......@@ -1486,7 +1485,7 @@ static int DecodeVideoInput( decoder_t *p_dec, OmxPort *p_port, block_t **pp_blo
* i_nal_size_length == 0, which is the case for codecs other
* than H.264 */
convert_h264_to_annexb( p_header->pBuffer, p_header->nFilledLen,
p_sys->i_nal_size_length, &convert_state );
p_sys->i_nal_size_length);
OMX_DBG( "EmptyThisBuffer %p, %p, %i, %"PRId64, p_header, p_header->pBuffer,
(int)p_header->nFilledLen, FromOmxTicks(p_header->nTimeStamp) );
OMX_EmptyThisBuffer(p_port->omx_handle, p_header);
......
......@@ -102,40 +102,41 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
}
void convert_h264_to_annexb( uint8_t *p_buf, uint32_t i_len,
size_t i_nal_size,
struct H264ConvertState *state )
size_t i_nal_size )
{
uint32_t nal_len = 0, nal_pos = 0;
if( i_nal_size < 3 || i_nal_size > 4 )
return;
/* This only works for NAL sizes 3-4 */
while( i_len > 0 )
{
if( state->nal_pos < i_nal_size ) {
if( nal_pos < i_nal_size ) {
unsigned int i;
for( i = 0; state->nal_pos < i_nal_size && i < i_len; i++, state->nal_pos++ ) {
state->nal_len = (state->nal_len << 8) | p_buf[i];
for( i = 0; nal_pos < i_nal_size && i < i_len; i++, nal_pos++ ) {
nal_len = (nal_len << 8) | p_buf[i];
p_buf[i] = 0;
}
if( state->nal_pos < i_nal_size )
if( nal_pos < i_nal_size )
return;
p_buf[i - 1] = 1;
p_buf += i;
i_len -= i;
}
if( state->nal_len > INT_MAX )
if( nal_len > INT_MAX )
return;
if( state->nal_len > i_len )
if( nal_len > i_len )
{
state->nal_len -= i_len;
nal_len -= i_len;
return;
}
else
{
p_buf += state->nal_len;
i_len -= state->nal_len;
state->nal_len = 0;
state->nal_pos = 0;
p_buf += nal_len;
i_len -= nal_len;
nal_len = 0;
nal_pos = 0;
}
}
}
......
......@@ -120,15 +120,8 @@ int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
uint32_t i_out_buf_size, uint32_t *p_sps_pps_size,
uint32_t *p_nal_size);
/* Convert H.264 NAL format to annex b in-place */
struct H264ConvertState {
uint32_t nal_len;
uint32_t nal_pos;
};
void convert_h264_to_annexb( uint8_t *p_buf, uint32_t i_len,
size_t i_nal_size,
struct H264ConvertState *state );
size_t i_nal_size );
/* Get the SPS/PPS pointers from an Annex B buffer
* Returns 0 if a SPS and/or a PPS is found */
......
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