3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4 * Copyright (c) 2004 Maarten Daniels
6 * This file is part of FFmpeg.
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.
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.
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
31 static int h261_find_frame_end(ParseContext
*pc
, AVCodecContext
* avctx
, const uint8_t *buf
, int buf_size
){
35 vop_found
= pc
->frame_start_found
;
38 for(i
=0; i
<buf_size
&& !vop_found
; i
++){
39 state
= (state
<<8) | buf
[i
];
41 if(((state
>>j
)&0xFFFFF0) == 0x000100){
48 for(; i
<buf_size
; i
++){
49 state
= (state
<<8) | buf
[i
];
51 if(((state
>>j
)&0xFFFFF0) == 0x000100){
52 pc
->frame_start_found
=0;
53 pc
->state
= (state
>>(3*8))+0xFF00;
60 pc
->frame_start_found
= vop_found
;
65 static int h261_parse(AVCodecParserContext
*s
,
66 AVCodecContext
*avctx
,
67 const uint8_t **poutbuf
, int *poutbuf_size
,
68 const uint8_t *buf
, int buf_size
)
70 ParseContext
*pc
= s
->priv_data
;
73 next
= h261_find_frame_end(pc
,avctx
, buf
, buf_size
);
74 if (ff_combine_frame(pc
, next
, &buf
, &buf_size
) < 0) {
80 *poutbuf_size
= buf_size
;
84 AVCodecParser h261_parser
= {