3 * Copyright (c) 2001 Fabrice Bellard
4 * Copyright (c) 2005 Alex Beregszaszi
5 * Copyright (c) 2015 Carl Eugen Hoyos
7 * This file is part of FFmpeg.
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.
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.
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
26 #include "libavcodec/golomb.h"
28 static int shn_probe(const AVProbeData
*p
)
31 int version
, internal_ftype
, channels
, blocksize
;
33 if (AV_RB32(p
->buf
) != 0x616a6b67)
36 if (init_get_bits8(&gb
, p
->buf
+ 5, p
->buf_size
- 5 - AV_INPUT_BUFFER_PADDING_SIZE
) < 0)
39 internal_ftype
= get_ur_golomb_shorten(&gb
, 4);
40 channels
= get_ur_golomb_shorten(&gb
, 0);
44 k
= get_ur_golomb_shorten(&gb
, 2);
47 internal_ftype
= get_ur_golomb_shorten(&gb
, k
);
48 k
= get_ur_golomb_shorten(&gb
, 2);
51 channels
= get_ur_golomb_shorten(&gb
, k
);
52 k
= get_ur_golomb_shorten(&gb
, 2);
55 blocksize
= get_ur_golomb_shorten(&gb
, k
);
58 if (internal_ftype
!= 2 && internal_ftype
!= 3 && internal_ftype
!= 5)
60 if (channels
< 1 || channels
> 8)
62 if (blocksize
< 1 || blocksize
> 65535)
65 return AVPROBE_SCORE_EXTENSION
+ 1;
68 FF_RAW_DEMUXER_CLASS(shorten
)
69 AVInputFormat ff_shorten_demuxer
= {
71 .long_name
= NULL_IF_CONFIG_SMALL("raw Shorten"),
72 .read_probe
= shn_probe
,
73 .read_header
= ff_raw_audio_read_header
,
74 .read_packet
= ff_raw_read_partial_packet
,
75 .flags
= AVFMT_NOBINSEARCH
| AVFMT_NOGENSEARCH
| AVFMT_NO_BYTE_SEEK
| AVFMT_NOTIMESTAMPS
,
77 .raw_codec_id
= AV_CODEC_ID_SHORTEN
,
78 .priv_data_size
= sizeof(FFRawDemuxerContext
),
79 .priv_class
= &shorten_demuxer_class
,