Revision 15d6e361 libavformat/avidec.c

View differences:

libavformat/avidec.c
1 1
/*
2 2
 * AVI demuxer
3
 * Copyright (c) 2001 Fabrice Bellard.
3
 * Copyright (c) 2001 Fabrice Bellard
4 4
 *
5 5
 * This file is part of FFmpeg.
6 6
 *
......
101 101
        return -1;
102 102

  
103 103
    if(header[7] == 0x19)
104
        av_log(NULL, AV_LOG_INFO, "file has been generated with a totally broken muxer\n");
104
        av_log(NULL, AV_LOG_INFO, "This file has been generated by a totally broken muxer.\n");
105 105

  
106 106
    return 0;
107 107
}
......
262 262

  
263 263
        switch(tag) {
264 264
        case MKTAG('L', 'I', 'S', 'T'):
265
            /* ignored, except when start of video packets */
265
            /* Ignored, except at start of video packets. */
266 266
            tag1 = get_le32(pb);
267 267
#ifdef DEBUG
268 268
            print_tag("list", tag1, 0);
......
284 284
        case MKTAG('a', 'm', 'v', 'h'):
285 285
            amv_file_format=1;
286 286
        case MKTAG('a', 'v', 'i', 'h'):
287
            /* avi header */
287
            /* AVI header */
288 288
            /* using frame_period is bad idea */
289 289
            frame_period = get_le32(pb);
290 290
            bit_rate = get_le32(pb) * 8;
......
330 330

  
331 331
                /*
332 332
                 * After some consideration -- I don't think we
333
                 * have to support anything but DV in a type1 AVIs.
333
                 * have to support anything but DV in type1 AVIs.
334 334
                 */
335 335
                if (s->nb_streams != 1)
336 336
                    goto fail;
......
362 362
                }
363 363
                /*
364 364
                 * else, leave duration alone; timing estimation in utils.c
365
                 *      will make a guess based on bit rate.
365
                 *      will make a guess based on bitrate.
366 366
                 */
367 367

  
368 368
                stream_index = s->nb_streams - 1;
......
380 380
            ast->scale = get_le32(pb);
381 381
            ast->rate = get_le32(pb);
