comparison movenc.c @ 422:2f30932cda1f libavformat

support for wider range of codecs
author alex
date Wed, 07 Apr 2004 12:47:33 +0000
parents 62e4ea840c52
children dc59cb26955c
comparison
equal deleted inserted replaced
421:a35263593560 422:2f30932cda1f
234 put_be32(pb, 0); /* null tag */ 234 put_be32(pb, 0); /* null tag */
235 235
236 return updateSize (pb, pos); 236 return updateSize (pb, pos);
237 } 237 }
238 238
239 const CodecTag codec_movaudio_tags[] = {
240 { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') },
241 { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') },
242 { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') },
243 { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') },
244 { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') },
245 { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') },
246 { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') },
247 { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') },
248 { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') },
249 { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') },
250 { 0, 0 },
251 };
252
239 static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track) 253 static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track)
240 { 254 {
241 int pos = url_ftell(pb); 255 int pos = url_ftell(pb), tag;
242 put_be32(pb, 0); /* size */ 256
243 257 put_be32(pb, 0); /* size */
244 if(track->enc->codec_id == CODEC_ID_PCM_MULAW) 258
245 put_tag(pb, "ulaw"); 259 tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id);
246 else if(track->enc->codec_id == CODEC_ID_PCM_ALAW) 260 // if no mac fcc found, try with Microsoft tags
247 put_tag(pb, "alaw"); 261 if (!tag)
248 else if(track->enc->codec_id == CODEC_ID_ADPCM_IMA_QT) 262 {
249 put_tag(pb, "ima4"); 263 int tmp = codec_get_tag(codec_wav_tags, track->enc->codec_id);
250 else if(track->enc->codec_id == CODEC_ID_MACE3) 264 if (tmp)
251 put_tag(pb, "MAC3"); 265 tag = MKTAG('m', 's', ((tmp >> 8) & 0xff), (tmp & 0xff));
252 else if(track->enc->codec_id == CODEC_ID_MACE6) 266 }
253 put_tag(pb, "MAC6"); 267 if (!tag)
254 else if(track->enc->codec_id == CODEC_ID_AAC) 268 put_tag(pb, " ");
255 put_tag(pb, "mp4a");
256 else if(track->enc->codec_id == CODEC_ID_AMR_NB)
257 put_tag(pb, "samr");
258 else if(track->enc->codec_id == CODEC_ID_PCM_S16BE)
259 put_tag(pb, "twos");
260 else if(track->enc->codec_id == CODEC_ID_PCM_S16LE)
261 put_tag(pb, "sowt");
262 else 269 else
263 put_tag(pb, " "); 270 put_le32(pb, tag); // store it byteswapped
264 271
265 put_be32(pb, 0); /* Reserved */ 272 put_be32(pb, 0); /* Reserved */
266 put_be16(pb, 0); /* Reserved */ 273 put_be16(pb, 0); /* Reserved */
267 put_be16(pb, 1); /* Data-reference index, XXX == 1 */ 274 put_be16(pb, 1); /* Data-reference index, XXX == 1 */
268 275
422 putDescr(pb, 0x06, 1); 429 putDescr(pb, 0x06, 1);
423 put_byte(pb, 0x02); 430 put_byte(pb, 0x02);
424 return updateSize (pb, pos); 431 return updateSize (pb, pos);
425 } 432 }
426 433
434 const CodecTag codec_movvideo_tags[] = {
435 { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') },
436 { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') },
437 { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
438 { CODEC_ID_H263, MKTAG('s', '2', '6', '3') },
439 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') },
440 { 0, 0 },
441 };
442
427 static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track) 443 static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track)
428 { 444 {
429 int pos = url_ftell(pb); 445 int pos = url_ftell(pb), tag;
430 put_be32(pb, 0); /* size */ 446
431 if(track->enc->codec_id == CODEC_ID_SVQ1) 447 put_be32(pb, 0); /* size */
432 put_tag(pb, "SVQ1"); 448
433 else if(track->enc->codec_id == CODEC_ID_SVQ3) 449 tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
434 put_tag(pb, "SVQ3"); 450 // if no mac fcc found, try with Microsoft tags
435 else if(track->enc->codec_id == CODEC_ID_MPEG4) 451 if (!tag)
436 put_tag(pb, "mp4v"); 452 tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id);
437 else if(track->enc->codec_id == CODEC_ID_H263) 453 if (!tag)
438 put_tag(pb, "s263"); 454 put_tag(pb, " ");
439 else if(track->enc->codec_id == CODEC_ID_DVVIDEO)
440 put_tag(pb, "dvc ");
441 else 455 else
442 put_tag(pb, " "); /* Unknown tag */ 456 put_le32(pb, tag); // store it byteswapped
443 457
444 put_be32(pb, 0); /* Reserved */ 458 put_be32(pb, 0); /* Reserved */
445 put_be16(pb, 0); /* Reserved */ 459 put_be16(pb, 0); /* Reserved */
446 put_be16(pb, 1); /* Data-reference index */ 460 put_be16(pb, 1); /* Data-reference index */
447 461