| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 "demux.h" | ||
| 26 | #include "rawdec.h" | ||
| 27 | #include "libavcodec/golomb.h" | ||
| 28 | |||
| 29 | 7467 | static int shn_probe(const AVProbeData *p) | |
| 30 | { | ||
| 31 | GetBitContext gb; | ||
| 32 | int version, internal_ftype, channels, blocksize; | ||
| 33 | |||
| 34 |
2/2✓ Branch 0 taken 7466 times.
✓ Branch 1 taken 1 times.
|
7467 | if (AV_RB32(p->buf) != 0x616a6b67) |
| 35 | 7466 | return 0; | |
| 36 | 1 | version = p->buf[4]; | |
| 37 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (init_get_bits8(&gb, p->buf + 5, p->buf_size - 5 - AV_INPUT_BUFFER_PADDING_SIZE) < 0) |
| 38 | ✗ | return 0; | |
| 39 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!version) { |
| 40 | ✗ | internal_ftype = get_ur_golomb_shorten(&gb, 4); | |
| 41 | ✗ | channels = get_ur_golomb_shorten(&gb, 0); | |
| 42 | ✗ | blocksize = 256; | |
| 43 | } else { | ||
| 44 | unsigned k; | ||
| 45 | 1 | k = get_ur_golomb_shorten(&gb, 2); | |
| 46 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (k > 31) |
| 47 | ✗ | return 0; | |
| 48 | 1 | internal_ftype = get_ur_golomb_shorten(&gb, k); | |
| 49 | 1 | k = get_ur_golomb_shorten(&gb, 2); | |
| 50 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (k > 31) |
| 51 | ✗ | return 0; | |
| 52 | 1 | channels = get_ur_golomb_shorten(&gb, k); | |
| 53 | 1 | k = get_ur_golomb_shorten(&gb, 2); | |
| 54 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (k > 31) |
| 55 | ✗ | return 0; | |
| 56 | 1 | blocksize = get_ur_golomb_shorten(&gb, k); | |
| 57 | } | ||
| 58 | |||
| 59 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | if (internal_ftype != 2 && internal_ftype != 3 && internal_ftype != 5) |
| 60 | ✗ | return 0; | |
| 61 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (channels < 1 || channels > 8) |
| 62 | ✗ | return 0; | |
| 63 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (blocksize < 1 || blocksize > 65535) |
| 64 | ✗ | return 0; | |
| 65 | |||
| 66 | 1 | return AVPROBE_SCORE_EXTENSION + 1; | |
| 67 | } | ||
| 68 | |||
| 69 | const FFInputFormat ff_shorten_demuxer = { | ||
| 70 | .p.name = "shn", | ||
| 71 | .p.long_name = NULL_IF_CONFIG_SMALL("raw Shorten"), | ||
| 72 | .p.flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS, | ||
| 73 | .p.extensions = "shn", | ||
| 74 | .p.priv_class = &ff_raw_demuxer_class, | ||
| 75 | .read_probe = shn_probe, | ||
| 76 | .read_header = ff_raw_audio_read_header, | ||
| 77 | .read_packet = ff_raw_read_partial_packet, | ||
| 78 | .raw_codec_id = AV_CODEC_ID_SHORTEN, | ||
| 79 | .priv_data_size = sizeof(FFRawDemuxerContext), | ||
| 80 | }; | ||
| 81 |