1 /*****************************************************************************
2 * decoder.c: stats decoder plugin for vlc.
3 *****************************************************************************
4 * Copyright (C) 2002-2008 the VideoLAN team
6 * Authors: Samuel Hocevar <sam@zoy.org>
7 * Pierre d'Herbemont <pdherbemont@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_codec.h>
36 /*****************************************************************************
38 *****************************************************************************/
39 static picture_t
*DecodeBlock( decoder_t
*p_dec
, block_t
**pp_block
);
41 /*****************************************************************************
42 * OpenDecoder: Open the decoder
43 *****************************************************************************/
44 int OpenDecoder ( vlc_object_t
*p_this
)
46 decoder_t
*p_dec
= (decoder_t
*)p_this
;
48 msg_Dbg( p_this
, "opening stats decoder" );
51 p_dec
->pf_decode_video
= DecodeBlock
;
52 p_dec
->pf_decode_audio
= NULL
;
53 p_dec
->pf_decode_sub
= NULL
;
56 es_format_Init( &p_dec
->fmt_out
, VIDEO_ES
, VLC_CODEC_I420
);
57 p_dec
->fmt_out
.video
.i_width
= 100;
58 p_dec
->fmt_out
.video
.i_height
= 100;
59 p_dec
->fmt_out
.video
.i_sar_num
= 1;
60 p_dec
->fmt_out
.video
.i_sar_den
= 1;
65 /****************************************************************************
66 * RunDecoder: the whole thing
67 ****************************************************************************/
68 static picture_t
*DecodeBlock( decoder_t
*p_dec
, block_t
**pp_block
)
71 picture_t
* p_pic
= NULL
;
73 if( !pp_block
|| !*pp_block
) return NULL
;
76 p_pic
= decoder_NewPicture( p_dec
);
78 if( p_block
->i_buffer
== kBufferSize
)
80 msg_Dbg( p_dec
, "got %"PRIu64
" ms",
81 *(mtime_t
*)p_block
->p_buffer
/ 1000 );
82 msg_Dbg( p_dec
, "got %"PRIu64
" ms offset",
83 (mdate() - *(mtime_t
*)p_block
->p_buffer
) / 1000 );
84 *(mtime_t
*)(p_pic
->p
->p_pixels
) = *(mtime_t
*)p_block
->p_buffer
;
88 msg_Dbg( p_dec
, "got a packet not from stats demuxer" );
89 *(mtime_t
*)(p_pic
->p
->p_pixels
) = mdate();
92 p_pic
->date
= p_block
->i_pts
> VLC_TS_INVALID
?
93 p_block
->i_pts
: p_block
->i_dts
;
94 p_pic
->b_force
= true;
96 block_Release( p_block
);
101 /*****************************************************************************
102 * CloseDecoder: decoder destruction
103 *****************************************************************************/
104 void CloseDecoder ( vlc_object_t
*p_this
)
106 msg_Dbg( p_this
, "closing stats decoder" );