Libav 0.7.1
|
00001 /* 00002 * RAW H.261 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 "libavcodec/get_bits.h" 00023 #include "avformat.h" 00024 #include "rawdec.h" 00025 00026 static int h261_probe(AVProbeData *p) 00027 { 00028 uint32_t code= -1; 00029 int i; 00030 int valid_psc=0; 00031 int invalid_psc=0; 00032 int next_gn=0; 00033 int src_fmt=0; 00034 GetBitContext gb; 00035 00036 init_get_bits(&gb, p->buf, p->buf_size*8); 00037 00038 for(i=0; i<p->buf_size*8; i++){ 00039 if ((code & 0x01ff0000) || !(code & 0xff00)) { 00040 code = (code<<8) + get_bits(&gb, 8); 00041 i += 7; 00042 } else 00043 code = (code<<1) + get_bits1(&gb); 00044 if ((code & 0xffff0000) == 0x10000) { 00045 int gn= (code>>12)&0xf; 00046 if(!gn) 00047 src_fmt= code&8; 00048 if(gn != next_gn) invalid_psc++; 00049 else valid_psc++; 00050 00051 if(src_fmt){ // CIF 00052 next_gn= (gn+1 )%13; 00053 }else{ //QCIF 00054 next_gn= (gn+1+!!gn)% 7; 00055 } 00056 } 00057 } 00058 if(valid_psc > 2*invalid_psc + 6){ 00059 return 50; 00060 }else if(valid_psc > 2*invalid_psc + 2) 00061 return 25; 00062 return 0; 00063 } 00064 00065 FF_DEF_RAWVIDEO_DEMUXER(h261, "raw H.261", h261_probe, "h261", CODEC_ID_H261)