[vlc-devel] [PATCH 2/2] Add a simple raw hevc demux
Vittorio Giovara
vittorio.giovara at gmail.com
Tue Feb 11 06:22:30 CET 2014
Hi Denia
On Tuesday, February 11, 2014, Denis Charmet <typx at dinauz.org> wrote:
> ---
> modules/demux/Makefile.am | 3 +
> modules/demux/mpeg/hevc.c | 349
> ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 352 insertions(+)
> create mode 100644 modules/demux/mpeg/hevc.c
>
>
> +
> +
> +static void skipProfileTiersLevel( bs_t * bs, int32_t
> max_sub_layer_minus1 )
> +{
> + uint8_t sub_layer_profile_present_flag[8];
> + uint8_t sub_layer_level_present_flag[8];
> +
> + /* skipping useless fields of the VPS see
> https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.265-201304-I!!PDF-E&type=item*/
> + bs_skip( bs, 2 + 1 + 5 + 32 + 1 + 1 + 1 + 1 + 44 + 8 );
> +
> + for( int32_t i = 0; i < max_sub_layer_minus1; i++ )
Shouldn't this be <= ?
> + {
> + sub_layer_profile_present_flag[i] = bs_read1( bs );
> + sub_layer_level_present_flag[i] = bs_read1( bs );
> + }
> +
> + if(max_sub_layer_minus1 > 0)
> + bs_skip( bs, (8 - max_sub_layer_minus1) * 2 );
> +
> + for( int32_t i = 0; i < max_sub_layer_minus1; i++ )
Ditto
> + {
> + if( sub_layer_profile_present_flag[i] )
> + bs_skip( bs, 2 + 1 + 5 + 32 + 1 + 1 + 1 + 1 + 44 );
> + if( sub_layer_level_present_flag[i] )
> + bs_skip( bs, 8 );
> + }
> +}
> +
> +static uint32_t read_ue( bs_t * bs )
> +{
> + int32_t i = 0;
> +
> + while( bs_read1( bs ) == 0 && bs->p < bs->p_end && i < 32 )
> + i++;
> +
> + return (1 << i) - 1 + bs_read( bs, i );
> +}
> +
> +static int32_t getFPS( demux_t *p_demux, block_t * p_block )
> +{
> + demux_sys_t *p_sys = p_demux->p_sys;
> +
> + bs_t bs;
> + uint8_t * p_decoded_nal;
> + int i_decoded_nal;
> +
> + if( p_block->i_buffer < 5 )
> + return -1;
> +
> + CreateDecodedNAL( &p_decoded_nal, &i_decoded_nal,
> + p_block->p_buffer+3, p_block->i_buffer-3 );
> +
> + if( !p_decoded_nal )
> + return -1;
> +
> + bs_init( &bs, p_decoded_nal, i_decoded_nal );
> + bs_skip( &bs, 12 );
> + int32_t max_sub_layer_minus1 = bs_read( &bs, 3 );
IMHO I find it clearer when the _minus1 is dropped from the variable and +1
is summed to it, especially if you have to loop on them (but that's just a
personal opinion)
> + bs_skip( &bs, 17 );
> +
> + skipProfileTiersLevel( &bs, max_sub_layer_minus1 );
> +
> + int32_t vps_sub_layer_ordering_info_present_flag = bs_read1( &bs );
> + int32_t i = vps_sub_layer_ordering_info_present_flag? 0 :
> max_sub_layer_minus1;
> + for( ; i <= max_sub_layer_minus1; i++ )
Slightly hard to read, wouldn't a plain
if (vps_sub_layer_ordering_info_present_flag)
be just as effective?
Vittorio
+ {
> + read_ue( &bs );
> + read_ue( &bs );
> + read_ue( &bs );
> + }
> + uint32_t vps_max_layer_id = bs_read( &bs, 6);
> + uint32_t vps_num_layer_sets_minus1 = read_ue( &bs );
> + bs_skip( &bs, vps_max_layer_id * vps_num_layer_sets_minus1 );
> +
> + if( bs_read1( &bs ))
> + {
> + uint32_t num_units_in_tick = bs_read( &bs, 32 );
> + uint32_t time_scale = bs_read( &bs, 32 );
> + if( num_units_in_tick )
> + {
> + p_sys->f_fps = ( (float) time_scale )/( (float)
> num_units_in_tick );
> + msg_Dbg(p_demux,"Using framerate %f fps from VPS",
> p_sys->f_fps);
> + }
> + else
> + {
> + msg_Err( p_demux, "vps_num_units_in_tick null defaulting to
> 25 fps");
> + p_sys->f_fps = 25.0f;
> + }
> + }
> + else
> + {
> + msg_Err( p_demux, "No timing info in VPS defaulting to 25 fps");
> + p_sys->f_fps = 25.0f;
> + }
> + free(p_decoded_nal);
> + return 0;
> +}
> --
> 1.9.rc1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140211/77fb24fc/attachment.html>
More information about the vlc-devel
mailing list