LCOV - code coverage report
Current view: top level - libavformat - mlpdec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 22 22 100.0 %
Date: 2017-12-16 21:16:39 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  * MLP and TrueHD demuxer
       3             :  * Copyright (c) 2001 Fabrice Bellard
       4             :  * Copyright (c) 2005 Alex Beregszaszi
       5             :  * Copyright (c) 2015 Carl Eugen Hoyos
       6             :  *
       7             :  * This file is part of FFmpeg.
       8             :  *
       9             :  * FFmpeg is free software; you can redistribute it and/or
      10             :  * modify it under the terms of the GNU Lesser General Public
      11             :  * License as published by the Free Software Foundation; either
      12             :  * version 2.1 of the License, or (at your option) any later version.
      13             :  *
      14             :  * FFmpeg is distributed in the hope that it will be useful,
      15             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :  * Lesser General Public License for more details.
      18             :  *
      19             :  * You should have received a copy of the GNU Lesser General Public
      20             :  * License along with FFmpeg; if not, write to the Free Software
      21             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      22             :  */
      23             : 
      24             : #include "avformat.h"
      25             : #include "rawdec.h"
      26             : #include "libavutil/intreadwrite.h"
      27             : 
      28       12260 : static int av_always_inline mlp_thd_probe(AVProbeData *p, uint32_t sync)
      29             : {
      30       12260 :     const uint8_t *buf, *last_buf = p->buf, *end = p->buf + p->buf_size;
      31       12260 :     int frames = 0, valid = 0, size = 0;
      32       12260 :     int nsubframes = 0;
      33             : 
      34   256475770 :     for (buf = p->buf; buf + 8 <= end; buf++) {
      35   256463510 :         if (AV_RB32(buf + 4) == sync) {
      36         369 :             frames++;
      37         369 :             if (last_buf + size == buf) {
      38         369 :                 valid += 1 + nsubframes / 8;
      39             :             }
      40         369 :             nsubframes = 0;
      41         369 :             last_buf = buf;
      42         369 :             size = (AV_RB16(buf) & 0xfff) * 2;
      43   256463141 :         } else if (buf - last_buf == size) {
      44       71937 :             nsubframes++;
      45       71937 :             size += (AV_RB16(buf) & 0xfff) * 2;
      46             :         }
      47             :     }
      48       12260 :     if (valid >= 100)
      49           1 :         return AVPROBE_SCORE_MAX;
      50       12259 :     return 0;
      51             : }
      52             : 
      53             : #if CONFIG_MLP_DEMUXER
      54        6130 : static int mlp_probe(AVProbeData *p)
      55             : {
      56        6130 :     return mlp_thd_probe(p, 0xf8726fbb);
      57             : }
      58             : 
      59             : AVInputFormat ff_mlp_demuxer = {
      60             :     .name           = "mlp",
      61             :     .long_name      = NULL_IF_CONFIG_SMALL("raw MLP"),
      62             :     .read_probe     = mlp_probe,
      63             :     .read_header    = ff_raw_audio_read_header,
      64             :     .read_packet    = ff_raw_read_partial_packet,
      65             :     .flags          = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
      66             :     .extensions     = "mlp",
      67             :     .raw_codec_id   = AV_CODEC_ID_MLP,
      68             : };
      69             : #endif
      70             : 
      71             : #if CONFIG_TRUEHD_DEMUXER
      72        6130 : static int thd_probe(AVProbeData *p)
      73             : {
      74        6130 :     return mlp_thd_probe(p, 0xf8726fba);
      75             : }
      76             : 
      77             : AVInputFormat ff_truehd_demuxer = {
      78             :     .name           = "truehd",
      79             :     .long_name      = NULL_IF_CONFIG_SMALL("raw TrueHD"),
      80             :     .read_probe     = thd_probe,
      81             :     .read_header    = ff_raw_audio_read_header,
      82             :     .read_packet    = ff_raw_read_partial_packet,
      83             :     .flags          = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
      84             :     .extensions     = "thd",
      85             :     .raw_codec_id   = AV_CODEC_ID_TRUEHD,
      86             : };
      87             : #endif
      88             : 

Generated by: LCOV version 1.13