comparison mp3.c @ 2735:6fba7e16a6c7 libavformat

Add support for ID3v2 year tag Patch by: patrice bensoussan a free d fr
author andoma
date Wed, 14 Nov 2007 06:32:55 +0000
parents 2c2da3011d6e
children fbc1944cd095
comparison
equal deleted inserted replaced
2734:1b2658f20244 2735:6fba7e16a6c7
580 580
581 static int mp3_write_header(struct AVFormatContext *s) 581 static int mp3_write_header(struct AVFormatContext *s)
582 { 582 {
583 int totlen = 0; 583 int totlen = 0;
584 char tracktxt[10]; 584 char tracktxt[10];
585 char yeartxt[10];
585 586
586 if(s->track) 587 if(s->track)
587 snprintf(tracktxt, sizeof(tracktxt) - 1, "%d", s->track); 588 snprintf(tracktxt, sizeof(tracktxt) - 1, "%d", s->track);
589 if(s->year)
590 snprintf( yeartxt, sizeof(yeartxt) , "%d", s->year );
588 591
589 if(s->title[0]) totlen += 11 + strlen(s->title); 592 if(s->title[0]) totlen += 11 + strlen(s->title);
590 if(s->author[0]) totlen += 11 + strlen(s->author); 593 if(s->author[0]) totlen += 11 + strlen(s->author);
591 if(s->album[0]) totlen += 11 + strlen(s->album); 594 if(s->album[0]) totlen += 11 + strlen(s->album);
592 if(s->genre[0]) totlen += 11 + strlen(s->genre); 595 if(s->genre[0]) totlen += 11 + strlen(s->genre);
593 if(s->copyright[0]) totlen += 11 + strlen(s->copyright); 596 if(s->copyright[0]) totlen += 11 + strlen(s->copyright);
594 if(s->track) totlen += 11 + strlen(tracktxt); 597 if(s->track) totlen += 11 + strlen(tracktxt);
598 if(s->year) totlen += 11 + strlen(yeartxt);
595 if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) 599 if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
596 totlen += strlen(LIBAVFORMAT_IDENT) + 11; 600 totlen += strlen(LIBAVFORMAT_IDENT) + 11;
597 601
598 if(totlen == 0) 602 if(totlen == 0)
599 return 0; 603 return 0;
608 if(s->author[0]) id3v2_put_ttag(s, s->author, MKBETAG('T', 'P', 'E', '1')); 612 if(s->author[0]) id3v2_put_ttag(s, s->author, MKBETAG('T', 'P', 'E', '1'));
609 if(s->album[0]) id3v2_put_ttag(s, s->album, MKBETAG('T', 'A', 'L', 'B')); 613 if(s->album[0]) id3v2_put_ttag(s, s->album, MKBETAG('T', 'A', 'L', 'B'));
610 if(s->genre[0]) id3v2_put_ttag(s, s->genre, MKBETAG('T', 'C', 'O', 'N')); 614 if(s->genre[0]) id3v2_put_ttag(s, s->genre, MKBETAG('T', 'C', 'O', 'N'));
611 if(s->copyright[0]) id3v2_put_ttag(s, s->copyright, MKBETAG('T', 'C', 'O', 'P')); 615 if(s->copyright[0]) id3v2_put_ttag(s, s->copyright, MKBETAG('T', 'C', 'O', 'P'));
612 if(s->track) id3v2_put_ttag(s, tracktxt, MKBETAG('T', 'R', 'C', 'K')); 616 if(s->track) id3v2_put_ttag(s, tracktxt, MKBETAG('T', 'R', 'C', 'K'));
617 if(s->year) id3v2_put_ttag(s, yeartxt, MKBETAG('T', 'Y', 'E', 'R'));
613 if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) 618 if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
614 id3v2_put_ttag(s, LIBAVFORMAT_IDENT, MKBETAG('T', 'E', 'N', 'C')); 619 id3v2_put_ttag(s, LIBAVFORMAT_IDENT, MKBETAG('T', 'E', 'N', 'C'));
615 return 0; 620 return 0;
616 } 621 }
617 622