~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/libopencore-amr.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
 
80
80
typedef struct AMRContext {
81
81
    AVClass *av_class;
82
 
    int   frame_count;
 
82
    AVFrame frame;
83
83
    void *dec_state;
84
84
    void *enc_state;
85
85
    int   enc_bitrate;
88
88
} AMRContext;
89
89
 
90
90
static const AVOption options[] = {
91
 
    { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRContext, enc_dtx), FF_OPT_TYPE_INT, 0, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
 
91
    { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRContext, enc_dtx), AV_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
92
92
    { NULL }
93
93
};
94
94
 
100
100
{
101
101
    AMRContext *s  = avctx->priv_data;
102
102
 
103
 
    s->frame_count = 0;
104
103
    s->dec_state   = Decoder_Interface_init();
105
104
    if (!s->dec_state) {
106
105
        av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\n");
114
113
        return AVERROR(ENOSYS);
115
114
    }
116
115
 
 
116
    avcodec_get_frame_defaults(&s->frame);
 
117
    avctx->coded_frame = &s->frame;
 
118
 
117
119
    return 0;
118
120
}
119
121
 
122
124
    AMRContext *s = avctx->priv_data;
123
125
 
124
126
    Decoder_Interface_exit(s->dec_state);
 
127
 
125
128
    return 0;
126
129
}
127
130
 
128
131
static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
129
 
                               int *data_size, AVPacket *avpkt)
 
132
                               int *got_frame_ptr, AVPacket *avpkt)
130
133
{
131
134
    const uint8_t *buf = avpkt->data;
132
135
    int buf_size       = avpkt->size;
133
136
    AMRContext *s      = avctx->priv_data;
134
137
    static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
135
138
    enum Mode dec_mode;
136
 
    int packet_size;
 
139
    int packet_size, ret;
137
140
 
138
141
    av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n",
139
 
            buf, buf_size, s->frame_count);
 
142
            buf, buf_size, avctx->frame_number);
 
143
 
 
144
    /* get output buffer */
 
145
    s->frame.nb_samples = 160;
 
146
    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
 
147
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 
148
        return ret;
 
149
    }
140
150
 
141
151
    dec_mode    = (buf[0] >> 3) & 0x000F;
142
152
    packet_size = block_size[dec_mode] + 1;
147
157
        return AVERROR_INVALIDDATA;
148
158
    }
149
159
 
150
 
    s->frame_count++;
151
160
    av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n",
152
161
              packet_size, buf[0], buf[1], buf[2], buf[3]);
153
162
    /* call decoder */
154
 
    Decoder_Interface_Decode(s->dec_state, buf, data, 0);
155
 
    *data_size = 160 * 2;
 
163
    Decoder_Interface_Decode(s->dec_state, buf, (short *)s->frame.data[0], 0);
 
164
 
 
165
    *got_frame_ptr   = 1;
 
166
    *(AVFrame *)data = s->frame;
156
167
 
157
168
    return packet_size;
158
169
}
159
170
 
160
171
AVCodec ff_libopencore_amrnb_decoder = {
161
 
    "libopencore_amrnb",
162
 
    AVMEDIA_TYPE_AUDIO,
163
 
    CODEC_ID_AMR_NB,
164
 
    sizeof(AMRContext),
165
 
    amr_nb_decode_init,
166
 
    NULL,
167
 
    amr_nb_decode_close,
168
 
    amr_nb_decode_frame,
 
172
    .name           = "libopencore_amrnb",
 
173
    .type           = AVMEDIA_TYPE_AUDIO,
 
174
    .id             = CODEC_ID_AMR_NB,
 
175
    .priv_data_size = sizeof(AMRContext),
 
176
    .init           = amr_nb_decode_init,
 
177
    .close          = amr_nb_decode_close,
 
178
    .decode         = amr_nb_decode_frame,
 
179
    .capabilities   = CODEC_CAP_DR1,
169
180
    .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
170
181
};
171
182
 
