/* Useful values of the Slice Header */
int i_nal_type;
+ int i_nal_ref_idc;
int i_idr_pic_id;
int i_frame_num;
};
p_sys->b_sps = VLC_FALSE;
p_sys->i_nal_type = -1;
+ p_sys->i_nal_ref_idc = -1;
p_sys->i_idr_pic_id = -1;
p_sys->i_frame_num = -1;
/* Setup properties */
es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
p_dec->fmt_out.i_codec = VLC_FOURCC( 'h', '2', '6', '4' );
+ /* FIXME: FFMPEG isn't happy at all if you leave this */
+ if( p_dec->fmt_out.i_extra ) free( p_dec->fmt_out.p_extra );
+ p_dec->fmt_out.i_extra = 0; p_dec->fmt_out.p_extra = 0;
if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'v', 'c', '1' ) )
{
p_dec->pf_packetize = Packetize;
}
+ block_ChainRelease( p_sys->p_frame );
+ p_sys->p_frame = 0;
return VLC_SUCCESS;
}
{
case STATE_NOSYNC:
if( block_FindStartcodeFromOffset( &p_sys->bytestream,
- &p_sys->i_offset, p_sys->startcode, 4 ) == VLC_SUCCESS )
+ &p_sys->i_offset, p_sys->startcode+1, 3 ) == VLC_SUCCESS)
{
p_sys->i_state = STATE_NEXT_SYNC;
}
case STATE_NEXT_SYNC:
/* Find the next startcode */
if( block_FindStartcodeFromOffset( &p_sys->bytestream,
- &p_sys->i_offset, p_sys->startcode, 4 ) != VLC_SUCCESS )
+ &p_sys->i_offset, p_sys->startcode, 3 ) != VLC_SUCCESS)
{
- /* Need more data */
- return NULL;
+ if( block_FindStartcodeFromOffset( &p_sys->bytestream,
+ &p_sys->i_offset, p_sys->startcode+1, 3 ) !=
+ VLC_SUCCESS )
+ {
+ /* Need more data */
+ return NULL;
+ }
}
/* Get the new fragment and set the pts/dts */
{
block_t *p_nal;
- p_nal = block_New( p_dec, 4 + i_size );
+ p_nal = block_New( p_dec, 3 + i_size );
/* Add start code */
p_nal->p_buffer[0] = 0x00;
p_nal->p_buffer[1] = 0x00;
- p_nal->p_buffer[2] = 0x00;
- p_nal->p_buffer[3] = 0x01;
+ p_nal->p_buffer[2] = 0x01;
/* Copy nalu */
- memcpy( &p_nal->p_buffer[4], p, i_size );
+ memcpy( &p_nal->p_buffer[3], p, i_size );
return p_nal;
}
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_pic = NULL;
- const int i_ref_idc = (p_frag->p_buffer[4] >> 5)&0x03;
- const int i_nal_type = p_frag->p_buffer[4]&0x1f;
+ const int i_nal_ref_idc = (p_frag->p_buffer[3] >> 5)&0x03;
+ const int i_nal_type = p_frag->p_buffer[3]&0x1f;
if( p_sys->b_slice && !p_sys->b_sps )
{
bs_t s;
/* do not convert the whole frame */
- nal_get_decoded( &dec, &i_dec, &p_frag->p_buffer[5],
- __MIN( p_frag->i_buffer - 5, 60 ) );
+ nal_get_decoded( &dec, &i_dec, &p_frag->p_buffer[4],
+ __MIN( p_frag->i_buffer - 4, 60 ) );
bs_init( &s, dec, i_dec );
/* first_mb_in_slice */
/* frame_num */
i_frame_num = bs_read( &s, p_sys->i_log2_max_frame_num + 4 );
- if( i_nal_type != NAL_SLICE_IDR && i_frame_num != p_sys->i_frame_num )
+ /* Detection of the first VCL NAL unit of a primary coded picture
+ * (cf. 7.4.1.2.4) */
+ if( i_frame_num != p_sys->i_frame_num ||
+ ( (i_nal_ref_idc != p_sys->i_nal_ref_idc) &&
+ (!i_nal_ref_idc || !p_sys->i_nal_ref_idc) ) )
{
b_pic = VLC_TRUE;
}
p_sys->i_frame_num = i_frame_num;
+ p_sys->i_nal_ref_idc = i_nal_ref_idc;
if( !p_sys->b_frame_mbs_only )
{
p_sys->b_sps = VLC_TRUE;
- nal_get_decoded( &dec, &i_dec, &p_frag->p_buffer[5],
- p_frag->i_buffer - 5 );
+ nal_get_decoded( &dec, &i_dec, &p_frag->p_buffer[4],
+ p_frag->i_buffer - 4 );
bs_init( &s, dec, i_dec );
/* Skip profile(8), constraint_set012, reserver(5), level(8) */
/* b_direct8x8_inference */
bs_skip( &s, 1 );
- /* crop ? */
+ /* crop */
i_tmp = bs_read( &s, 1 );
if( i_tmp )
{
/* left */
- p_dec->fmt_out.video.i_width -= 2 * bs_read_ue( &s );
+ bs_read_ue( &s );
/* right */
- p_dec->fmt_out.video.i_width -= 2 * bs_read_ue( &s );
+ bs_read_ue( &s );
/* top */
- p_dec->fmt_out.video.i_height -= 2 * bs_read_ue( &s );
+ bs_read_ue( &s );
/* bottom */
- p_dec->fmt_out.video.i_height -= 2 * bs_read_ue( &s );
+ bs_read_ue( &s );
}
/* vui */
else if( i_nal_type == NAL_PPS )
{
bs_t s;
- bs_init( &s, &p_frag->p_buffer[5], p_frag->i_buffer - 5 );
+ bs_init( &s, &p_frag->p_buffer[4], p_frag->i_buffer - 4 );
/* TODO */
msg_Dbg( p_dec, "found NAL_PPS" );