Commit 99986702 authored by Felix Abecassis's avatar Felix Abecassis

h264: refactor Exp-Golomb reading functions with existing mpeg demuxing code

parent d3571381
......@@ -263,12 +263,12 @@ static int32_t getFPS( demux_t *p_demux, block_t * p_block )
int32_t i = vps_sub_layer_ordering_info_present_flag? 0 : max_sub_layer_minus1;
for( ; i <= max_sub_layer_minus1; i++ )
{
read_ue( &bs );
read_ue( &bs );
read_ue( &bs );
bs_read_ue( &bs );
bs_read_ue( &bs );
bs_read_ue( &bs );
}
uint32_t vps_max_layer_id = bs_read( &bs, 6);
uint32_t vps_num_layer_sets_minus1 = read_ue( &bs );
uint32_t vps_num_layer_sets_minus1 = bs_read_ue( &bs );
bs_skip( &bs, vps_max_layer_id * vps_num_layer_sets_minus1 );
if( bs_read1( &bs ))
......
......@@ -51,7 +51,8 @@ static inline void hevc_skip_profile_tiers_level( bs_t * bs, int32_t max_sub_lay
}
}
static inline uint32_t read_ue( bs_t * bs )
/* Read unsigned Exp-Golomb code */
static inline uint32_t bs_read_ue( bs_t * bs )
{
int32_t i = 0;
......@@ -61,6 +62,13 @@ static inline uint32_t read_ue( bs_t * bs )
return (1 << i) - 1 + bs_read( bs, i );
}
/* Read signed Exp-Golomb code */
static inline int32_t bs_read_se( bs_t *s )
{
int val = bs_read_ue( s );
return val&0x01 ? (val+1)/2 : -(val/2);
}
static inline size_t nal_decode(uint8_t * p_src, uint8_t * p_dst, size_t i_size)
{
......
......@@ -856,26 +856,26 @@ static void hevcParseSPS(uint8_t * p_buffer, size_t i_buffer, uint8_t * chroma_i
hevc_skip_profile_tiers_level(&bs, sps_max_sublayer_minus1);
/* skip sps id */
(void) read_ue( &bs );
(void) bs_read_ue( &bs );
*chroma_idc = read_ue(&bs);
*chroma_idc = bs_read_ue(&bs);
if (*chroma_idc == 3)
bs_skip(&bs, 1);
/* skip width and heigh */
(void) read_ue( &bs );
(void) read_ue( &bs );
(void) bs_read_ue( &bs );
(void) bs_read_ue( &bs );
uint32_t conformance_window_flag = bs_read1(&bs);
if (conformance_window_flag) {
/* skip offsets*/
(void) read_ue(&bs);
(void) read_ue(&bs);
(void) read_ue(&bs);
(void) read_ue(&bs);
(void) bs_read_ue(&bs);
(void) bs_read_ue(&bs);
(void) bs_read_ue(&bs);
(void) bs_read_ue(&bs);
}
*bit_depth_luma_minus8 = read_ue(&bs);
*bit_depth_chroma_minus8 = read_ue(&bs);
*bit_depth_luma_minus8 = bs_read_ue(&bs);
*bit_depth_chroma_minus8 = bs_read_ue(&bs);
}
static bo_t *GetHvcCTag(mp4_stream_t *p_stream)
......
......@@ -42,6 +42,7 @@
#include <vlc_bits.h>
#include "../codec/cc.h"
#include "packetizer_helper.h"
#include "../demux/mpeg/mpeg_parser_helpers.h"
/*****************************************************************************
* Module descriptor
......@@ -572,24 +573,6 @@ static void CreateDecodedNAL( uint8_t **pp_ret, int *pi_ret,
*pi_ret = dst - *pp_ret;
}
static inline int bs_read_ue( bs_t *s )
{
int i = 0;
while( bs_read1( s ) == 0 && s->p < s->p_end && i < 32 )
{
i++;
}
return( ( 1 << i) - 1 + bs_read( s, i ) );
}
static inline int bs_read_se( bs_t *s )
{
int val = bs_read_ue( s );
return val&0x01 ? (val+1)/2 : -(val/2);
}
/*****************************************************************************
* ParseNALBlock: parses annexB type NALs
* All p_frag blocks are required to start with 0 0 0 1 4-byte startcode
......
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