1 /*
2 * VC-1 and WMV3 parser
3 * Copyright (c) 2006-2007 Konstantin Shishkov
4 * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, 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 /**
24 * @file
25 * VC-1 and WMV3 parser
26 */
27
31
36
38 const uint8_t *buf,
int buf_size)
39 {
44
47 next = buf;
49
50 for(start = buf, end = buf + buf_size; next <
end; start = next){
52
54 size = next - start - 4;
57 if(size <= 0) continue;
61 break;
64 break;
68 else
70
71 /* keep AV_PICTURE_TYPE_BI internal to VC1 */
74 else
76
78 // process pulldown flags
80 // Pulldown flags are only valid when 'broadcast' has been set.
81 // So ticks_per_frame will be 2
83 // repeat field
86 // repeat frames
88 }
89 }
90
91 break;
92 }
93 }
94
96 }
97
98 /**
99 * Find the end of the current frame in the bitstream.
100 * @return the position of the first byte of the next frame, or -1
101 */
103 int buf_size) {
104 int pic_found, i;
106
109
110 i=0;
111 if(!pic_found){
112 for(i=0; i<buf_size; i++){
113 state= (state<<8) | buf[i];
115 i++;
116 pic_found=1;
117 break;
118 }
119 }
120 }
121
122 if(pic_found){
123 /* EOF considered as end of frame */
124 if (buf_size == 0)
125 return 0;
126 for(; i<buf_size; i++){
127 state= (state<<8) | buf[i];
131 return i-3;
132 }
133 }
134 }
138 }
139
142 const uint8_t **poutbuf,
int *poutbuf_size,
143 const uint8_t *buf,
int buf_size)
144 {
146 int next;
147
149 next= buf_size;
150 }else{
152
155 *poutbuf_size = 0;
156 return buf_size;
157 }
158 }
159
161
162 *poutbuf = buf;
163 *poutbuf_size = buf_size;
164 return next;
165 }
166
168 const uint8_t *buf,
int buf_size)
169 {
170 int i;
172 int charged=0;
173
174 for(i=0; i<buf_size; i++){
175 state= (state<<8) | buf[i];
178 charged=1;
179 }else if(charged){
180 return i-3;
181 }
182 }
183 }
184 return 0;
185 }
186
188 {
192 }
193
201 };