Revision 01f4895c libavformat/avidec.c

View differences:

libavformat/avidec.c
178 178
	           goto fail;
179 179
                
180 180
		ast = s->streams[0]->priv_data;
181
		av_freep(&s->streams[0]->codec.extradata);
181
		av_freep(&s->streams[0]->codec->extradata);
182 182
		av_freep(&s->streams[0]);
183 183
		s->nb_streams = 0;
184 184
	        avi->dv_demux = dv_init_demux(s);
......
199 199
            } 
200 200
            st = s->streams[stream_index];
201 201
            ast = st->priv_data;
202
            st->codec.stream_codec_tag= handler;
202
            st->codec->stream_codec_tag= handler;
203 203

  
204 204
            get_le32(pb); /* flags */
205 205
            get_le16(pb); /* priority */
......
259 259
                switch(codec_type) {
260 260
                case CODEC_TYPE_VIDEO:
261 261
                    get_le32(pb); /* size */
262
                    st->codec.width = get_le32(pb);
263
                    st->codec.height = get_le32(pb);
262
                    st->codec->width = get_le32(pb);
263
                    st->codec->height = get_le32(pb);
264 264
                    get_le16(pb); /* panes */
265
                    st->codec.bits_per_sample= get_le16(pb); /* depth */
265
                    st->codec->bits_per_sample= get_le16(pb); /* depth */
266 266
                    tag1 = get_le32(pb);
267 267
                    get_le32(pb); /* ImageSize */
268 268
                    get_le32(pb); /* XPelsPerMeter */
......
271 271
                    get_le32(pb); /* ClrImportant */
272 272

  
273 273
                 if(size > 10*4 && size<(1<<30)){
274
                    st->codec.extradata_size= size - 10*4;
275
                    st->codec.extradata= av_malloc(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
276
                    get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
274
                    st->codec->extradata_size= size - 10*4;
275
                    st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
276
                    get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
277 277
                 }
278 278
                    
279
                    if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly
279
                    if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
280 280
                        get_byte(pb);
281 281

  
282 282
                    /* Extract palette from extradata if bpp <= 8 */
283 283
                    /* This code assumes that extradata contains only palette */
284 284
                    /* This is true for all paletted codecs implemented in ffmpeg */
285
                    if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) {
286
                        st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl));
285
                    if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) {
286
                        st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
287 287
#ifdef WORDS_BIGENDIAN
288
                        for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++)
289
                            st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]);
288
                        for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
289
                            st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]);
290 290
#else
291
                        memcpy(st->codec.palctrl->palette, st->codec.extradata,
292
                               FFMIN(st->codec.extradata_size, AVPALETTE_SIZE));
291
                        memcpy(st->codec->palctrl->palette, st->codec->extradata,
292
                               FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
293 293
#endif
294
                        st->codec.palctrl->palette_changed = 1;
294
                        st->codec->palctrl->palette_changed = 1;
295 295
                    }
296 296

  
297 297
#ifdef DEBUG
298 298
                    print_tag("video", tag1, 0);
299 299
#endif
300
                    st->codec.codec_type = CODEC_TYPE_VIDEO;
301
                    st->codec.codec_tag = tag1;
302
                    st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
303
                    if (st->codec.codec_id == CODEC_ID_XAN_WC4)
300
                    st->codec->codec_type = CODEC_TYPE_VIDEO;
301
                    st->codec->codec_tag = tag1;
302
                    st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
303
                    if (st->codec->codec_id == CODEC_ID_XAN_WC4)
304 304
                        xan_video = 1;
305 305
//                    url_fskip(pb, size - 5 * 4);
306 306
                    break;
307 307
                case CODEC_TYPE_AUDIO:
308
                    get_wav_header(pb, &st->codec, size);
308
                    get_wav_header(pb, st->codec, size);
309 309
                    if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
310 310
                        url_fskip(pb, 1);
311 311
                    /* special case time: To support Xan DPCM, hardcode
......
314 314
                    /* force parsing as several audio frames can be in
315 315
                       one packet */
316 316
                    if (xan_video)
317
                        st->codec.codec_id = CODEC_ID_XAN_DPCM;
317
                        st->codec->codec_id = CODEC_ID_XAN_DPCM;
318 318
                    break;
319 319
                default:
320
                    st->codec.codec_type = CODEC_TYPE_DATA;
321
                    st->codec.codec_id= CODEC_ID_NONE;
322
                    st->codec.codec_tag= 0;
320
                    st->codec->codec_type = CODEC_TYPE_DATA;
321
                    st->codec->codec_id= CODEC_ID_NONE;
322
                    st->codec->codec_tag= 0;
323 323
                    url_fskip(pb, size);
324 324
                    break;
325 325
                }
......
337 337
    if (stream_index != s->nb_streams - 1) {
338 338
    fail:
339 339
        for(i=0;i<s->nb_streams;i++) {
340
            av_freep(&s->streams[i]->codec.extradata);
340
            av_freep(&s->streams[i]->codec->extradata);
341 341
            av_freep(&s->streams[i]);
342 342
        }
343 343
        return -1;
......
440 440
//av_log(NULL, AV_LOG_DEBUG, "dts:%Ld offset:%d %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, n, size);
441 441
            pkt->stream_index = avi->stream_index;
442 442

  
443
            if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
443
            if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
444 444
                if(st->index_entries){
445 445
                    AVIndexEntry *e;
446 446
                    int index;
......
580 580
                g = get_byte(pb);
581 581
                b = get_byte(pb);
582 582
                    get_byte(pb);
583
                st->codec.palctrl->palette[k] = b + (g << 8) + (r << 16);
583
                st->codec->palctrl->palette[k] = b + (g << 8) + (r << 16);
584 584
            }
585
            st->codec.palctrl->palette_changed = 1;
585
            st->codec->palctrl->palette_changed = 1;
586 586
            goto resync;
587 587
        }
588 588

  
......
786 786
        AVStream *st = s->streams[i];
787 787
        AVIStream *ast = st->priv_data;
788 788
        av_free(ast);
789
        av_free(st->codec.extradata);
790
        av_free(st->codec.palctrl);
789
        av_free(st->codec->extradata);
790
        av_free(st->codec->palctrl);
791 791
    }
792 792

  
793 793
    if (avi->dv_demux)

Also available in: Unified diff