Mercurial > libavformat.hg
annotate h261dec.c @ 6469:eb68008daac2 libavformat
Add a muxer and demuxer for raw G.722
author | mstorsjo |
---|---|
date | Thu, 09 Sep 2010 19:27:41 +0000 |
parents | 4775a49a6045 |
children |
rev | line source |
---|---|
885 | 1 /* |
6437 | 2 * RAW H.261 video demuxer |
3 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at> | |
0 | 4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
0 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
0 | 11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
0 | 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 | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 20 */ |
3286 | 21 |
4872 | 22 #include "libavcodec/get_bits.h" |
0 | 23 #include "avformat.h" |
6448 | 24 #include "rawdec.h" |
0 | 25 |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
26 static int h261_probe(AVProbeData *p) |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
27 { |
5183 | 28 uint32_t code= -1; |
29 int i; | |
30 int valid_psc=0; | |
31 int invalid_psc=0; | |
32 int next_gn=0; | |
33 int src_fmt=0; | |
34 GetBitContext gb; | |
35 | |
36 init_get_bits(&gb, p->buf, p->buf_size*8); | |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
37 |
5183 | 38 for(i=0; i<p->buf_size*8; i++){ |
5656
408c4e4d278a
Optimize h261_probe function, since it is far slower than all others.
reimar
parents:
5451
diff
changeset
|
39 if ((code & 0x01ff0000) || !(code & 0xff00)) { |
408c4e4d278a
Optimize h261_probe function, since it is far slower than all others.
reimar
parents:
5451
diff
changeset
|
40 code = (code<<8) + get_bits(&gb, 8); |
408c4e4d278a
Optimize h261_probe function, since it is far slower than all others.
reimar
parents:
5451
diff
changeset
|
41 i += 7; |
408c4e4d278a
Optimize h261_probe function, since it is far slower than all others.
reimar
parents:
5451
diff
changeset
|
42 } else |
5657 | 43 code = (code<<1) + get_bits1(&gb); |
5183 | 44 if ((code & 0xffff0000) == 0x10000) { |
45 int gn= (code>>12)&0xf; | |
46 if(!gn) | |
47 src_fmt= code&8; | |
48 if(gn != next_gn) invalid_psc++; | |
49 else valid_psc++; | |
50 | |
51 if(src_fmt){ // CIF | |
52 next_gn= (gn+1 )%13; | |
53 }else{ //QCIF | |
54 next_gn= (gn+1+!!gn)% 7; | |
55 } | |
56 } | |
57 } | |
5191
9affc096944c
Make h261 and mpegvideo probe a little more robust so they dont fail with
michael
parents:
5184
diff
changeset
|
58 if(valid_psc > 2*invalid_psc + 6){ |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
59 return 50; |
5183 | 60 }else if(valid_psc > 2*invalid_psc + 2) |
61 return 25; | |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
62 return 0; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
63 } |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
64 |
1167 | 65 AVInputFormat h261_demuxer = { |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
66 "h261", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3405
diff
changeset
|
67 NULL_IF_CONFIG_SMALL("raw H.261"), |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
68 0, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
69 h261_probe, |
6430 | 70 ff_raw_video_read_header, |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
71 ff_raw_read_partial_packet, |
1756 | 72 .flags= AVFMT_GENERIC_INDEX, |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
73 .extensions = "h261", |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
74 .value = CODEC_ID_H261, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
75 }; |