~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavformat/idcin.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
#include "avformat.h"
72
72
 
73
73
#define HUFFMAN_TABLE_SIZE (64 * 1024)
74
 
#define FRAME_PTS_INC (90000 / 14)
 
74
#define IDCIN_FPS 14
75
75
 
76
76
typedef struct IdcinDemuxContext {
77
77
    int video_stream_index;
104
104
     * audio channels: 0 for no audio, or 1 or 2
105
105
     */
106
106
 
107
 
    /* cannot proceed without 20 bytes */
108
 
    if (p->buf_size < 20)
109
 
        return 0;
110
 
 
111
107
    /* check the video width */
112
108
    number = AV_RL32(&p->buf[0]);
113
109
    if ((number == 0) || (number > 1024))
140
136
static int idcin_read_header(AVFormatContext *s,
141
137
                             AVFormatParameters *ap)
142
138
{
143
 
    ByteIOContext *pb = &s->pb;
144
 
    IdcinDemuxContext *idcin = (IdcinDemuxContext *)s->priv_data;
 
139
    ByteIOContext *pb = s->pb;
 
140
    IdcinDemuxContext *idcin = s->priv_data;
145
141
    AVStream *st;
146
142
    unsigned int width, height;
147
143
    unsigned int sample_rate, bytes_per_sample, channels;
155
151
 
156
152
    st = av_new_stream(s, 0);
157
153
    if (!st)
158
 
        return AVERROR_NOMEM;
159
 
    av_set_pts_info(st, 33, 1, 90000);
 
154
        return AVERROR(ENOMEM);
 
155
    av_set_pts_info(st, 33, 1, IDCIN_FPS);
160
156
    idcin->video_stream_index = st->index;
161
157
    st->codec->codec_type = CODEC_TYPE_VIDEO;
162
158
    st->codec->codec_id = CODEC_ID_IDCIN;
169
165
    st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
170
166
    if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
171
167
        HUFFMAN_TABLE_SIZE)
172
 
        return AVERROR_IO;
 
168
        return AVERROR(EIO);
173
169
    /* save a reference in order to transport the palette */
174
170
    st->codec->palctrl = &idcin->palctrl;
175
171
 
178
174
        idcin->audio_present = 1;
179
175
        st = av_new_stream(s, 0);
180
176
        if (!st)
181
 
            return AVERROR_NOMEM;
182
 
        av_set_pts_info(st, 33, 1, 90000);
 
177
            return AVERROR(ENOMEM);
 
178
        av_set_pts_info(st, 33, 1, IDCIN_FPS);
183
179
        idcin->audio_stream_index = st->index;
184
180
        st->codec->codec_type = CODEC_TYPE_AUDIO;
185
181
        st->codec->codec_tag = 1;
218
214
    int ret;
219
215
    unsigned int command;
220
216
    unsigned int chunk_size;
221
 
    IdcinDemuxContext *idcin = (IdcinDemuxContext *)s->priv_data;
222
 
    ByteIOContext *pb = &s->pb;
 
217
    IdcinDemuxContext *idcin = s->priv_data;
 
218
    ByteIOContext *pb = s->pb;
223
219
    int i;
224
220
    int palette_scale;
225
221
    unsigned char r, g, b;
226
222
    unsigned char palette_buffer[768];
227
223
 
228
 
    if (url_feof(&s->pb))
229
 
        return AVERROR_IO;
 
224
    if (url_feof(s->pb))
 
225
        return AVERROR(EIO);
230
226
 
231
227
    if (idcin->next_chunk_is_video) {
232
228
        command = get_le32(pb);
233
229
        if (command == 2) {
234
 
            return AVERROR_IO;
 
230
            return AVERROR(EIO);
235
231
        } else if (command == 1) {
236
232
            /* trigger a palette change */
237
233
            idcin->palctrl.palette_changed = 1;
238
234
            if (get_buffer(pb, palette_buffer, 768) != 768)
239
 
                return AVERROR_IO;
 
235
                return AVERROR(EIO);
240
236
            /* scale the palette as necessary */
241
237
            palette_scale = 2;
242
238
            for (i = 0; i < 768; i++)
259
255
        chunk_size -= 4;
260
256
        ret= av_get_packet(pb, pkt, chunk_size);
261
257
        if (ret != chunk_size)
262
 
            return AVERROR_IO;
 
258
            return AVERROR(EIO);
263
259
        pkt->stream_index = idcin->video_stream_index;
264
260
        pkt->pts = idcin->pts;
265
261
    } else {
270
266
            chunk_size = idcin->audio_chunk_size1;
271
267
        ret= av_get_packet(pb, pkt, chunk_size);
272
268
        if (ret != chunk_size)
273
 
            return AVERROR_IO;
 
269
            return AVERROR(EIO);
274
270
        pkt->stream_index = idcin->audio_stream_index;
275
271
        pkt->pts = idcin->pts;
276
272
 
277
273
        idcin->current_audio_chunk ^= 1;
278
 
        idcin->pts += FRAME_PTS_INC;
 
274
        idcin->pts++;
279
275
    }
280
276
 
281
277
    if (idcin->audio_present)