~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/mlp_parser.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include <stdint.h>
28
28
 
 
29
#include "libavutil/channel_layout.h"
29
30
#include "libavutil/crc.h"
30
 
#include "libavutil/audioconvert.h"
31
31
#include "get_bits.h"
32
32
#include "parser.h"
33
33
#include "mlp_parser.h"
79
79
    AV_CH_LOW_FREQUENCY,                                    // LFE
80
80
    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRs
81
81
    AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT,             // LRvh
82
 
    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRc
 
82
    AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, // LRc
83
83
    AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT,                       // LRrs
84
84
    AV_CH_BACK_CENTER,                                      // Cs
85
 
    AV_CH_TOP_BACK_CENTER,                                  // Ts
86
 
    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRsd
87
 
    AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, // LRw
88
 
    AV_CH_TOP_BACK_CENTER,                                  // Cvh
89
 
    AV_CH_LOW_FREQUENCY                                     // LFE2
 
85
    AV_CH_TOP_CENTER,                                       // Ts
 
86
    AV_CH_SURROUND_DIRECT_LEFT|AV_CH_SURROUND_DIRECT_RIGHT, // LRsd
 
87
    AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT,                       // LRw
 
88
    AV_CH_TOP_FRONT_CENTER,                                 // Cvh
 
89
    AV_CH_LOW_FREQUENCY_2,                                  // LFE2
90
90
};
91
91
 
92
92
static int mlp_samplerate(int in)
109
109
 
110
110
static uint64_t truehd_layout(int chanmap)
111
111
{
112
 
    int layout = 0, i;
 
112
    int i;
 
113
    uint64_t layout = 0;
113
114
 
114
115
    for (i = 0; i < 13; i++)
115
116
        layout |= thd_layout[i] * ((chanmap >> i) & 1);
125
126
 
126
127
int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
127
128
{
128
 
    int ratebits;
 
129
    int ratebits, channel_arrangement;
129
130
    uint16_t checksum;
130
131
 
131
132
    assert(get_bits_count(gb) == 0);
156
157
 
157
158
        skip_bits(gb, 11);
158
159
 
159
 
        mh->channels_mlp = get_bits(gb, 5);
 
160
        channel_arrangement    = get_bits(gb, 5);
 
161
        mh->channels_mlp       = mlp_channels[channel_arrangement];
 
162
        mh->channel_layout_mlp = mlp_layout[channel_arrangement];
160
163
    } else if (mh->stream_type == 0xba) {
161
164
        mh->group1_bits = 24; // TODO: Is this information actually conveyed anywhere?
162
165
        mh->group2_bits = 0;
167
170
 
168
171
        skip_bits(gb, 8);
169
172
 
170
 
        mh->channels_thd_stream1 = get_bits(gb, 5);
 
173
        channel_arrangement            = get_bits(gb, 5);
 
174
        mh->channels_thd_stream1       = truehd_channels(channel_arrangement);
 
175
        mh->channel_layout_thd_stream1 = truehd_layout(channel_arrangement);
171
176
 
172
177
        skip_bits(gb, 2);
173
178
 
174
 
        mh->channels_thd_stream2 = get_bits(gb, 13);
 
179
        channel_arrangement            = get_bits(gb, 13);
 
180
        mh->channels_thd_stream2       = truehd_channels(channel_arrangement);
 
181
        mh->channel_layout_thd_stream2 = truehd_layout(channel_arrangement);
175
182
    } else
176
183
        return AVERROR_INVALIDDATA;
177
184
 
311
318
        else
312
319
            avctx->sample_fmt = AV_SAMPLE_FMT_S16;
313
320
        avctx->sample_rate = mh.group1_samplerate;
314
 
        avctx->frame_size = mh.access_unit_size;
 
321
        s->duration = mh.access_unit_size;
315
322
 
316
323
        if (mh.stream_type == 0xbb) {
317
324
            /* MLP stream */
318
 
            avctx->channels = mlp_channels[mh.channels_mlp];
319
 
            avctx->channel_layout = mlp_layout[mh.channels_mlp];
 
325
            avctx->channels       = mh.channels_mlp;
 
326
            avctx->channel_layout = mh.channel_layout_mlp;
320
327
        } else { /* mh.stream_type == 0xba */
321
328
            /* TrueHD stream */
322
329
            if (mh.channels_thd_stream2) {
323
 
                avctx->channels = truehd_channels(mh.channels_thd_stream2);
324
 
                avctx->channel_layout = truehd_layout(mh.channels_thd_stream2);
 
330
                avctx->channels       = mh.channels_thd_stream2;
 
331
                avctx->channel_layout = mh.channel_layout_thd_stream2;
325
332
            } else {
326
 
                avctx->channels = truehd_channels(mh.channels_thd_stream1);
327
 
                avctx->channel_layout = truehd_layout(mh.channels_thd_stream1);
 
333
                avctx->channels       = mh.channels_thd_stream1;
 
334
                avctx->channel_layout = mh.channel_layout_thd_stream1;
328
335
            }
329
336
        }
330
337
 
345
352
}
346
353
 
347
354
AVCodecParser ff_mlp_parser = {
348
 
    .codec_ids      = { CODEC_ID_MLP, CODEC_ID_TRUEHD },
 
355
    .codec_ids      = { AV_CODEC_ID_MLP, AV_CODEC_ID_TRUEHD },
349
356
    .priv_data_size = sizeof(MLPParseContext),
350
357
    .parser_init    = mlp_init,
351
358
    .parser_parse   = mlp_parse,