~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavformat/ipmovie.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:23:28 UTC
  • mfrom: (0.4.7 sid)
  • mto: This revision was merged to the branch mainline in revision 76.
  • Revision ID: package-import@ubuntu.com-20120112222328-8jqdyodym3p84ygu
Tags: 2:1.0~rc4.dfsg1+svn34540-1
* New upstream snapshot
* upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
#include "libavutil/intreadwrite.h"
36
36
#include "avformat.h"
 
37
#include "internal.h"
37
38
 
38
39
#define CHUNK_PREAMBLE_SIZE 4
39
40
#define OPCODE_PREAMBLE_SIZE 4
88
89
    int64_t video_pts;
89
90
    uint32_t     palette[256];
90
91
    int          has_palette;
 
92
    int          changed;
91
93
 
92
94
    unsigned int audio_bits;
93
95
    unsigned int audio_channels;
115
117
    int chunk_type;
116
118
 
117
119
    if (s->audio_chunk_offset) {
 
120
        if (s->audio_type == CODEC_ID_NONE) {
 
121
            av_log(NULL, AV_LOG_ERROR, "Can not read audio packet before"
 
122
                   "audio codec is known\n");
 
123
                return CHUNK_BAD;
 
124
        }
118
125
 
119
126
        /* adjust for PCM audio by skipping chunk header */
120
127
        if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) {
137
144
            (s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
138
145
        else
139
146
            s->audio_frame_count +=
140
 
                (s->audio_chunk_size - 6) / s->audio_channels;
 
147
                (s->audio_chunk_size - 6 - s->audio_channels) / s->audio_channels;
141
148
 
142
149
        av_dlog(NULL, "sending audio frame with pts %"PRId64" (%d audio frames)\n",
143
150
                pkt->pts, s->audio_frame_count);
162
169
            }
163
170
        }
164
171
 
 
172
        if (s->changed) {
 
173
            ff_add_param_change(pkt, 0, 0, 0, s->video_width, s->video_height);
 
174
            s->changed = 0;
 
175
        }
165
176
        pkt->pos= s->decode_map_chunk_offset;
166
177
        avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
167
178
        s->decode_map_chunk_offset = 0;
217
228
    int first_color, last_color;
218
229
    int audio_flags;
219
230
    unsigned char r, g, b;
 
231
    unsigned int width, height;
220
232
 
221
233
    /* see if there are any pending packets */
222
234
    chunk_type = load_ipmovie_packet(s, pb, pkt);
373
385
                chunk_type = CHUNK_BAD;
374
386
                break;
375
387
            }
376
 
            s->video_width = AV_RL16(&scratch[0]) * 8;
377
 
            s->video_height = AV_RL16(&scratch[2]) * 8;
 
388
            width  = AV_RL16(&scratch[0]) * 8;
 
389
            height = AV_RL16(&scratch[2]) * 8;
 
390
            if (width != s->video_width) {
 
391
                s->video_width = width;
 
392
                s->changed++;
 
393
            }
 
394
            if (height != s->video_height) {
 
395
                s->video_height = height;
 
396
                s->changed++;
 
397
            }
378
398
            if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
379
399
                s->video_bpp = 8;
380
400
            } else {
559
579
        return AVERROR_INVALIDDATA;
560
580
 
561
581
    /* initialize the stream decoders */
562
 
    st = av_new_stream(s, 0);
 
582
    st = avformat_new_stream(s, NULL);
563
583
    if (!st)
564
584
        return AVERROR(ENOMEM);
565
 
    av_set_pts_info(st, 63, 1, 1000000);
 
585
    avpriv_set_pts_info(st, 63, 1, 1000000);
566
586
    ipmovie->video_stream_index = st->index;
567
587
    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
568
588
    st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO;
572
592
    st->codec->bits_per_coded_sample = ipmovie->video_bpp;
573
593
 
574
594
    if (ipmovie->audio_type) {
575
 
        st = av_new_stream(s, 0);
 
595
        st = avformat_new_stream(s, NULL);
576
596
        if (!st)
577
597
            return AVERROR(ENOMEM);
578
 
        av_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
 
598
        avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
579
599
        ipmovie->audio_stream_index = st->index;
580
600
        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
581
601
        st->codec->codec_id = ipmovie->audio_type;
616
636
}
617
637
 
618
638
AVInputFormat ff_ipmovie_demuxer = {
619
 
    "ipmovie",
620
 
    NULL_IF_CONFIG_SMALL("Interplay MVE format"),
621
 
    sizeof(IPMVEContext),
622
 
    ipmovie_probe,
623
 
    ipmovie_read_header,
624
 
    ipmovie_read_packet,
 
639
    .name           = "ipmovie",
 
640
    .long_name      = NULL_IF_CONFIG_SMALL("Interplay MVE format"),
 
641
    .priv_data_size = sizeof(IPMVEContext),
 
642
    .read_probe     = ipmovie_probe,
 
643
    .read_header    = ipmovie_read_header,
 
644
    .read_packet    = ipmovie_read_packet,
625
645
};