~ubuntu-branches/ubuntu/trusty/libav/trusty-proposed

« back to all changes in this revision

Viewing changes to libavformat/idroqdec.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2013-10-22 23:24:08 UTC
  • mfrom: (1.3.36 sid)
  • Revision ID: package-import@ubuntu.com-20131022232408-b8tvvn4pyzri9mi3
Tags: 6:9.10-1ubuntu1
* Build all -extra flavors from this source package, as libav got demoted
  from main to universe, cf LP: #1243235
* Simplify debian/rules to follow exactly the code that debian executes
* New upstream (LP: #1180288) fixes lots of security issues (LP: #1242802)
* Merge from unstable, remaining changes:
  - build-depend on libtiff5-dev rather than libtiff4-dev,
    avoids FTBFS caused by imlib
  - follow the regular debian codepaths

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 *   http://www.csse.monash.edu.au/~timf/
28
28
 */
29
29
 
 
30
#include "libavutil/channel_layout.h"
30
31
#include "libavutil/intreadwrite.h"
31
32
#include "avformat.h"
32
33
#include "internal.h"
66
67
    return AVPROBE_SCORE_MAX;
67
68
}
68
69
 
69
 
static int roq_read_header(AVFormatContext *s,
70
 
                           AVFormatParameters *ap)
 
70
static int roq_read_header(AVFormatContext *s)
71
71
{
72
72
    RoqDemuxContext *roq = s->priv_data;
73
73
    AVIOContext *pb = s->pb;
128
128
                avpriv_set_pts_info(st, 63, 1, roq->frame_rate);
129
129
                roq->video_stream_index = st->index;
130
130
                st->codec->codec_type   = AVMEDIA_TYPE_VIDEO;
131
 
                st->codec->codec_id     = CODEC_ID_ROQ;
 
131
                st->codec->codec_id     = AV_CODEC_ID_ROQ;
132
132
                st->codec->codec_tag    = 0;  /* no fourcc */
133
133
 
134
134
                if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
142
142
            break;
143
143
 
144
144
        case RoQ_QUAD_CODEBOOK:
 
145
            if (roq->video_stream_index < 0)
 
146
                return AVERROR_INVALIDDATA;
145
147
            /* packet needs to contain both this codebook and next VQ chunk */
146
148
            codebook_offset = avio_tell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
147
149
            codebook_size = chunk_size;
174
176
                avpriv_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE);
175
177
                roq->audio_stream_index = st->index;
176
178
                st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
177
 
                st->codec->codec_id = CODEC_ID_ROQ_DPCM;
 
179
                st->codec->codec_id = AV_CODEC_ID_ROQ_DPCM;
178
180
                st->codec->codec_tag = 0;  /* no tag */
179
 
                st->codec->channels = roq->audio_channels = chunk_type == RoQ_SOUND_STEREO ? 2 : 1;
 
181
                if (chunk_type == RoQ_SOUND_STEREO) {
 
182
                    st->codec->channels       = 2;
 
183
                    st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
 
184
                } else {
 
185
                    st->codec->channels       = 1;
 
186
                    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
 
187
                }
 
188
                roq->audio_channels    = st->codec->channels;
180
189
                st->codec->sample_rate = RoQ_AUDIO_SAMPLE_RATE;
181
190
                st->codec->bits_per_coded_sample = 16;
182
191
                st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
184
193
                st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
185
194
            }
186
195
        case RoQ_QUAD_VQ:
 
196
            if (chunk_type == RoQ_QUAD_VQ) {
 
197
                if (roq->video_stream_index < 0)
 
198
                    return AVERROR_INVALIDDATA;
 
199
            }
 
200
 
187
201
            /* load up the packet */
188
202
            if (av_new_packet(pkt, chunk_size + RoQ_CHUNK_PREAMBLE_SIZE))
189
203
                return AVERROR(EIO);
218
232
}
219
233
 
220
234
AVInputFormat ff_roq_demuxer = {
221
 
    .name           = "RoQ",
222
 
    .long_name      = NULL_IF_CONFIG_SMALL("id RoQ format"),
 
235
    .name           = "roq",
 
236
    .long_name      = NULL_IF_CONFIG_SMALL("id RoQ"),
223
237
    .priv_data_size = sizeof(RoqDemuxContext),
224
238
    .read_probe     = roq_probe,
225
239
    .read_header    = roq_read_header,