Mercurial > libavcodec.hg
annotate h261_parser.c @ 5310:9aa9197034d7 libavcodec
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
More code cleanup.
Window is now runtime generated.
Fixed the bugs in rematrixing routine and
in Decoding AC3 Bitstreams when coupling is in use.
Still struggling to find out what affects the quality of
the produced sound. Can anybody have a look at the
imdct routines do_imdct_256 and do_imdct_512 and tell me
whether it is the correctly implemented as described in
standard.
author | jbr |
---|---|
date | Sat, 14 Jul 2007 15:57:51 +0000 |
parents | da1ca444ff51 |
children | e9d9d946f213 |
rev | line source |
---|---|
4905 | 1 /* |
2 * H261 parser | |
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | |
4 * Copyright (c) 2004 Maarten Daniels | |
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 h261_parser.c | |
25 * h261codec. | |
26 */ | |
27 | |
28 #include "parser.h" | |
29 | |
30 | |
31 static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const uint8_t *buf, int buf_size){ | |
32 int vop_found, i, j; | |
33 uint32_t state; | |
34 | |
35 vop_found= pc->frame_start_found; | |
36 state= pc->state; | |
37 | |
38 for(i=0; i<buf_size && !vop_found; i++){ | |
39 state= (state<<8) | buf[i]; | |
40 for(j=0; j<8; j++){ | |
5046 | 41 if(((state>>j)&0xFFFFF0) == 0x000100){ |
4905 | 42 vop_found=1; |
43 break; | |
44 } | |
45 } | |
46 } | |
47 if(vop_found){ | |
48 for(; i<buf_size; i++){ | |
49 state= (state<<8) | buf[i]; | |
50 for(j=0; j<8; j++){ | |
5046 | 51 if(((state>>j)&0xFFFFF0) == 0x000100){ |
4905 | 52 pc->frame_start_found=0; |
5046 | 53 pc->state= (state>>(3*8))+0xFF00; |
54 return i-2; | |
4905 | 55 } |
56 } | |
57 } | |
58 } | |
59 | |
60 pc->frame_start_found= vop_found; | |
61 pc->state= state; | |
62 return END_NOT_FOUND; | |
63 } | |
64 | |
65 static int h261_parse(AVCodecParserContext *s, | |
66 AVCodecContext *avctx, | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4919
diff
changeset
|
67 const uint8_t **poutbuf, int *poutbuf_size, |
4905 | 68 const uint8_t *buf, int buf_size) |
69 { | |
70 ParseContext *pc = s->priv_data; | |
71 int next; | |
72 | |
73 next= h261_find_frame_end(pc,avctx, buf, buf_size); | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4919
diff
changeset
|
74 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { |
4905 | 75 *poutbuf = NULL; |
76 *poutbuf_size = 0; | |
77 return buf_size; | |
78 } | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4919
diff
changeset
|
79 *poutbuf = buf; |
4905 | 80 *poutbuf_size = buf_size; |
81 return next; | |
82 } | |
83 | |
84 AVCodecParser h261_parser = { | |
85 { CODEC_ID_H261 }, | |
86 sizeof(ParseContext), | |
87 NULL, | |
88 h261_parse, | |
89 ff_parse_close, | |
90 }; |