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

« back to all changes in this revision

Viewing changes to libavformat/ipmovie.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:
32
32
 * up and sending out the chunks.
33
33
 */
34
34
 
 
35
#include "libavutil/channel_layout.h"
35
36
#include "libavutil/intreadwrite.h"
36
37
#include "avformat.h"
37
38
#include "internal.h"
94
95
    unsigned int audio_bits;
95
96
    unsigned int audio_channels;
96
97
    unsigned int audio_sample_rate;
97
 
    enum CodecID audio_type;
 
98
    enum AVCodecID audio_type;
98
99
    unsigned int audio_frame_count;
99
100
 
100
101
    int video_stream_index;
117
118
    int chunk_type;
118
119
 
119
120
    if (s->audio_chunk_offset) {
120
 
        if (s->audio_type == CODEC_ID_NONE) {
 
121
        if (s->audio_type == AV_CODEC_ID_NONE) {
121
122
            av_log(NULL, AV_LOG_ERROR, "Can not read audio packet before"
122
123
                   "audio codec is known\n");
123
124
                return CHUNK_BAD;
124
125
        }
125
126
 
126
127
        /* adjust for PCM audio by skipping chunk header */
127
 
        if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) {
 
128
        if (s->audio_type != AV_CODEC_ID_INTERPLAY_DPCM) {
128
129
            s->audio_chunk_offset += 6;
129
130
            s->audio_chunk_size -= 6;
130
131
        }
139
140
        pkt->pts = s->audio_frame_count;
140
141
 
141
142
        /* audio frame maintenance */
142
 
        if (s->audio_type != CODEC_ID_INTERPLAY_DPCM)
 
143
        if (s->audio_type != AV_CODEC_ID_INTERPLAY_DPCM)
143
144
            s->audio_frame_count +=
144
145
            (s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
145
146
        else
356
357
            s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
357
358
            /* bit 2 indicates compressed audio in version 1 opcode */
358
359
            if ((opcode_version == 1) && (audio_flags & 0x4))
359
 
                s->audio_type = CODEC_ID_INTERPLAY_DPCM;
 
360
                s->audio_type = AV_CODEC_ID_INTERPLAY_DPCM;
360
361
            else if (s->audio_bits == 16)
361
 
                s->audio_type = CODEC_ID_PCM_S16LE;
 
362
                s->audio_type = AV_CODEC_ID_PCM_S16LE;
362
363
            else
363
 
                s->audio_type = CODEC_ID_PCM_U8;
 
364
                s->audio_type = AV_CODEC_ID_PCM_U8;
364
365
            av_dlog(NULL, "audio: %d bits, %d Hz, %s, %s format\n",
365
366
                    s->audio_bits, s->audio_sample_rate,
366
367
                    (s->audio_channels == 2) ? "stereo" : "mono",
367
 
                    (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ?
 
368
                    (s->audio_type == AV_CODEC_ID_INTERPLAY_DPCM) ?
368
369
                    "Interplay audio" : "PCM");
369
370
            break;
370
371
 
535
536
    return 0;
536
537
}
537
538
 
538
 
static int ipmovie_read_header(AVFormatContext *s,
539
 
                               AVFormatParameters *ap)
 
539
static int ipmovie_read_header(AVFormatContext *s)
540
540
{
541
541
    IPMVEContext *ipmovie = s->priv_data;
542
542
    AVIOContext *pb = s->pb;
574
574
    avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
575
575
 
576
576
    if (chunk_type == CHUNK_VIDEO)
577
 
        ipmovie->audio_type = CODEC_ID_NONE;  /* no audio */
 
577
        ipmovie->audio_type = AV_CODEC_ID_NONE;  /* no audio */
578
578
    else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
579
579
        return AVERROR_INVALIDDATA;
580
580
 
585
585
    avpriv_set_pts_info(st, 63, 1, 1000000);
586
586
    ipmovie->video_stream_index = st->index;
587
587
    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
588
 
    st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO;
 
588
    st->codec->codec_id = AV_CODEC_ID_INTERPLAY_VIDEO;
589
589
    st->codec->codec_tag = 0;  /* no fourcc */
590
590
    st->codec->width = ipmovie->video_width;
591
591
    st->codec->height = ipmovie->video_height;
601
601
        st->codec->codec_id = ipmovie->audio_type;
602
602
        st->codec->codec_tag = 0;  /* no tag */
603
603
        st->codec->channels = ipmovie->audio_channels;
 
604
        st->codec->channel_layout = st->codec->channels == 1 ? AV_CH_LAYOUT_MONO :
 
605
                                                               AV_CH_LAYOUT_STEREO;
604
606
        st->codec->sample_rate = ipmovie->audio_sample_rate;
605
607
        st->codec->bits_per_coded_sample = ipmovie->audio_bits;
606
608
        st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
607
609
            st->codec->bits_per_coded_sample;
608
 
        if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM)
 
610
        if (st->codec->codec_id == AV_CODEC_ID_INTERPLAY_DPCM)
609
611
            st->codec->bit_rate /= 2;
610
612
        st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
611
613
    }
637
639
 
638
640
AVInputFormat ff_ipmovie_demuxer = {
639
641
    .name           = "ipmovie",
640
 
    .long_name      = NULL_IF_CONFIG_SMALL("Interplay MVE format"),
 
642
    .long_name      = NULL_IF_CONFIG_SMALL("Interplay MVE"),
641
643
    .priv_data_size = sizeof(IPMVEContext),
642
644
    .read_probe     = ipmovie_probe,
643
645
    .read_header    = ipmovie_read_header,