]> git.sesse.net Git - vlc/blob - modules/misc/stats/decoder.c
Used VLC_CODEC_* and i_original_fourcc when applicable.
[vlc] / modules / misc / stats / decoder.c
1 /*****************************************************************************
2  * decoder.c: stats decoder plugin for vlc.
3  *****************************************************************************
4  * Copyright (C) 2002-2008 the VideoLAN team
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
7  *          Pierre d'Herbemont <pdherbemont@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc_common.h>
32 #include <vlc_codec.h>
33 #include <vlc_vout.h>
34
35 #include "stats.h"
36
37 /*****************************************************************************
38  * Local prototypes
39  *****************************************************************************/
40 static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block );
41
42 /*****************************************************************************
43  * OpenDecoder: Open the decoder
44  *****************************************************************************/
45 int OpenDecoder ( vlc_object_t *p_this )
46 {
47     decoder_t *p_dec = (decoder_t*)p_this;
48
49     msg_Dbg( p_this, "opening stats decoder" );
50
51     /* Set callbacks */
52     p_dec->pf_decode_video = DecodeBlock;
53     p_dec->pf_decode_audio = NULL;
54     p_dec->pf_decode_sub = NULL;
55
56     /* */
57     es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_CODEC_I420 );
58     p_dec->fmt_out.video.i_width = 100;
59     p_dec->fmt_out.video.i_height = 100;
60     p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR;
61
62     return VLC_SUCCESS;
63 }
64
65 /****************************************************************************
66  * RunDecoder: the whole thing
67  ****************************************************************************/
68 static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
69 {
70     block_t *p_block;
71     picture_t * p_pic = NULL;
72
73     if( !pp_block || !*pp_block ) return NULL;
74     p_block = *pp_block;
75
76     p_pic = decoder_NewPicture( p_dec );
77
78     if( p_block->i_buffer == kBufferSize )
79     {
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;
85     }
86     else
87     {
88         msg_Dbg( p_dec, "got a packet not from stats demuxer" );
89         *(mtime_t *)(p_pic->p->p_pixels) = mdate();
90     }
91
92     p_pic->date = p_block->i_pts ? p_block->i_pts : p_block->i_dts;
93     p_pic->b_force = true;
94
95     block_Release( p_block );
96     *pp_block = NULL;
97     return p_pic;
98 }
99
100 /*****************************************************************************
101  * CloseDecoder: decoder destruction
102  *****************************************************************************/
103 void CloseDecoder ( vlc_object_t *p_this )
104 {
105     msg_Dbg( p_this, "closing stats decoder" );
106 }