• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavformat/cavsvideodec.c

Go to the documentation of this file.
00001 /*
00002  * RAW Chinese AVS video demuxer
00003  * Copyright (c) 2009  Stefan Gehrer <stefan.gehrer@gmx.de>
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 #define CAVS_SEQ_START_CODE       0x000001b0
00026 #define CAVS_PIC_I_START_CODE     0x000001b3
00027 #define CAVS_UNDEF_START_CODE     0x000001b4
00028 #define CAVS_PIC_PB_START_CODE    0x000001b6
00029 #define CAVS_VIDEO_EDIT_CODE      0x000001b7
00030 #define CAVS_PROFILE_JIZHUN       0x20
00031 
00032 static int cavsvideo_probe(AVProbeData *p)
00033 {
00034     uint32_t code= -1;
00035     int pic=0, seq=0, slice_pos = 0;
00036     int i;
00037 
00038     for(i=0; i<p->buf_size; i++){
00039         code = (code<<8) + p->buf[i];
00040         if ((code & 0xffffff00) == 0x100) {
00041             if(code < CAVS_SEQ_START_CODE) {
00042                 /* slices have to be consecutive */
00043                 if(code < slice_pos)
00044                     return 0;
00045                 slice_pos = code;
00046             } else {
00047                 slice_pos = 0;
00048             }
00049             if (code == CAVS_SEQ_START_CODE) {
00050                 seq++;
00051                 /* check for the only currently supported profile */
00052                 if(p->buf[i+1] != CAVS_PROFILE_JIZHUN)
00053                     return 0;
00054             } else if ((code == CAVS_PIC_I_START_CODE) ||
00055                        (code == CAVS_PIC_PB_START_CODE)) {
00056                 pic++;
00057             } else if ((code == CAVS_UNDEF_START_CODE) ||
00058                        (code >  CAVS_VIDEO_EDIT_CODE)) {
00059                 return 0;
00060             }
00061         }
00062     }
00063     if(seq && seq*9<=pic*10)
00064         return AVPROBE_SCORE_MAX/2;
00065     return 0;
00066 }
00067 
00068 FF_DEF_RAWVIDEO_DEMUXER(cavsvideo, "raw Chinese AVS video", cavsvideo_probe, NULL, CODEC_ID_CAVS)
Generated on Fri Feb 1 2013 14:34:51 for FFmpeg by doxygen 1.7.1