# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_codec.h>
#include <vlc_block.h>
vlc_module_begin();
set_category( CAT_SOUT );
set_subcategory( SUBCAT_SOUT_PACKETIZER );
- set_description( _("H.264 video packetizer") );
+ set_description( N_("H.264 video packetizer") );
set_capability( "packetizer", 50 );
set_callbacks( Open, Close );
vlc_module_end();
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys = malloc( sizeof(decoder_sys_t) ) ) == NULL )
{
- msg_Err( p_dec, "out of memory" );
- return VLC_EGENERIC;
+ return VLC_ENOMEM;
}
p_sys->i_state = STATE_NOSYNC;
p_sys->i_offset = 0;
p_sys->i_avcC_length_size, i_sps, i_pps );
/* 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 = NULL;
+ if( p_dec->fmt_out.i_extra > 0 ) free( p_dec->fmt_out.p_extra );
+ p_dec->fmt_out.i_extra = 0;
+ p_dec->fmt_out.p_extra = NULL;
/* Set the new extradata */
p_dec->fmt_out.i_extra = p_sys->p_pps->i_buffer + p_sys->p_sps->i_buffer;
- p_dec->fmt_out.p_extra = (uint8_t*)malloc( p_dec->fmt_out.i_extra );
+ p_dec->fmt_out.p_extra = malloc( p_dec->fmt_out.i_extra );
if( p_dec->fmt_out.p_extra )
{
- memcpy( (uint8_t*)p_dec->fmt_out.p_extra, p_sys->p_sps->p_buffer, p_sys->p_sps->i_buffer);
- memcpy( (uint8_t*)p_dec->fmt_out.p_extra+p_sys->p_sps->i_buffer, p_sys->p_pps->p_buffer, p_sys->p_pps->i_buffer);
+ memcpy( (uint8_t*)p_dec->fmt_out.p_extra,
+ p_sys->p_sps->p_buffer, p_sys->p_sps->i_buffer);
+ memcpy( (uint8_t*)p_dec->fmt_out.p_extra+p_sys->p_sps->i_buffer,
+ p_sys->p_pps->p_buffer, p_sys->p_pps->i_buffer);
p_sys->b_header = true;
}
else p_dec->fmt_out.i_extra = 0;
break;
}
#if 0
- msg_Dbg( p_dec, "pts="I64Fd" dts="I64Fd,
+ msg_Dbg( p_dec, "pts=%"PRId64" dts=%"PRId64,
p_pic->i_pts, p_pic->i_dts );
#endif
/* Copy nalu */
memcpy( &p_nal->p_buffer[4], p, i_size );
+ VLC_UNUSED(p_dec);
return p_nal;
}
* ParseNALBlock: parses annexB type NALs
* All p_frag blocks are required to start with 0 0 0 1 4-byte startcode
*****************************************************************************/
+static block_t *OutputPicture( decoder_t *p_dec )
+{
+ decoder_sys_t *p_sys = p_dec->p_sys;
+ block_t *p_pic;
+
+ if( !p_sys->b_header && p_sys->slice.i_frame_type != BLOCK_FLAG_TYPE_I)
+ return NULL;
+
+ if( p_sys->slice.i_frame_type == BLOCK_FLAG_TYPE_I && p_sys->p_sps && p_sys->p_pps )
+ {
+ block_t *p_sps = block_Duplicate( p_sys->p_sps );
+ block_t *p_pps = block_Duplicate( p_sys->p_pps );
+ p_sps->i_dts = p_sys->p_frame->i_dts;
+ p_sps->i_pts = p_sys->p_frame->i_pts;
+ block_ChainAppend( &p_sps, p_pps );
+ block_ChainAppend( &p_sps, p_sys->p_frame );
+ p_sys->b_header = true;
+ p_pic = block_ChainGather( p_sps );
+ }
+ else
+ {
+ p_pic = block_ChainGather( p_sys->p_frame );
+ }
+ p_pic->i_length = 0; /* FIXME */
+ p_pic->i_flags |= p_sys->slice.i_frame_type;
+
+ p_sys->slice.i_frame_type = 0;
+ p_sys->p_frame = NULL;
+ p_sys->b_slice = false;
+
+ return p_pic;
+}
+
static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
{
decoder_sys_t *p_sys = p_dec->p_sys;
const int i_nal_ref_idc = (p_frag->p_buffer[4] >> 5)&0x03;
const int i_nal_type = p_frag->p_buffer[4]&0x1f;
-#define OUTPUT \
- do { \
- if( !p_sys->b_header && p_sys->slice.i_frame_type != BLOCK_FLAG_TYPE_I) \
- break; \
- \
- if( p_sys->slice.i_frame_type == BLOCK_FLAG_TYPE_I && p_sys->p_sps && p_sys->p_pps ) \
- { \
- block_t *p_sps = block_Duplicate( p_sys->p_sps ); \
- block_t *p_pps = block_Duplicate( p_sys->p_pps ); \
- p_sps->i_dts = p_sys->p_frame->i_dts; \
- p_sps->i_pts = p_sys->p_frame->i_pts; \
- block_ChainAppend( &p_sps, p_pps ); \
- block_ChainAppend( &p_sps, p_sys->p_frame ); \
- p_sys->b_header = true; \
- p_pic = block_ChainGather( p_sps ); \
- } else { \
- p_pic = block_ChainGather( p_sys->p_frame ); \
- } \
- p_pic->i_length = 0; /* FIXME */ \
- p_pic->i_flags |= p_sys->slice.i_frame_type; \
- \
- p_sys->slice.i_frame_type = 0; \
- p_sys->p_frame = NULL; \
- p_sys->b_slice = false; \
- } while(0)
-
if( p_sys->b_slice && ( !p_sys->b_sps || !p_sys->b_pps ) )
{
block_ChainRelease( p_sys->p_frame );
p_sys->slice = slice;
if( b_pic && p_sys->b_slice )
- OUTPUT;
+ p_pic = OutputPicture( p_dec );
p_sys->b_slice = true;
free( dec );
- if( p_sys->b_slice ) OUTPUT;
+ if( p_sys->b_slice )
+ p_pic = OutputPicture( p_dec );
/* We have a new SPS */
if( p_sys->p_sps ) block_Release( p_sys->p_sps );
/* TODO */
- if( p_sys->b_slice ) OUTPUT;
+ if( p_sys->b_slice )
+ p_pic = OutputPicture( p_dec );
/* We have a new PPS */
if( p_sys->p_pps ) block_Release( p_sys->p_pps );
i_nal_type == NAL_SEI ||
( i_nal_type >= 13 && i_nal_type <= 18 ) )
{
- if( p_sys->b_slice ) OUTPUT;
+ if( p_sys->b_slice )
+ p_pic = OutputPicture( p_dec );
}
-#undef OUTPUT
-
/* Append the block */
block_ChainAppend( &p_sys->p_frame, p_frag );