LCOV - code coverage report
Current view: top level - libavformat - vc1dec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 35 39 89.7 %
Date: 2017-12-15 18:13:28 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * VC-1 demuxer
       3             :  * Copyright (c) 2015 Carl Eugen Hoyos
       4             :  *
       5             :  * This file is part of FFmpeg.
       6             :  *
       7             :  * FFmpeg is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * FFmpeg is distributed in the hope that it will be useful,
      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
      18             :  * License along with FFmpeg; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : #include "avformat.h"
      23             : #include "rawdec.h"
      24             : #include "libavutil/intreadwrite.h"
      25             : #include "libavcodec/vc1_common.h"
      26             : 
      27        6130 : static int vc1_probe(AVProbeData *p)
      28             : {
      29        6130 :     int seq = 0, entry = 0, frame = 0, i;
      30             : 
      31   128187941 :     for (i = 0; i < p->buf_size + 5; i++) {
      32   128181811 :         uint32_t code = AV_RB32(p->buf + i);
      33   128181811 :         if ((code & 0xffffffe0) == 0x100) {
      34       30804 :             int type = code & 0x11f;
      35       30804 :             i += 4;
      36       30804 :             switch (type) {
      37         389 :             case VC1_CODE_SEQHDR: {
      38             :                 int profile, level, chromaformat;
      39         389 :                 profile = (p->buf[i] & 0xc0) >> 6;
      40         389 :                 if (profile != PROFILE_ADVANCED) {
      41         358 :                     seq = 0;
      42         358 :                     continue;
      43             :                 }
      44          31 :                 level = (p->buf[i] & 0x38) >> 3;
      45          31 :                 if (level >= 5) {
      46           0 :                     seq = 0;
      47           0 :                     continue;
      48             :                 }
      49          31 :                 chromaformat = (p->buf[i] & 0x6) >> 1;
      50          31 :                 if (chromaformat != 1) {
      51           0 :                     seq = 0;
      52           0 :                     continue;
      53             :                 }
      54          31 :                 seq++;
      55          31 :                 i += 6;
      56          31 :                 break;
      57             :             }
      58         478 :             case VC1_CODE_ENTRYPOINT:
      59         478 :                 if (!seq)
      60         427 :                     continue;
      61          51 :                 entry++;
      62          51 :                 i += 2;
      63          51 :                 break;
      64        1466 :             case VC1_CODE_FRAME:
      65             :             case VC1_CODE_FIELD:
      66             :             case VC1_CODE_SLICE:
      67        1466 :                 if (seq && entry)
      68          39 :                     frame++;
      69        1466 :                 break;
      70             :             }
      71             :         }
      72             :     }
      73             : 
      74        6130 :     if (frame > 1)
      75           6 :         return AVPROBE_SCORE_EXTENSION / 2 + 1;
      76        6124 :     if (frame == 1)
      77          23 :         return AVPROBE_SCORE_EXTENSION / 4;
      78        6101 :     return 0;
      79             : }
      80             : 
      81             : FF_DEF_RAWVIDEO_DEMUXER2(vc1, "raw VC-1", vc1_probe, "vc1", AV_CODEC_ID_VC1, AVFMT_GENERIC_INDEX|AVFMT_NOTIMESTAMPS)

Generated by: LCOV version 1.13