382 382
            if(!(ast->scale && ast->rate)){
383
                av_log(s, AV_LOG_WARNING, "Scale/Rate is %u/%u which is invalid. (This file has been generated by broken software)\n", ast->scale, ast->rate);
383
                av_log(s, AV_LOG_WARNING, "scale/rate is %u/%u which is invalid. (This file has been generated by broken software.)\n", ast->scale, ast->rate);
384 384
                if(frame_period){
385 385
                    ast->rate = 1000000;
386 386
                    ast->scale = frame_period;
......
469 469
                    if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
470 470
                        get_byte(pb);
471 471

  
472
                    /* Extract palette from extradata if bpp <= 8 */
473
                    /* This code assumes that extradata contains only palette */
474
                    /* This is true for all paletted codecs implemented in ffmpeg */
472
                    /* Extract palette from extradata if bpp <= 8. */
473
                    /* This code assumes that extradata contains only palette. */
474
                    /* This is true for all paletted codecs implemented in FFmpeg. */
475 475
                    if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) {
476 476
                        st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
477 477
#ifdef WORDS_BIGENDIAN
......
490 490
                    st->codec->codec_type = CODEC_TYPE_VIDEO;
491 491
                    st->codec->codec_tag = tag1;
492 492
                    st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
493
                    st->need_parsing = AVSTREAM_PARSE_HEADERS; // this is needed to get the pict type which is needed for generating correct pts
493
                    st->need_parsing = AVSTREAM_PARSE_HEADERS; // This is needed to get the pict type which is necessary for generating correct pts.
494 494
//                    url_fskip(pb, size - 5 * 4);
495 495
                    break;
496 496
                case CODEC_TYPE_AUDIO:
......
502 502
                    if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
503 503
                        url_fskip(pb, 1);
504 504
                    /* Force parsing as several audio frames can be in
505
                     * one packet and timestamps refer to packet start*/
505
                     * one packet and timestamps refer to packet start. */
506 506
                    st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
507
                    /* ADTS header is in extradata, AAC without header must be stored as exact frames, parser not needed and it will fail */
507
                    /* ADTS header is in extradata, AAC without header must be
508
                     * stored as exact frames. Parser not needed and it will
509
                     * fail. */
508 510
                    if (st->codec->codec_id == CODEC_ID_AAC && st->codec->extradata_size)
509 511
                        st->need_parsing = AVSTREAM_PARSE_NONE;
510 512
                    /* AVI files with Xan DPCM audio (wrongly) declare PCM
......
581 583
            break;
582 584
        default:
583 585
            if(size > 1000000){
584
                av_log(s, AV_LOG_ERROR, "well something went wrong during header parsing, "
585
                                        "ill ignore it and try to continue anyway\n");
586
                av_log(s, AV_LOG_ERROR, "Something went wrong during header parsing, "
587
                                        "I will ignore it and try to continue anyway.\n");
586 588
                avi->movi_list = url_ftell(pb) - 4;
587 589
                avi->movi_end  = url_fsize(pb);
588 590
                goto end_of_header;
......
605 607
    avi->index_loaded = 1;
606 608
    avi->non_interleaved |= guess_ni_flag(s);
607 609
    if(avi->non_interleaved) {
608
        av_log(s, AV_LOG_INFO, "Non interleaved AVI\n");
610
        av_log(s, AV_LOG_INFO, "non-interleaved AVI\n");
609 611
        clean_index(s);
610 612
    }
611 613

  
......
707 709
            pkt->destruct = dstr;
708 710
            pkt->flags |= PKT_FLAG_KEY;
709 711
        } else {
710
            /* XXX: how to handle B frames in avi ? */
712
            /* XXX: How to handle B-frames in AVI? */
711 713
            pkt->dts = ast->frame_offset;
712 714
//                pkt->dts += ast->start;
713 715
            if(ast->sample_size)
......
778 780
            && d[1] >= '0' && d[1] <= '9'){
779 781
            n= (d[0] - '0') * 10 + (d[1] - '0');
780 782
        }else{
781
            n= 100; //invalid stream id
783
            n= 100; //invalid stream ID
782 784
        }
783 785

  
784 786
        //parse ##dc/##wb
......
802 804
                    n=1;
803 805
                    st = st1;
804 806
                    ast = ast1;
805
                    av_log(s, AV_LOG_WARNING, "Invalid stream+prefix combination, assuming audio\n");
807
                    av_log(s, AV_LOG_WARNING, "Invalid stream + prefix combination, assuming audio.\n");
806 808
                }
807 809
            }
808 810

  
......
857 859
    return -1;
858 860
}
859 861

  
860
/* XXX: we make the implicit supposition that the position are sorted
861
   for each stream */
862
/* XXX: We make the implicit supposition that the positions are sorted
863
   for each stream. */
862 864
static int avi_read_idx1(AVFormatContext *s, int size)
863 865
{
864 866
    AVIContext *avi = s->priv_data;
......
873 875
    if (nb_index_entries <= 0)
874 876
        return -1;
875 877

  
876
    /* read the entries and sort them in each stream component */
878
    /* Read the entries and sort them in each stream component. */
877 879
    for(i = 0; i < nb_index_entries; i++) {
878 880
        tag = get_le32(pb);
879 881
        flags = get_le32(pb);
......
1005 1007
        assert(stream_index == 0);
1006 1008

  
1007 1009
        /* Feed the DV video stream version of the timestamp to the */
1008
        /* DV demux so it can synth correct timestamps              */
1010
        /* DV demux so it can synthesize correct timestamps.        */
1009 1011
        dv_offset_reset(avi->dv_demux, timestamp);
1010 1012

  
1011 1013
        url_fseek(s->pb, pos, SEEK_SET);

Also available in: Unified diff