Revision 5ce117c3 libavformat/swf.c

View differences:

libavformat/swf.c
19 19
 */
20 20
#include "avformat.h"
21 21
#include "bitstream.h"
22
#include "riff.h"    /* for CodecTag */
22 23

  
23 24
/* should have a generic way to indicate probable size */
24 25
#define DUMMY_FILE_SIZE   (100 * 1024 * 1024)
......
45 46
#define FLAG_SETFILL0    0x02
46 47
#define FLAG_SETFILL1    0x04
47 48

  
48
#define SWF_VIDEO_CODEC_FLV1    0x02
49

  
50 49
#define AUDIO_FIFO_SIZE 65536
51 50

  
52 51
/* character id used */
......
80 79
    int audio_type;
81 80
} SWFContext;
82 81

  
82
static const CodecTag swf_codec_tags[] = {
83
    {CODEC_ID_FLV1, 0x02},
84
    {CODEC_ID_VP6F, 0x04},
85
    {0, 0},
86
};
87

  
83 88
static const int sSampleRates[3][4] = {
84 89
    {44100, 48000, 32000, 0},
85 90
    {22050, 24000, 16000, 0},
......
328 333
        if (enc->codec_type == CODEC_TYPE_AUDIO)
329 334
            audio_enc = enc;
330 335
        else {
331
            if ( enc->codec_id == CODEC_ID_FLV1 || enc->codec_id == CODEC_ID_MJPEG ) {
336
            if ( enc->codec_id == CODEC_ID_VP6F ||
337
                 enc->codec_id == CODEC_ID_FLV1 ||
338
                 enc->codec_id == CODEC_ID_MJPEG ) {
332 339
                video_enc = enc;
333 340
            } else {
334
                av_log(enc, AV_LOG_ERROR, "SWF only supports FLV1 and MJPEG\n");
341
                av_log(enc, AV_LOG_ERROR, "SWF only supports VP6, FLV1 and MJPEG\n");
335 342
                return -1;
336 343
            }
337 344
        }
......
361 368
    }
362 369

  
363 370
    put_tag(pb, "FWS");
364
    if ( video_enc && video_enc->codec_id == CODEC_ID_FLV1 ) {
371
    if ( video_enc && video_enc->codec_id == CODEC_ID_VP6F ) {
372
        put_byte(pb, 8); /* version (version 8 and above support VP6 codec) */
373
    } else if ( video_enc && video_enc->codec_id == CODEC_ID_FLV1 ) {
365 374
        put_byte(pb, 6); /* version (version 6 and above support FLV1 codec) */
366 375
    } else {
367 376
        put_byte(pb, 4); /* version (should use 4 for mpeg audio support) */
......
375 384
    put_le16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
376 385

  
377 386
    /* define a shape with the jpeg inside */
378
    if ( video_enc && video_enc->codec_id == CODEC_ID_FLV1 ) {
387
    if ( video_enc && (video_enc->codec_id == CODEC_ID_VP6F ||
388
                       video_enc->codec_id == CODEC_ID_FLV1 )) {
379 389
    } else if ( video_enc && video_enc->codec_id == CODEC_ID_MJPEG ) {
380 390
        put_swf_tag(s, TAG_DEFINESHAPE);
381 391

  
......
512 522
        }
513 523
    }
514 524

  
515
            if ( swf->video_type == CODEC_ID_FLV1 ) {
525
            if ( swf->video_type == CODEC_ID_VP6F ||
526
                 swf->video_type == CODEC_ID_FLV1 ) {
516 527
                if ( swf->video_frame_number == 0 ) {
517 528
                    /* create a new video object */
518 529
                    put_swf_tag(s, TAG_VIDEOSTREAM);
......
521 532
                    put_le16(pb, enc->width);
522 533
                    put_le16(pb, enc->height);
523 534
                    put_byte(pb, 0);
524
                    put_byte(pb, SWF_VIDEO_CODEC_FLV1);
535
                    put_byte(pb,codec_get_tag(swf_codec_tags,swf->video_type));
525 536
                    put_swf_end_tag(s);
526 537

  
527 538
                    /* place the video object for the first time */
......
784 795
            return AVERROR_IO;
785 796
        }
786 797
        if ( tag == TAG_VIDEOSTREAM && !vst) {
798
            int codec_id;
787 799
            swf->ch_id = get_le16(pb);
788 800
            get_le16(pb);
789 801
            get_le16(pb);
790 802
            get_le16(pb);
791 803
            get_byte(pb);
792 804
            /* Check for FLV1 */
793
            if ( get_byte(pb) == SWF_VIDEO_CODEC_FLV1 ) {
805
            codec_id = codec_get_id(swf_codec_tags, get_byte(pb));
806
            if ( codec_id ) {
794 807
                vst = av_new_stream(s, 0);
795 808
                av_set_pts_info(vst, 24, 1, 1000); /* 24 bit pts in ms */
796 809

  
797 810
                vst->codec->codec_type = CODEC_TYPE_VIDEO;
798
                vst->codec->codec_id = CODEC_ID_FLV1;
811
                vst->codec->codec_id = codec_id;
799 812
                if ( swf->samples_per_frame ) {
800 813
                    vst->codec->time_base.den = 1000. / swf->ms_per_frame;
801 814
                    vst->codec->time_base.num = 1;

Also available in: Unified diff