annotate h263dec.c @ 6461:c12416642843 libavformat

matroskadec: allow uint and float elements with length = 0
author aurel
date Sun, 05 Sep 2010 21:37:40 +0000
parents 4775a49a6045
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 868
diff changeset
1 /*
6436
505105fc99ab move h263 demuxer to its own file
aurel
parents: 6435
diff changeset
2 * RAW H.263 video demuxer
505105fc99ab move h263 demuxer to its own file
aurel
parents: 6435
diff changeset
3 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 */
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 3274
diff changeset
21
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #include "avformat.h"
6448
4775a49a6045 split raw.c into rawdec.c and rawenc.c
aurel
parents: 6436
diff changeset
23 #include "rawdec.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24
135
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
25 static int h263_probe(AVProbeData *p)
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
26 {
5179
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
27 uint64_t code= -1;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
28 int i;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
29 int valid_psc=0;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
30 int invalid_psc=0;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
31 int res_change=0;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
32 int src_fmt, last_src_fmt=-1;
6144
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
33 int last_gn=0;
135
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
34
5179
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
35 for(i=0; i<p->buf_size; i++){
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
36 code = (code<<8) + p->buf[i];
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
37 if ((code & 0xfffffc0000) == 0x800000) {
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
38 src_fmt= (code>>2)&3;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
39 if( src_fmt != last_src_fmt
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
40 && last_src_fmt>0 && last_src_fmt<6
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
41 && src_fmt<6)
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
42 res_change++;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
43
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
44 if((code&0x300)==0x200 && src_fmt){
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
45 valid_psc++;
6144
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
46 last_gn=0;
5179
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
47 }else
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
48 invalid_psc++;
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
49 last_src_fmt= src_fmt;
6144
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
50 } else if((code & 0xffff800000) == 0x800000) {
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
51 int gn= (code>>(23-5)) & 0x1F;
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
52 if(gn<last_gn){
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
53 invalid_psc++;
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
54 }else
f2c92e715300 Improve h263_probe()
michael
parents: 6121
diff changeset
55 last_gn= gn;
5179
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
56 }
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
57 }
5424
8dd3cb8e01c7 Add out commented av_log to debug h263_probe.
michael
parents: 5360
diff changeset
58 //av_log(NULL, AV_LOG_ERROR, "h263_probe: psc:%d invalid:%d res_change:%d\n", valid_psc, invalid_psc, res_change);
5425
9ee7e675a476 Raise threshold of h263 probe by 1 to avoid misdetection.
michael
parents: 5424
diff changeset
59 //h263_probe: psc:3 invalid:0 res_change:0 (1588/recent_ffmpeg_parses_mpg_incorrectly.mpg)
9ee7e675a476 Raise threshold of h263 probe by 1 to avoid misdetection.
michael
parents: 5424
diff changeset
60 if(valid_psc > 2*invalid_psc + 2*res_change + 3){
135
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
61 return 50;
5179
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
62 }else if(valid_psc > 2*invalid_psc)
cd0985411145 Rewrite h263_probe().
michael
parents: 5108
diff changeset
63 return 25;
135
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
64 return 0;
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
65 }
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
66
1167
d89d7ef290da give AVInput/OutputFormat structs consistent names
mru
parents: 1121
diff changeset
67 AVInputFormat h263_demuxer = {
135
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
68 "h263",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 3405
diff changeset
69 NULL_IF_CONFIG_SMALL("raw H.263"),
135
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
70 0,
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
71 h263_probe,
6430
d3a51b32b769 move ingenient demuxer to its own file
aurel
parents: 6429
diff changeset
72 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
73 ff_raw_read_partial_packet,
1756
5d72afc6c8aa better generic index building and seeking code
michael
parents: 1463
diff changeset
74 .flags= AVFMT_GENERIC_INDEX,
135
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
75 // .extensions = "h263", //FIXME remove after writing mpeg4_probe
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
76 .value = CODEC_ID_H263,
56590088f801 truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents: 128
diff changeset
77 };