]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/flvenc.c
unused
[ffmpeg] / libavformat / flvenc.c
index 1bc0f9f63be6bd4826db3d01069ca7f89a482e31..d4ef51d5d36bdddcc0593ef0000a605214362a97 100644 (file)
@@ -69,7 +69,7 @@ static int get_audio_flags(AVCodecContext *enc){
             flags |= FLV_SAMPLERATE_SPECIAL;
             break;
         default:
-            av_log(enc, AV_LOG_ERROR, "flv doesnt support that sample rate, choose from (44100, 22050, 11025)\n");
+            av_log(enc, AV_LOG_ERROR, "flv does not support that sample rate, choose from (44100, 22050, 11025).\n");
             return -1;
     }
 
@@ -91,7 +91,7 @@ static int get_audio_flags(AVCodecContext *enc){
         flags |= FLV_CODECID_PCM_LE | FLV_SAMPLESSIZE_16BIT;
         break;
     case CODEC_ID_ADPCM_SWF:
-        flags |= FLV_CODECID_ADPCM;
+        flags |= FLV_CODECID_ADPCM | FLV_SAMPLESSIZE_16BIT;
         break;
     case 0:
         flags |= enc->codec_tag<<4;
@@ -145,7 +145,7 @@ static int flv_write_header(AVFormatContext *s)
             }
             flv->hasVideo=1;
 
-            videocodecid = codec_get_tag(flv_video_codec_ids, enc->codec_id);
+            videocodecid = enc->codec_tag;
             if(videocodecid == 0) {
                 av_log(enc, AV_LOG_ERROR, "video codec not compatible with flv\n");
                 return -1;
@@ -155,7 +155,7 @@ static int flv_write_header(AVFormatContext *s)
             samplerate = enc->sample_rate;
             channels = enc->channels;
 
-            audiocodecid = codec_get_tag(flv_audio_codec_ids, enc->codec_id);
+            audiocodecid = enc->codec_tag;
             samplesize = (enc->codec_id == CODEC_ID_PCM_S8) ? 8 : 16;
 
             if(get_audio_flags(enc)<0)
@@ -275,14 +275,19 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
     FLVContext *flv = s->priv_data;
     int size= pkt->size;
-    int flags;
+    int flags, flags_size;
 
 //    av_log(s, AV_LOG_DEBUG, "type:%d pts: %"PRId64" size:%d\n", enc->codec_type, timestamp, size);
 
+    if(enc->codec_id == CODEC_ID_VP6 || enc->codec_id == CODEC_ID_VP6F)
+        flags_size= 2;
+    else
+        flags_size= 1;
+
     if (enc->codec_type == CODEC_TYPE_VIDEO) {
         put_byte(pb, FLV_TAG_TYPE_VIDEO);
 
-        flags = codec_get_tag(flv_video_codec_ids, enc->codec_id);
+        flags = enc->codec_tag;
         if(flags == 0) {
             av_log(enc, AV_LOG_ERROR, "video codec %X not compatible with flv\n",enc->codec_id);
             return -1;
@@ -298,10 +303,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         put_byte(pb, FLV_TAG_TYPE_AUDIO);
     }
 
-    if ((enc->codec_id == CODEC_ID_VP6) || (enc->codec_id == CODEC_ID_VP6F))
-        put_be24(pb,size+2); // include the extra byte needed for VP6 in flv and flags
-    else
-        put_be24(pb,size+1); // include flags
+    put_be24(pb,size + flags_size);
     put_be24(pb,pkt->pts);
     put_be32(pb,flv->reserved);
     put_byte(pb,flags);
@@ -310,7 +312,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (enc->codec_id == CODEC_ID_VP6F)
         put_byte(pb, enc->extradata_size ? enc->extradata[0] : 0);
     put_buffer(pb, pkt->data, size);
-    put_be32(pb,size+1+11); // previous tag size
+    put_be32(pb,size+flags_size+11); // previous tag size
     flv->duration = pkt->pts + pkt->duration;
 
     put_flush_packet(pb);
@@ -332,5 +334,5 @@ AVOutputFormat flv_muxer = {
     flv_write_header,
     flv_write_packet,
     flv_write_trailer,
-    .codec_tag= {flv_video_codec_ids, flv_audio_codec_ids},
+    .codec_tag= (const AVCodecTag*[]){flv_video_codec_ids, flv_audio_codec_ids, 0},
 };