Libav 0.7.1
|
00001 /* 00002 * RAW H.263 video demuxer 00003 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at> 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #include "avformat.h" 00023 #include "rawdec.h" 00024 00025 static int h263_probe(AVProbeData *p) 00026 { 00027 uint64_t code= -1; 00028 int i; 00029 int valid_psc=0; 00030 int invalid_psc=0; 00031 int res_change=0; 00032 int src_fmt, last_src_fmt=-1; 00033 int last_gn=0; 00034 00035 for(i=0; i<p->buf_size; i++){ 00036 code = (code<<8) + p->buf[i]; 00037 if ((code & 0xfffffc0000) == 0x800000) { 00038 src_fmt= (code>>2)&3; 00039 if( src_fmt != last_src_fmt 00040 && last_src_fmt>0 && last_src_fmt<6 00041 && src_fmt<6) 00042 res_change++; 00043 00044 if((code&0x300)==0x200 && src_fmt){ 00045 valid_psc++; 00046 last_gn=0; 00047 }else 00048 invalid_psc++; 00049 last_src_fmt= src_fmt; 00050 } else if((code & 0xffff800000) == 0x800000) { 00051 int gn= (code>>(23-5)) & 0x1F; 00052 if(gn<last_gn){ 00053 invalid_psc++; 00054 }else 00055 last_gn= gn; 00056 } 00057 } 00058 //av_log(NULL, AV_LOG_ERROR, "h263_probe: psc:%d invalid:%d res_change:%d\n", valid_psc, invalid_psc, res_change); 00059 //h263_probe: psc:3 invalid:0 res_change:0 (1588/recent_ffmpeg_parses_mpg_incorrectly.mpg) 00060 if(valid_psc > 2*invalid_psc + 2*res_change + 3){ 00061 return 50; 00062 }else if(valid_psc > 2*invalid_psc) 00063 return 25; 00064 return 0; 00065 } 00066 00067 FF_DEF_RAWVIDEO_DEMUXER(h263, "raw H.263", h263_probe, NULL, CODEC_ID_H263)