LCOV - code coverage report
Current view: top level - libavformat - m4vdec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 25 25 100.0 %
Date: 2017-12-10 21:22:29 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * RAW MPEG-4 video demuxer
       3             :  * Copyright (c) 2006  Thijs Vermeir <thijs.vermeir@barco.com>
       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             : 
      25             : #define VISUAL_OBJECT_START_CODE       0x000001b5
      26             : #define VOP_START_CODE                 0x000001b6
      27             : 
      28        6130 : static int mpeg4video_probe(AVProbeData *probe_packet)
      29             : {
      30        6130 :     uint32_t temp_buffer = -1;
      31        6130 :     int VO = 0, VOL = 0, VOP = 0, VISO = 0, res = 0;
      32             :     int i;
      33             : 
      34   128280795 :     for (i = 0; i < probe_packet->buf_size; i++) {
      35   128274665 :         temp_buffer = (temp_buffer << 8) + probe_packet->buf[i];
      36   128274665 :         if (temp_buffer & 0xfffffe00)
      37   124077004 :             continue;
      38     4197661 :         if (temp_buffer < 2)
      39     4011364 :             continue;
      40             : 
      41      186297 :         if (temp_buffer == VOP_START_CODE)
      42         163 :             VOP++;
      43      186134 :         else if (temp_buffer == VISUAL_OBJECT_START_CODE)
      44         674 :             VISO++;
      45      185460 :         else if (temp_buffer >= 0x100 && temp_buffer < 0x120)
      46       32032 :             VO++;
      47      153428 :         else if (temp_buffer >= 0x120 && temp_buffer < 0x130)
      48        1499 :             VOL++;
      49      151929 :         else if (!(0x1AF < temp_buffer && temp_buffer < 0x1B7) &&
      50        2280 :                  !(0x1B9 < temp_buffer && temp_buffer < 0x1C4))
      51      151007 :             res++;
      52             :     }
      53             : 
      54        6130 :     if (VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res == 0)
      55          48 :         return VOP+VO > 4 ? AVPROBE_SCORE_EXTENSION : AVPROBE_SCORE_EXTENSION/2;
      56             : 
      57        6082 :     if (VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && VOP+VO > 4)
      58           3 :         return AVPROBE_SCORE_EXTENSION/10;
      59        6079 :     return 0;
      60             : }
      61             : 
      62             : FF_DEF_RAWVIDEO_DEMUXER2(m4v, "raw MPEG-4 video", mpeg4video_probe, "m4v",
      63             :                          AV_CODEC_ID_MPEG4, AVFMT_GENERIC_INDEX | AVFMT_TS_DISCONT)

Generated by: LCOV version 1.13