#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_sout.h>
-#include <vlc_vout.h>
#include <schroedinger/schro.h>
decoder_sys_t *p_sys;
SchroDecoder *p_schro;
- if( p_dec->fmt_in.i_codec != VLC_FOURCC('d','r','a','c') )
+ if( p_dec->fmt_in.i_codec != VLC_CODEC_DIRAC )
{
return VLC_EGENERIC;
}
p_dec->p_sys = p_sys;
p_sys->p_schro = p_schro;
p_sys->p_format = NULL;
- p_sys->i_lastpts = -1;
+ p_sys->i_lastpts = VLC_TS_INVALID;
p_sys->i_frame_pts_delta = 0;
- /* request packetizer */
- p_dec->b_need_packetized = true;
-
/* Set output properties */
p_dec->fmt_out.i_cat = VIDEO_ES;
- p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0');
+ p_dec->fmt_out.i_codec = VLC_CODEC_I420;
/* Set callbacks */
p_dec->pf_decode_video = DecodeBlock;
static void SetVideoFormat( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
- double f_aspect;
p_sys->p_format = schro_decoder_get_video_format(p_sys->p_schro);
if( p_sys->p_format == NULL ) return;
switch( p_sys->p_format->chroma_format )
{
- case SCHRO_CHROMA_420: p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0'); break;
- case SCHRO_CHROMA_422: p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','2'); break;
- case SCHRO_CHROMA_444: p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','4','4'); break;
+ case SCHRO_CHROMA_420: p_dec->fmt_out.i_codec = VLC_CODEC_I420; break;
+ case SCHRO_CHROMA_422: p_dec->fmt_out.i_codec = VLC_CODEC_I422; break;
+ case SCHRO_CHROMA_444: p_dec->fmt_out.i_codec = VLC_CODEC_I444; break;
default:
p_dec->fmt_out.i_codec = 0;
break;
}
- p_dec->fmt_out.video.i_visible_width =
+ p_dec->fmt_out.video.i_visible_width = p_sys->p_format->clean_width;
+ p_dec->fmt_out.video.i_x_offset = p_sys->p_format->left_offset;
p_dec->fmt_out.video.i_width = p_sys->p_format->width;
- p_dec->fmt_out.video.i_visible_height =
+ p_dec->fmt_out.video.i_visible_height = p_sys->p_format->clean_height;
+ p_dec->fmt_out.video.i_y_offset = p_sys->p_format->top_offset;
p_dec->fmt_out.video.i_height = p_sys->p_format->height;
/* aspect_ratio_[numerator|denominator] describes the pixel aspect ratio */
- f_aspect = (double)
- ( p_sys->p_format->aspect_ratio_numerator * p_sys->p_format->width ) /
- ( p_sys->p_format->aspect_ratio_denominator * p_sys->p_format->height);
-
- p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * f_aspect;
+ p_dec->fmt_out.video.i_sar_num = p_sys->p_format->aspect_ratio_numerator;
+ p_dec->fmt_out.video.i_sar_den = p_sys->p_format->aspect_ratio_denominator;
p_dec->fmt_out.video.i_frame_rate =
p_sys->p_format->frame_rate_numerator;
static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
- uint32_t u_pnum;
if( !pp_block ) return NULL;
/* reset the decoder when seeking as the decode in progress is invalid */
/* discard the block as it is just a null magic block */
- if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) {
+ if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY ) {
schro_decoder_reset( p_sys->p_schro );
- p_sys->i_lastpts = -1;
-
+ p_sys->i_lastpts = VLC_TS_INVALID;
block_Release( p_block );
*pp_block = NULL;
return NULL;
p_schrobuffer = schro_buffer_new_with_data( p_block->p_buffer, p_block->i_buffer );
p_schrobuffer->free = SchroBufferFree;
p_schrobuffer->priv = p_block;
- mtime_t *p_pts = malloc( sizeof(*p_pts) );
- if( p_pts ) {
- *p_pts = p_block->i_pts;
- /* if this call fails, p_pts is freed automatically */
- p_schrobuffer->tag = schro_tag_new( p_pts, free );
+ if( p_block->i_pts > VLC_TS_INVALID ) {
+ mtime_t *p_pts = malloc( sizeof(*p_pts) );
+ if( p_pts ) {
+ *p_pts = p_block->i_pts;
+ /* if this call fails, p_pts is freed automatically */
+ p_schrobuffer->tag = schro_tag_new( p_pts, free );
+ }
}
/* this stops the same block being fed back into this function if
case SCHRO_DECODER_OK: {
SchroTag *p_tag = schro_decoder_get_picture_tag( p_sys->p_schro );
- u_pnum = schro_decoder_get_picture_number( p_sys->p_schro );
p_schroframe = schro_decoder_pull( p_sys->p_schro );
- if( !p_schroframe->priv )
+ if( !p_schroframe || !p_schroframe->priv )
{
/* frame can't be one that was allocated by us
* -- no private data: discard */
if( p_tag ) schro_tag_free( p_tag );
- schro_frame_unref( p_schroframe );
+ if( p_schroframe ) schro_frame_unref( p_schroframe );
break;
}
p_pic = ((struct picture_free_t*) p_schroframe->priv)->p_pic;
p_schroframe->priv = NULL;
- /* solve presentation time stamp for picture. If this picture
- * was not tagged with a pts when presented to decoder, interpolate
- * one
- * This means no need to set p_pic->b_force, as we have a pts on
- * each picture */
if( p_tag )
{
/* free is handled by schro_frame_unref */
p_pic->date = *(mtime_t*) p_tag->value;
schro_tag_free( p_tag );
- msg_Err(p_dec, "pts out: %"PRId64, p_pic->date);
}
- else if( p_sys->i_lastpts >= 0 )
+ else if( p_sys->i_lastpts > VLC_TS_INVALID )
{
+ /* NB, this shouldn't happen since the packetizer does a
+ * very thorough job of inventing timestamps. The
+ * following is just a very rough fall back incase packetizer
+ * is missing. */
+ /* maybe it would be better to set p_pic->b_force ? */
p_pic->date = p_sys->i_lastpts + p_sys->i_frame_pts_delta;
- /* fixme */
- msg_Err(p_dec, "no pts");
}
p_sys->i_lastpts = p_pic->date;