comparison flvdec.c @ 5155:e562b793c959 libavformat

Remove fake Speex header creation from FLV demuxer. Having it there was not the correct solution to the problem. A better solution might be possible later once Speex is supported in muxers.
author jbr
date Fri, 04 Sep 2009 21:43:41 +0000
parents 44a0fab134a9
children 01514407ab35
comparison
equal deleted inserted replaced
5154:36b6bb08e0e2 5155:e562b793c959
43 return AVPROBE_SCORE_MAX; 43 return AVPROBE_SCORE_MAX;
44 } 44 }
45 return 0; 45 return 0;
46 } 46 }
47 47
48 /**
49 * Builds a Speex header.
50 * This is not needed for the libavcodec libspeex decoder, but is needed for
51 * stream copy and for decoders which require a header.
52 */
53 static void flv_build_speex_header(uint8_t *extradata)
54 {
55 memset(extradata, 0, 80);
56 bytestream_put_buffer(&extradata, "Speex ", 8); // speex_string
57 bytestream_put_buffer(&extradata, "1.2rc1", 6); // speex_version
58 extradata += 14; // speex_version padding
59 bytestream_put_le32(&extradata, 1); // speex_version_id
60 bytestream_put_le32(&extradata, 80); // header_size
61 bytestream_put_le32(&extradata, 16000); // rate
62 bytestream_put_le32(&extradata, 1); // mode
63 bytestream_put_le32(&extradata, 4); // mode_bitstream_version
64 bytestream_put_le32(&extradata, 1); // nb_channels
65 bytestream_put_le32(&extradata, -1); // bitrate
66 bytestream_put_le32(&extradata, 320); // frame_size
67 // vbr = 0
68 // frames_per_packet = 0
69 // extra_headers = 0
70 // reserved1 = 0
71 // reserved2 = 0
72 }
73
74 static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, int flv_codecid) { 48 static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, int flv_codecid) {
75 AVCodecContext *acodec = astream->codec; 49 AVCodecContext *acodec = astream->codec;
76 switch(flv_codecid) { 50 switch(flv_codecid) {
77 //no distinction between S16 and S8 PCM codec flags 51 //no distinction between S16 and S8 PCM codec flags
78 case FLV_CODECID_PCM: 52 case FLV_CODECID_PCM:
88 case FLV_CODECID_AAC : acodec->codec_id = CODEC_ID_AAC; break; 62 case FLV_CODECID_AAC : acodec->codec_id = CODEC_ID_AAC; break;
89 case FLV_CODECID_ADPCM: acodec->codec_id = CODEC_ID_ADPCM_SWF; break; 63 case FLV_CODECID_ADPCM: acodec->codec_id = CODEC_ID_ADPCM_SWF; break;
90 case FLV_CODECID_SPEEX: 64 case FLV_CODECID_SPEEX:
91 acodec->codec_id = CODEC_ID_SPEEX; 65 acodec->codec_id = CODEC_ID_SPEEX;
92 acodec->sample_rate = 16000; 66 acodec->sample_rate = 16000;
93 acodec->extradata = av_mallocz(80 + FF_INPUT_BUFFER_PADDING_SIZE);
94 if (acodec->extradata) {
95 acodec->extradata_size = 80;
96 flv_build_speex_header(acodec->extradata);
97 } else {
98 av_log(s, AV_LOG_WARNING, "Unable to create Speex extradata\n");
99 }
100 break; 67 break;
101 case FLV_CODECID_MP3 : acodec->codec_id = CODEC_ID_MP3 ; astream->need_parsing = AVSTREAM_PARSE_FULL; break; 68 case FLV_CODECID_MP3 : acodec->codec_id = CODEC_ID_MP3 ; astream->need_parsing = AVSTREAM_PARSE_FULL; break;
102 case FLV_CODECID_NELLYMOSER_8KHZ_MONO: 69 case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
103 acodec->sample_rate = 8000; //in case metadata does not otherwise declare samplerate 70 acodec->sample_rate = 8000; //in case metadata does not otherwise declare samplerate
104 case FLV_CODECID_NELLYMOSER: 71 case FLV_CODECID_NELLYMOSER: