xine-lib  1.2.9
h264_parser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Julian Scheel
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  * h264_parser.h: Almost full-features H264 NAL-Parser
21  */
22 
23 #ifndef NAL_PARSER_H_
24 #define NAL_PARSER_H_
25 
26 #include <stdlib.h>
27 
28 #include <xine/xine_internal.h>
29 #include "nal.h"
30 #include "dpb.h"
31 
32 #define MAX_FRAME_SIZE 1024*1024
33 
34 /* specifies wether the parser last parsed
35  * non-vcl or vcl nal units. depending on
36  * this the access unit boundaries are detected
37  */
41 };
42 
46 };
47 
48 struct h264_parser {
49  uint8_t buf[MAX_FRAME_SIZE];
50  uint32_t buf_len;
51 
52  /* prebuf is used to store the currently
53  * processed nal unit */
55  uint32_t prebuf_len;
57 
58  uint8_t last_nal_res;
59 
60  uint8_t nal_size_length;
61  uint32_t next_nal_size;
64 
66 
67  struct coded_picture *pic;
68 
72 
75  uint32_t frame_num_offset;
76 
78 
79  uint32_t curr_pic_num;
80 
81  uint16_t flag_mask;
82 
83  /* this is dpb used for reference frame
84  * heading to vdpau + unordered frames
85  */
86  struct dpb *dpb;
87 
89 };
90 
91 static int parse_nal(const uint8_t *buf, int buf_len, struct h264_parser *parser,
92  struct coded_picture **completed_picture);
93 
94 static int seek_for_nal(uint8_t *buf, int buf_len, struct h264_parser *parser);
95 
96 static struct h264_parser* init_parser(xine_t *xine);
97 #if 0
98 static void reset_parser(struct h264_parser *parser);
99 #endif
100 static void free_parser(struct h264_parser *parser);
101 static int parse_frame(struct h264_parser *parser, const uint8_t *inbuf, int inbuf_len,
102  int64_t pts,
103  const void **ret_buf, uint32_t *ret_len, struct coded_picture **ret_pic);
104 
105 /* this has to be called after decoding the frame delivered by parse_frame,
106  * but before adding a decoded frame to the dpb.
107  */
108 static void process_mmc_operations(struct h264_parser *parser, struct coded_picture *picture);
109 
110 static void parse_codec_private(struct h264_parser *parser, const uint8_t *inbuf, int inbuf_len);
111 
112 #endif
Definition: h264_parser.h:40
struct nal_buffer * pps_buffer
Definition: h264_parser.h:71
uint32_t buf_len
Definition: h264_parser.h:50
Definition: nal.h:476
static void parse_codec_private(struct h264_parser *parser, const uint8_t *inbuf, int inbuf_len)
static int seek_for_nal(uint8_t *buf, int buf_len, struct h264_parser *parser)
uint32_t prebuf_len
Definition: h264_parser.h:55
int32_t prev_top_field_order_cnt
Definition: h264_parser.h:77
uint16_t flag_mask
Definition: h264_parser.h:81
#define MAX_FRAME_SIZE
Definition: h264_parser.h:32
uint8_t last_nal_res
Definition: h264_parser.h:58
uint8_t nal_size_length
Definition: h264_parser.h:60
static int parse_nal(const uint8_t *buf, int buf_len, struct h264_parser *parser, struct coded_picture **completed_picture)
uint8_t prebuf[1024 *1024]
Definition: h264_parser.h:54
uint32_t next_nal_position
Definition: h264_parser.h:56
uint32_t frame_num_offset
Definition: h264_parser.h:75
uint32_t curr_pic_num
Definition: h264_parser.h:79
Definition: h264_parser.h:39
struct nal_buffer * sps_buffer
Definition: h264_parser.h:70
Definition: nal.h:459
uint8_t buf[1024 *1024]
Definition: h264_parser.h:49
struct dpb * dpb
Definition: h264_parser.h:86
static void process_mmc_operations(struct h264_parser *parser, struct coded_picture *picture)
static struct h264_parser * init_parser(xine_t *xine)
static void free_parser(struct h264_parser *parser)
uint8_t * nal_size_length_buf
Definition: h264_parser.h:62
uint32_t prev_pic_order_cnt_lsb
Definition: h264_parser.h:73
Definition: h264_parser.h:45
struct coded_picture * pic
Definition: h264_parser.h:67
struct nal_unit * last_vcl_nal
Definition: h264_parser.h:69
Definition: h264_parser.h:48
Definition: xine_internal.h:81
uint8_t have_nal_size_length_buf
Definition: h264_parser.h:63
xine_t * xine
Definition: h264_parser.h:88
Definition: dpb.h:76
Definition: h264_parser.h:44
parser_position
Definition: h264_parser.h:38
enum parser_position position
Definition: h264_parser.h:65
uint32_t prev_pic_order_cnt_msb
Definition: h264_parser.h:74
parser_flags
Definition: h264_parser.h:43
static int parse_frame(struct h264_parser *parser, const uint8_t *inbuf, int inbuf_len, int64_t pts, const void **ret_buf, uint32_t *ret_len, struct coded_picture **ret_pic)
Definition: cpb.h:35
uint32_t next_nal_size
Definition: h264_parser.h:61