~ubuntu-branches/debian/experimental/libav/experimental

« back to all changes in this revision

Viewing changes to libavcodec/libvorbis.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2014-08-10 09:45:02 UTC
  • mfrom: (1.1.28) (2.1.45 sid)
  • Revision ID: package-import@ubuntu.com-20140810094502-p8pds4kq0zpig5oq
Tags: 6:11~alpha1-1
* New upstream Release v11
  - Fixes Unchecked conversion from double to enum (Closes: #749164)
* Add some post v11_alpha1 patches from upstream
* All SONAMEs bumped because of internal changes, but external API is
  promised to have not changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 * an output packet will always start at the same point as one of the input
44
44
 * packets.
45
45
 */
46
 
#define OGGVORBIS_FRAME_SIZE 64
 
46
#define LIBVORBIS_FRAME_SIZE 64
47
47
 
48
48
#define BUFFER_SIZE (1024 * 64)
49
49
 
50
 
typedef struct OggVorbisContext {
 
50
typedef struct LibvorbisContext {
51
51
    AVClass *av_class;                  /**< class for AVOptions            */
52
52
    vorbis_info vi;                     /**< vorbis_info used during init   */
53
53
    vorbis_dsp_state vd;                /**< DSP state used for analysis    */
60
60
    double iblock;                      /**< impulse block bias option      */
61
61
    VorbisParseContext vp;              /**< parse context to get durations */
62
62
    AudioFrameQueue afq;                /**< frame queue for timestamps     */
63
 
} OggVorbisContext;
 
63
} LibvorbisContext;
64
64
 
65
65
static const AVOption options[] = {
66
 
    { "iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
 
66
    { "iblock", "Sets the impulse block bias", offsetof(LibvorbisContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
67
67
    { NULL }
68
68
};
69
69
 
85
85
    }
86
86
}
87
87
 
88
 
static av_cold int oggvorbis_init_encoder(vorbis_info *vi,
89
 
                                          AVCodecContext *avctx)
 
88
static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
90
89
{
91
 
    OggVorbisContext *s = avctx->priv_data;
 
90
    LibvorbisContext *s = avctx->priv_data;
92
91
    double cfreq;
93
92
    int ret;
94
93
 
148
147
    return 1 + l / 255 + l;
149
148
}
150
149
 
151
 
static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)
 
150
static av_cold int libvorbis_encode_close(AVCodecContext *avctx)
152
151
{
153
 
    OggVorbisContext *s = avctx->priv_data;
 
152
    LibvorbisContext *s = avctx->priv_data;
154
153
 
155
154
    /* notify vorbisenc this is EOF */
156
155
    if (s->dsp_initialized)
167
166
    return 0;
168
167
}
169
168
 
170
 
static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
 
169
static av_cold int libvorbis_encode_init(AVCodecContext *avctx)
171
170
{
172
 
    OggVorbisContext *s = avctx->priv_data;
 
171
    LibvorbisContext *s = avctx->priv_data;
173
172
    ogg_packet header, header_comm, header_code;
174
173
    uint8_t *p;
175
174
    unsigned int offset;
176
175
    int ret;
177
176
 
178
177
    vorbis_info_init(&s->vi);
179
 
    if ((ret = oggvorbis_init_encoder(&s->vi, avctx))) {
 
178
    if ((ret = libvorbis_setup(&s->vi, avctx))) {
180
179
        av_log(avctx, AV_LOG_ERROR, "encoder setup failed\n");
181
180
        goto error;
182
181
    }
229
228
 
230
229
    vorbis_comment_clear(&s->vc);
231
230
 
232
 
    avctx->frame_size = OGGVORBIS_FRAME_SIZE;
 
231
    avctx->frame_size = LIBVORBIS_FRAME_SIZE;
233
232
    ff_af_queue_init(avctx, &s->afq);
234
233
 
235
234
    s->pkt_fifo = av_fifo_alloc(BUFFER_SIZE);
240
239
 
241
240
    return 0;
242
241
error:
243
 
    oggvorbis_encode_close(avctx);
 
242
    libvorbis_encode_close(avctx);
244
243
    return ret;
245
244
}
246
245
 
247
 
static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 
246
static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
248
247
                                  const AVFrame *frame, int *got_packet_ptr)
249
248
{
250
 
    OggVorbisContext *s = avctx->priv_data;
 
249
    LibvorbisContext *s = avctx->priv_data;
251
250
    ogg_packet op;
252
251
    int ret, duration;
253
252
 
340
339
    .long_name      = NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
341
340
    .type           = AVMEDIA_TYPE_AUDIO,
342
341
    .id             = AV_CODEC_ID_VORBIS,
343
 
    .priv_data_size = sizeof(OggVorbisContext),
344
 
    .init           = oggvorbis_encode_init,
345
 
    .encode2        = oggvorbis_encode_frame,
346
 
    .close          = oggvorbis_encode_close,
 
342
    .priv_data_size = sizeof(LibvorbisContext),
 
343
    .init           = libvorbis_encode_init,
 
344
    .encode2        = libvorbis_encode_frame,
 
345
    .close          = libvorbis_encode_close,
347
346
    .capabilities   = CODEC_CAP_DELAY,
348
347
    .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
349
348
                                                      AV_SAMPLE_FMT_NONE },