1 /*
2 * MPEG-4 video frame extraction
3 * Copyright (c) 2003 Fabrice Bellard
4 * Copyright (c) 2003 Michael Niedermayer
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #define UNCHECKED_BITSTREAM_READER 1
24
30
35 };
36
37 /**
38 * Find the end of the current frame in the bitstream.
39 * @return the position of the first byte of the next frame, or -1
40 */
42 {
45
48
50 if (!vop_found) {
51 for (
i = 0;
i < buf_size;
i++) {
55 vop_found = 1;
56 break;
57 }
58 }
59 }
60
61 if (vop_found) {
62 /* EOF considered as end of frame */
63 if (buf_size == 0)
64 return 0;
65 for (;
i < buf_size;
i++) {
67 if ((
state & 0xFFFFFF00) == 0x100) {
69 continue;
73 }
74 }
75 }
79 }
80
81 /* XXX: make it use less memory */
83 const uint8_t *buf, int buf_size)
84 {
90
92
98 }
99
107 }
111
113 }
114
115 s1->pict_type =
s->pict_type;
116 pc->first_picture = 0;
118 }
119
121 {
123
124 pc->first_picture = 1;
125 pc->dec_ctx.m.quant_precision = 5;
126 pc->dec_ctx.m.slice_context_count = 1;
127 pc->dec_ctx.showed_packed_warning = 1;
128 return 0;
129 }
130
133 const uint8_t **poutbuf, int *poutbuf_size,
134 const uint8_t *buf, int buf_size)
135 {
137 int next;
138
140 next = buf_size;
141 } else {
143
146 *poutbuf_size = 0;
147 return buf_size;
148 }
149 }
151
152 *poutbuf = buf;
153 *poutbuf_size = buf_size;
154 return next;
155 }
156
163 };