Commit 85ad5695 authored by Michael Niedermayer's avatar Michael Niedermayer

shorten decoder by (Jeff Muizelaar <jrmuizel gmail com>)

Originally committed as revision 3984 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 21754ce6
......@@ -194,6 +194,7 @@ void avcodec_register_all(void)
register_avcodec(&sol_dpcm_decoder);
register_avcodec(&qtrle_decoder);
register_avcodec(&flac_decoder);
register_avcodec(&shorten_decoder);
#endif /* CONFIG_DECODERS */
#ifdef AMR_NB
......
......@@ -164,6 +164,7 @@ enum CodecID {
CODEC_ID_FLAC,
CODEC_ID_MP3ADU,
CODEC_ID_MP3ON4,
CODEC_ID_SHORTEN,
CODEC_ID_OGGTHEORA= 0x16000,
......@@ -2008,6 +2009,7 @@ extern AVCodec ulti_decoder;
extern AVCodec qdraw_decoder;
extern AVCodec xl_decoder;
extern AVCodec qpeg_decoder;
extern AVCodec shorten_decoder;
/* pcm codecs */
#define PCM_CODEC(id, name) \
......
......@@ -284,6 +284,27 @@ static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int es
return (v>>1) ^ -(v&1);
}
/**
* read unsigned golomb rice code (shorten).
*/
static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){
return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
}
/**
* read signed golomb rice code (shorten).
*/
static inline int get_sr_golomb_shorten(GetBitContext* gb, int k)
{
int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0);
if (uvar & 1)
return ~(uvar >> 1);
else
return uvar >> 1;
}
#ifdef TRACE
static inline int get_ue(GetBitContext *s, char *file, const char *func, int line){
......
This diff is collapsed.
......@@ -188,6 +188,21 @@ static int ac3_read_header(AVFormatContext *s,
return 0;
}
static int shorten_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
AVStream *st;
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
st->codec.codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_SHORTEN;
st->need_parsing = 1;
/* the parameters will be extracted from the compressed bitstream */
return 0;
}
/* dts read */
static int dts_read_header(AVFormatContext *s,
AVFormatParameters *ap)
......@@ -295,6 +310,17 @@ static int h261_probe(AVProbeData *p)
return 0;
}
AVInputFormat shorten_iformat = {
"shn",
"raw shn",
0,
NULL,
shorten_read_header,
raw_read_partial_packet,
raw_read_close,
.extensions = "shn",
};
AVInputFormat ac3_iformat = {
"ac3",
"raw ac3",
......@@ -672,6 +698,9 @@ AVOutputFormat null_oformat = {
int raw_init(void)
{
av_register_input_format(&shorten_iformat);
av_register_input_format(&ac3_iformat);
av_register_output_format(&ac3_oformat);
......
......@@ -1845,6 +1845,7 @@ int av_find_stream_info(AVFormatContext *ic)
st->codec.codec_id == CODEC_ID_PGMYUV ||
st->codec.codec_id == CODEC_ID_PBM ||
st->codec.codec_id == CODEC_ID_PPM ||
st->codec.codec_id == CODEC_ID_SHORTEN ||
(st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing)))
try_decode_frame(st, pkt->data, pkt->size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment