changeset 679:54d87ed9b3e4 libavformat

correct pcm in flv handling
author alex
date Mon, 21 Feb 2005 18:05:21 +0000
parents 9b2cda2905cc
children 0f77a8b8f348
files flvdec.c flvenc.c
diffstat 2 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flvdec.c	Mon Feb 21 17:50:48 2005 +0000
+++ b/flvdec.c	Mon Feb 21 18:05:21 2005 +0000
@@ -60,7 +60,7 @@
 static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     int ret, i, type, size, pts, flags, is_audio;
-    AVStream *st;
+    AVStream *st = NULL;
     
  for(;;){
     url_fskip(&s->pb, 4); /* size of previous packet */
@@ -122,7 +122,12 @@
             else
                 st->codec.sample_rate = (44100<<((flags>>2)&3))>>3;
             switch(flags >> 4){/* 0: uncompressed 1: ADPCM 2: mp3 5: Nellymoser 8kHz mono 6: Nellymoser*/
+	    case 0: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16BE;
+		    else st->codec.codec_id = CODEC_ID_PCM_S8; break;
             case 2: st->codec.codec_id = CODEC_ID_MP3; break;
+	    // this is not listed at FLV but at SWF, strange...
+	    case 3: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16LE;
+		    else st->codec.codec_id = CODEC_ID_PCM_S8; break;
             default:
                 st->codec.codec_tag= (flags >> 4);
             }
--- a/flvenc.c	Mon Feb 21 17:50:48 2005 +0000
+++ b/flvenc.c	Mon Feb 21 18:05:21 2005 +0000
@@ -35,7 +35,7 @@
 }
 
 static int get_audio_flags(AVCodecContext *enc){
-    int flags = 0x02;
+    int flags = 0;
 
     switch (enc->sample_rate) {
         case    44100:
@@ -61,8 +61,16 @@
     
     switch(enc->codec_id){
     case CODEC_ID_MP3:
-        flags |= 0x20;
+        flags |= 0x20 | 0x2;
         break;
+    case CODEC_ID_PCM_S8:
+	break;
+    case CODEC_ID_PCM_S16BE:
+	flags |= 0x60 | 0x2;
+	break;
+    case CODEC_ID_PCM_S16LE:
+	flags |= 0x2;
+	break;
     case 0:
         flags |= enc->codec_tag<<4;
         break;
@@ -155,8 +163,8 @@
     put_be32(pb,flv->reserved);
     put_byte(pb,flags);
     put_buffer(pb, pkt->data, size);
-    put_be32(pb,size+1+11); // reserved
-
+    put_be32(pb,size+1+11); // previous tag size
+    
     put_flush_packet(pb);
     return 0;
 }