~ubuntu-branches/ubuntu/vivid/libav/vivid

« back to all changes in this revision

Viewing changes to libavformat/avienc.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:
105
105
    return tag;
106
106
}
107
107
 
108
 
static void avi_write_info_tag(AVIOContext *pb, const char *tag, const char *str)
109
 
{
110
 
    int len = strlen(str);
111
 
    if (len > 0) {
112
 
        len++;
113
 
        ffio_wfourcc(pb, tag);
114
 
        avio_wl32(pb, len);
115
 
        avio_put_str(pb, str);
116
 
        if (len & 1)
117
 
            avio_w8(pb, 0);
118
 
    }
119
 
}
120
 
 
121
108
static int avi_write_counters(AVFormatContext* s, int riff_id)
122
109
{
123
110
    AVIOContext *pb = s->pb;
234
221
        case AVMEDIA_TYPE_SUBTITLE:
235
222
            // XSUB subtitles behave like video tracks, other subtitles
236
223
            // are not (yet) supported.
237
 
            if (stream->codec_id != CODEC_ID_XSUB) {
 
224
            if (stream->codec_id != AV_CODEC_ID_XSUB) {
238
225
                av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
239
226
                return AVERROR_PATCHWELCOME;
240
227
            }
244
231
        case AVMEDIA_TYPE_DATA : ffio_wfourcc(pb, "dats"); break;
245
232
        }
246
233
        if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
247
 
           stream->codec_id == CODEC_ID_XSUB)
 
234
           stream->codec_id == AV_CODEC_ID_XSUB)
248
235
            avio_wl32(pb, stream->codec_tag);
249
236
        else
250
237
            avio_wl32(pb, 1);
286
273
        case AVMEDIA_TYPE_SUBTITLE:
287
274
            // XSUB subtitles behave like video tracks, other subtitles
288
275
            // are not (yet) supported.
289
 
            if (stream->codec_id != CODEC_ID_XSUB) break;
 
276
            if (stream->codec_id != AV_CODEC_ID_XSUB) break;
290
277
        case AVMEDIA_TYPE_VIDEO:
291
278
            ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0);
292
279
            break;
300
287
        }
301
288
        ff_end_tag(pb, strf);
302
289
        if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
303
 
            avi_write_info_tag(s->pb, "strn", t->value);
 
290
            ff_riff_write_info_tag(s->pb, "strn", t->value);
304
291
            t = NULL;
305
292
        }
306
293
      }
377
364
 
378
365
    ff_end_tag(pb, list1);
379
366
 
380
 
    list2 = ff_start_tag(pb, "LIST");
381
 
    ffio_wfourcc(pb, "INFO");
382
 
    ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL);
383
 
    for (i = 0; *ff_riff_tags[i]; i++) {
384
 
        if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE)))
385
 
            avi_write_info_tag(s->pb, t->key, t->value);
386
 
    }
387
 
    ff_end_tag(pb, list2);
 
367
    ff_riff_write_info(s);
388
368
 
389
369
    /* some padding for easier tag editing */
390
370
    list2 = ff_start_tag(pb, "JUNK");
520
500
    AVCodecContext *enc= s->streams[stream_index]->codec;
521
501
    int size= pkt->size;
522
502
 
523
 
//    av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %d\n", pkt->dts, avi->packet_count[stream_index], stream_index);
524
503
    while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count){
525
504
        AVPacket empty_packet;
526
505
 
529
508
        empty_packet.data= NULL;
530
509
        empty_packet.stream_index= stream_index;
531
510
        avi_write_packet(s, &empty_packet);
532
 
//        av_log(s, AV_LOG_DEBUG, "dup %"PRId64" %d\n", pkt->dts, avi->packet_count[stream_index]);
533
511
    }
534
512
    avist->packet_count++;
535
513
 
615
593
                    if (nb_frames < avist->packet_count)
616
594
                        nb_frames = avist->packet_count;
617
595
                } else {
618
 
                    if (stream->codec_id == CODEC_ID_MP2 || stream->codec_id == CODEC_ID_MP3) {
 
596
                    if (stream->codec_id == AV_CODEC_ID_MP2 || stream->codec_id == AV_CODEC_ID_MP3) {
619
597
                        nb_frames += avist->packet_count;
620
598
                    }
621
599
                }
626
604
            avi_write_counters(s, avi->riff_id);
627
605
        }
628
606
    }
629
 
    avio_flush(pb);
630
607
 
631
608
    for (i=0; i<s->nb_streams; i++) {
632
609
         AVIStream *avist= s->streams[i]->priv_data;
641
618
 
642
619
AVOutputFormat ff_avi_muxer = {
643
620
    .name              = "avi",
644
 
    .long_name         = NULL_IF_CONFIG_SMALL("AVI format"),
 
621
    .long_name         = NULL_IF_CONFIG_SMALL("AVI (Audio Video Interleaved)"),
645
622
    .mime_type         = "video/x-msvideo",
646
623
    .extensions        = "avi",
647
624
    .priv_data_size    = sizeof(AVIContext),
648
 
#if CONFIG_LIBMP3LAME_ENCODER
649
 
    .audio_codec       = CODEC_ID_MP3,
650
 
#else
651
 
    .audio_codec       = CODEC_ID_AC3,
652
 
#endif
653
 
    .video_codec       = CODEC_ID_MPEG4,
 
625
    .audio_codec       = CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_AC3,
 
626
    .video_codec       = AV_CODEC_ID_MPEG4,
654
627
    .write_header      = avi_write_header,
655
628
    .write_packet      = avi_write_packet,
656
629
    .write_trailer     = avi_write_trailer,
657
 
    .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
658
 
    .flags= AVFMT_VARIABLE_FPS,
 
630
    .codec_tag         = (const AVCodecTag* const []){
 
631
        ff_codec_bmp_tags, ff_codec_wav_tags, 0
 
632
    },
 
633
    .flags             = AVFMT_VARIABLE_FPS,
659
634
};