xine-lib  1.2.9
ff_mpeg_parser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2001-2017 the xine project
3  *
4  * This file is part of xine, a free video player.
5  *
6  * xine is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * xine is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  *
20  * Simple MPEG-ES parser/framer by Thibaut Mattern (tmattern@noos.fr)
21  * based on libmpeg2 decoder.
22  */
23 #ifndef HAVE_MPEG_PARSER_H
24 #define HAVE_MPEG_PARSER_H
25 
26 #include <stdint.h>
27 #include <stddef.h>
28 
29 #define BUFFER_SIZE (1194 * 1024) /* libmpeg2's buffer size */
30 
31 /* picture coding type (mpeg2 header) */
32 #define I_TYPE 1
33 #define P_TYPE 2
34 #define B_TYPE 3
35 #define D_TYPE 4
36 
37 typedef struct mpeg_parser_s {
38  uint8_t *chunk_buffer;
39  uint8_t *chunk_ptr;
40  uint8_t *chunk_start;
41  uint32_t shift;
43  uint8_t code;
45 
46  uint8_t is_sequence_needed:1;
47  uint8_t is_mpeg1:1; /* public */
48  uint8_t has_sequence:1; /* public */
49  uint8_t in_slice:1;
50 
51  uint8_t rate_code:4;
52 
54 
55  /* public properties */
56  uint16_t width;
57  uint16_t height;
60 
62 
63 /* parser initialization */
64 void mpeg_parser_init (mpeg_parser_t *parser, size_t padding_size);
65 
66 /* parser disposal */
67 void mpeg_parser_dispose (mpeg_parser_t *parser);
68 
69 /* read a frame
70  * return a pointer to the first byte of the next frame
71  * or NULL if more bytes are needed
72  * *flush is set to 1 if the decoder must be flushed (needed for still menus)
73  */
74 uint8_t *mpeg_parser_decode_data (mpeg_parser_t *parser,
75  uint8_t *current, uint8_t *end,
76  int *flush);
77 
78 /* reset the parser */
79 void mpeg_parser_reset (mpeg_parser_t *parser);
80 
81 #endif /* HAVE_MPEG_PARSER_H */
uint8_t in_slice
Definition: ff_mpeg_parser.h:49
uint16_t width
Definition: ff_mpeg_parser.h:56
void mpeg_parser_reset(mpeg_parser_t *parser)
Definition: ff_mpeg_parser.c:74
int frame_duration
Definition: ff_mpeg_parser.h:58
uint8_t is_sequence_needed
Definition: ff_mpeg_parser.h:46
double frame_aspect_ratio
Definition: ff_mpeg_parser.h:59
uint8_t picture_coding_type
Definition: ff_mpeg_parser.h:44
int aspect_ratio_info
Definition: ff_mpeg_parser.h:53
uint8_t * chunk_buffer
Definition: ff_mpeg_parser.h:38
void mpeg_parser_dispose(mpeg_parser_t *parser)
Definition: ff_mpeg_parser.c:67
uint8_t * mpeg_parser_decode_data(mpeg_parser_t *parser, uint8_t *current, uint8_t *end, int *flush)
Definition: ff_mpeg_parser.c:289
int buffer_size
Definition: ff_mpeg_parser.h:42
uint16_t height
Definition: ff_mpeg_parser.h:57
uint8_t * chunk_ptr
Definition: ff_mpeg_parser.h:39
uint8_t * chunk_start
Definition: ff_mpeg_parser.h:40
struct mpeg_parser_s mpeg_parser_t
uint8_t code
Definition: ff_mpeg_parser.h:43
uint32_t shift
Definition: ff_mpeg_parser.h:41
uint8_t rate_code
Definition: ff_mpeg_parser.h:51
uint8_t has_sequence
Definition: ff_mpeg_parser.h:48
Definition: ff_mpeg_parser.h:37
uint8_t is_mpeg1
Definition: ff_mpeg_parser.h:47
void mpeg_parser_init(mpeg_parser_t *parser, size_t padding_size)
Definition: ff_mpeg_parser.c:61