173
184
{
174
185
    AMRContext *s = avctx->priv_data;
175
186
 
176
 
    s->frame_count = 0;
177
 
 
178
187
    if (avctx->sample_rate != 8000) {
179
188
        av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
180
189
        return AVERROR(ENOSYS);
230
239
}
231
240
 
232
241
AVCodec ff_libopencore_amrnb_encoder = {
233
 
    "libopencore_amrnb",
234
 
    AVMEDIA_TYPE_AUDIO,
235
 
    CODEC_ID_AMR_NB,
236
 
    sizeof(AMRContext),
237
 
    amr_nb_encode_init,
238
 
    amr_nb_encode_frame,
239
 
    amr_nb_encode_close,
240
 
    NULL,
 
242
    .name           = "libopencore_amrnb",
 
243
    .type           = AVMEDIA_TYPE_AUDIO,
 
244
    .id             = CODEC_ID_AMR_NB,
 
245
    .priv_data_size = sizeof(AMRContext),
 
246
    .init           = amr_nb_encode_init,
 
247
    .encode         = amr_nb_encode_frame,
 
248
    .close          = amr_nb_encode_close,
241
249
    .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
242
250
    .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
243
251
    .priv_class = &class,
252
260
#include <opencore-amrwb/if_rom.h>
253
261
 
254
262
typedef struct AMRWBContext {
 
263
    AVFrame frame;
255
264
    void  *state;
256
265
} AMRWBContext;
257
266
 
268
277
        return AVERROR(ENOSYS);
269
278
    }
270
279
 
 
280
    avcodec_get_frame_defaults(&s->frame);
 
281
    avctx->coded_frame = &s->frame;
 
282
 
271
283
    return 0;
272
284
}
273
285
 
274
286
static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
275
 
                               int *data_size, AVPacket *avpkt)
 
287
                               int *got_frame_ptr, AVPacket *avpkt)
276
288
{
277
289
    const uint8_t *buf = avpkt->data;
278
290
    int buf_size       = avpkt->size;
279
291
    AMRWBContext *s    = avctx->priv_data;
280
 
    int mode;
 
292
    int mode, ret;
281
293
    int packet_size;
282
294
    static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
283
295
 
284
 
    if (!buf_size)
285
 
        /* nothing to do */
286
 
        return 0;
 
296
    /* get output buffer */
 
297
    s->frame.nb_samples = 320;
 
298
    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
 
299
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 
300
        return ret;
 
301
    }
287
302
 
288
303
    mode        = (buf[0] >> 3) & 0x000F;
289
304
    packet_size = block_size[mode];
294
309
        return AVERROR_INVALIDDATA;
295
310
    }
296
311
 
297
 
    D_IF_decode(s->state, buf, data, _good_frame);
298
 
    *data_size = 320 * 2;
 
312
    D_IF_decode(s->state, buf, (short *)s->frame.data[0], _good_frame);
 
313
 
 
314
    *got_frame_ptr   = 1;
 
315
    *(AVFrame *)data = s->frame;
 
316
 
299
317
    return packet_size;
300
318
}
301
319
 
308
326
}
309
327
 
310
328
AVCodec ff_libopencore_amrwb_decoder = {
311
 
    "libopencore_amrwb",
312
 
    AVMEDIA_TYPE_AUDIO,
313
 
    CODEC_ID_AMR_WB,
314
 
    sizeof(AMRWBContext),
315
 
    amr_wb_decode_init,
316
 
    NULL,
317
 
    amr_wb_decode_close,
318
 
    amr_wb_decode_frame,
 
329
    .name           = "libopencore_amrwb",
 
330
    .type           = AVMEDIA_TYPE_AUDIO,
 
331
    .id             = CODEC_ID_AMR_WB,
 
332
    .priv_data_size = sizeof(AMRWBContext),
 
333
    .init           = amr_wb_decode_init,
 
334
    .close          = amr_wb_decode_close,
 
335
    .decode         = amr_wb_decode_frame,
 
336
    .capabilities   = CODEC_CAP_DR1,
319
337
    .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"),
320
338
};
321
339