Mercurial > libavcodec.hg
annotate h263_parser.c @ 9429:017b81b285f4 libavcodec
flacenc : do not #include libavutil/lls.h since lpc code is now
separate.
author | jai_menon |
---|---|
date | Mon, 13 Apr 2009 16:23:54 +0000 |
parents | e9d9d946f213 |
children | 367119ffda3f |
rev | line source |
---|---|
4938 | 1 /* |
2 * H.263 parser | |
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | |
4 * | |
5 * This file is part of FFmpeg. | |
6 * | |
7 * FFmpeg is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * FFmpeg is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with FFmpeg; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 | |
22 /** | |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
6305
diff
changeset
|
23 * @file libavcodec/h263_parser.c |
4938 | 24 * H.263 parser |
25 */ | |
26 | |
27 #include "parser.h" | |
28 | |
29 int ff_h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){ | |
30 int vop_found, i; | |
31 uint32_t state; | |
32 | |
33 vop_found= pc->frame_start_found; | |
34 state= pc->state; | |
35 | |
36 i=0; | |
37 if(!vop_found){ | |
38 for(i=0; i<buf_size; i++){ | |
39 state= (state<<8) | buf[i]; | |
40 if(state>>(32-22) == 0x20){ | |
41 i++; | |
42 vop_found=1; | |
43 break; | |
44 } | |
45 } | |
46 } | |
47 | |
48 if(vop_found){ | |
49 for(; i<buf_size; i++){ | |
50 state= (state<<8) | buf[i]; | |
51 if(state>>(32-22) == 0x20){ | |
52 pc->frame_start_found=0; | |
53 pc->state=-1; | |
54 return i-3; | |
55 } | |
56 } | |
57 } | |
58 pc->frame_start_found= vop_found; | |
59 pc->state= state; | |
60 | |
61 return END_NOT_FOUND; | |
62 } | |
63 | |
64 static int h263_parse(AVCodecParserContext *s, | |
65 AVCodecContext *avctx, | |
5156 | 66 const uint8_t **poutbuf, int *poutbuf_size, |
4938 | 67 const uint8_t *buf, int buf_size) |
68 { | |
69 ParseContext *pc = s->priv_data; | |
70 int next; | |
71 | |
72 next= ff_h263_find_frame_end(pc, buf, buf_size); | |
73 | |
5258 | 74 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { |
4938 | 75 *poutbuf = NULL; |
76 *poutbuf_size = 0; | |
77 return buf_size; | |
78 } | |
79 | |
6305 | 80 *poutbuf = buf; |
4938 | 81 *poutbuf_size = buf_size; |
82 return next; | |
83 } | |
84 | |
85 AVCodecParser h263_parser = { | |
86 { CODEC_ID_H263 }, | |
87 sizeof(ParseContext), | |
88 NULL, | |
89 h263_parse, | |
90 ff_parse_close, | |
91 }; |