Mercurial > libavcodec.hg
annotate 8svx.c @ 9548:c005889b5389 libavcodec
Support >8bit per component YUV in FFV1.
decoding becomes slower, encoding becomes faster, with gcc on duron.
some inlining overrides like av_flatten are added to keep inlining similar
to before.
author | michael |
---|---|
date | Fri, 24 Apr 2009 04:10:32 +0000 |
parents | 54bc8a2727b0 |
children | 8a4984c5cacc |
rev | line source |
---|---|
6547 | 1 /* |
6555 | 2 * 8SVX audio decoder |
6547 | 3 * Copyright (C) 2008 Jaikrishnan Menon |
4 * | |
5 * This file is part of FFmpeg. | |
6 * | |
7 * FFmpeg is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * FFmpeg is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with FFmpeg; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 | |
22 /** | |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
7981
diff
changeset
|
23 * @file libavcodec/8svx.c |
6547 | 24 * 8svx audio decoder |
25 * @author Jaikrishnan Menon | |
26 * supports: fibonacci delta encoding | |
27 * : exponential encoding | |
28 */ | |
29 | |
30 #include "avcodec.h" | |
31 | |
6554
a8a3c0be40c7
cosmetics: Write some Doxygen comments in a more compact fashion.
diego
parents:
6547
diff
changeset
|
32 /** decoder context */ |
6547 | 33 typedef struct EightSvxContext { |
34 int16_t fib_acc; | |
7981
fcc940b7952e
Make 8svx codec context table pointer const to match the type of the
reimar
parents:
7977
diff
changeset
|
35 const int16_t *table; |
6547 | 36 } EightSvxContext; |
37 | |
7977 | 38 static const int16_t fibonacci[16] = { -34<<8, -21<<8, -13<<8, -8<<8, -5<<8, -3<<8, -2<<8, -1<<8, |
6547 | 39 0, 1<<8, 2<<8, 3<<8, 5<<8, 8<<8, 13<<8, 21<<8 }; |
7977 | 40 static const int16_t exponential[16] = { -128<<8, -64<<8, -32<<8, -16<<8, -8<<8, -4<<8, -2<<8, -1<<8, |
6547 | 41 0, 1<<8, 2<<8, 4<<8, 8<<8, 16<<8, 32<<8, 64<<8 }; |
42 | |
6554
a8a3c0be40c7
cosmetics: Write some Doxygen comments in a more compact fashion.
diego
parents:
6547
diff
changeset
|
43 /** decode a frame */ |
6547 | 44 static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
45 AVPacket *avpkt) |
6547 | 46 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
47 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
48 int buf_size = avpkt->size; |
6547 | 49 EightSvxContext *esc = avctx->priv_data; |
50 int16_t *out_data = data; | |
51 int consumed = buf_size; | |
52 const uint8_t *buf_end = buf + buf_size; | |
53 | |
54 if((*data_size >> 2) < buf_size) | |
55 return -1; | |
56 | |
57 if(avctx->frame_number == 0) { | |
58 esc->fib_acc = buf[1] << 8; | |
59 buf_size -= 2; | |
60 buf += 2; | |
61 } | |
62 | |
63 *data_size = buf_size << 2; | |
64 | |
65 while(buf < buf_end) { | |
66 uint8_t d = *buf++; | |
67 esc->fib_acc += esc->table[d & 0x0f]; | |
68 *out_data++ = esc->fib_acc; | |
69 esc->fib_acc += esc->table[d >> 4]; | |
70 *out_data++ = esc->fib_acc; | |
71 } | |
72 | |
73 return consumed; | |
74 } | |
75 | |
6554
a8a3c0be40c7
cosmetics: Write some Doxygen comments in a more compact fashion.
diego
parents:
6547
diff
changeset
|
76 /** initialize 8svx decoder */ |
6547 | 77 static av_cold int eightsvx_decode_init(AVCodecContext *avctx) |
78 { | |
79 EightSvxContext *esc = avctx->priv_data; | |
80 | |
81 switch(avctx->codec->id) { | |
82 case CODEC_ID_8SVX_FIB: | |
83 esc->table = fibonacci; | |
84 break; | |
85 case CODEC_ID_8SVX_EXP: | |
86 esc->table = exponential; | |
87 break; | |
88 default: | |
89 return -1; | |
90 } | |
7451
85ab7655ad4d
Modify all codecs to report their supported input and output sample format(s).
pross
parents:
7040
diff
changeset
|
91 avctx->sample_fmt = SAMPLE_FMT_S16; |
6547 | 92 return 0; |
93 } | |
94 | |
95 AVCodec eightsvx_fib_decoder = { | |
6711
78c7765d9618
Make 8SVX codec names just a single word for consistency with other codec names.
diego
parents:
6710
diff
changeset
|
96 .name = "8svx_fib", |
6547 | 97 .type = CODEC_TYPE_AUDIO, |
98 .id = CODEC_ID_8SVX_FIB, | |
99 .priv_data_size = sizeof (EightSvxContext), | |
100 .init = eightsvx_decode_init, | |
101 .decode = eightsvx_decode_frame, | |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6711
diff
changeset
|
102 .long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"), |
6547 | 103 }; |
104 | |
105 AVCodec eightsvx_exp_decoder = { | |
6711
78c7765d9618
Make 8SVX codec names just a single word for consistency with other codec names.
diego
parents:
6710
diff
changeset
|
106 .name = "8svx_exp", |
6547 | 107 .type = CODEC_TYPE_AUDIO, |
108 .id = CODEC_ID_8SVX_EXP, | |
109 .priv_data_size = sizeof (EightSvxContext), | |
110 .init = eightsvx_decode_init, | |
111 .decode = eightsvx_decode_frame, | |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6711
diff
changeset
|
112 .long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"), |
6547 | 113 }; |