LCOV - code coverage report
Current view: top level - libavformat - shortendec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 16 23 69.6 %
Date: 2017-12-12 11:08:38 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Shorten 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 "libavcodec/golomb.h"
      27             : 
      28        6130 : static int shn_probe(AVProbeData *p)
      29             : {
      30             :     GetBitContext gb;
      31             :     int version, internal_ftype, channels, blocksize;
      32             : 
      33        6130 :     if (AV_RB32(p->buf) != 0x616a6b67)
      34        6129 :         return 0;
      35           1 :     version = p->buf[4];
      36           1 :     if (init_get_bits8(&gb, p->buf + 5, p->buf_size - 5 - AV_INPUT_BUFFER_PADDING_SIZE) < 0)
      37           0 :         return 0;
      38           1 :     if (!version) {
      39           0 :         internal_ftype = get_ur_golomb_shorten(&gb, 4);
      40           0 :         channels = get_ur_golomb_shorten(&gb, 0);
      41           0 :         blocksize = 256;
      42             :     } else {
      43             :         int k;
      44           1 :         k = get_ur_golomb_shorten(&gb, 2);
      45           1 :         internal_ftype = get_ur_golomb_shorten(&gb, k);
      46           1 :         k = get_ur_golomb_shorten(&gb, 2);
      47           1 :         channels = get_ur_golomb_shorten(&gb, k);
      48           1 :         k = get_ur_golomb_shorten(&gb, 2);
      49           1 :         blocksize = get_ur_golomb_shorten(&gb, k);
      50             :     }
      51             : 
      52           1 :     if (internal_ftype != 2 && internal_ftype != 3 && internal_ftype != 5)
      53           0 :         return 0;
      54           1 :     if (channels < 1 || channels > 8)
      55           0 :         return 0;
      56           1 :     if (blocksize < 1 || blocksize > 65535)
      57           0 :         return 0;
      58             : 
      59           1 :     return AVPROBE_SCORE_EXTENSION + 1;
      60             : }
      61             : 
      62             : AVInputFormat ff_shorten_demuxer = {
      63             :     .name           = "shn",
      64             :     .long_name      = NULL_IF_CONFIG_SMALL("raw Shorten"),
      65             :     .read_probe     = shn_probe,
      66             :     .read_header    = ff_raw_audio_read_header,
      67             :     .read_packet    = ff_raw_read_partial_packet,
      68             :     .flags          = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
      69             :     .extensions     = "shn",
      70             :     .raw_codec_id   = AV_CODEC_ID_SHORTEN,
      71             : };

Generated by: LCOV version 1.13