[FFmpeg-cvslog] r18362 - trunk/libavformat/movenc.c
bcoudurier
subversion
Wed Apr 8 00:19:58 CEST 2009
Author: bcoudurier
Date: Wed Apr 8 00:19:58 2009
New Revision: 18362
Log:
split mov_find_codec_tag in separate per format functions
Modified:
trunk/libavformat/movenc.c
Modified: trunk/libavformat/movenc.c
==============================================================================
--- trunk/libavformat/movenc.c Tue Apr 7 23:59:16 2009 (r18361)
+++ trunk/libavformat/movenc.c Wed Apr 8 00:19:58 2009 (r18362)
@@ -580,10 +580,9 @@ static const AVCodecTag codec_ipod_tags[
{ CODEC_ID_NONE, 0 },
};
-static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
+static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->enc->codec_tag;
- if (track->mode == MODE_MP4 || track->mode == MODE_PSP) {
if (!codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
return 0;
if (track->enc->codec_id == CODEC_ID_H264) tag = MKTAG('a','v','c','1');
@@ -592,7 +591,14 @@ static int mov_find_codec_tag(AVFormatCo
else if (track->enc->codec_id == CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
else if (track->enc->codec_type == CODEC_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
else if (track->enc->codec_type == CODEC_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
- } else if (track->mode == MODE_IPOD) {
+
+ return tag;
+}
+
+static int ipod_get_codec_tag(AVFormatContext *s, MOVTrack *track)
+{
+ int tag = track->enc->codec_tag;
+
if (track->enc->codec_type == CODEC_TYPE_SUBTITLE &&
(tag == MKTAG('t','x','3','g') ||
tag == MKTAG('t','e','x','t')))
@@ -602,20 +608,27 @@ static int mov_find_codec_tag(AVFormatCo
if (!match_ext(s->filename, "m4a") && !match_ext(s->filename, "m4v"))
av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
"Quicktime/Ipod might not play the file\n");
- } else if (track->mode & MODE_3GP) {
- tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id);
- } else if (!tag || (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
- (tag == MKTAG('d','v','c','p') ||
- track->enc->codec_id == CODEC_ID_RAWVIDEO ||
- av_get_bits_per_sample(track->enc->codec_id)))) { // pcm audio
- if (track->enc->codec_id == CODEC_ID_DVVIDEO) {
+
+ return tag;
+}
+
+static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
+{
+ int tag;
+
if (track->enc->height == 480) /* NTSC */
if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
else tag = MKTAG('d','v','c',' ');
else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
else tag = MKTAG('d','v','p','p');
- } else if (track->enc->codec_id == CODEC_ID_RAWVIDEO) {
+
+ return tag;
+}
+
+static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
+{
+ int tag = track->enc->codec_tag;
int i;
for (i = 0; i < FF_ARRAY_ELEMS(mov_pix_fmt_tags); i++) {
if (track->enc->pix_fmt == mov_pix_fmt_tags[i].pix_fmt) {
@@ -626,6 +639,22 @@ static int mov_find_codec_tag(AVFormatCo
}
if (!tag) // restore tag
tag = track->enc->codec_tag;
+
+ return tag;
+}
+
+static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
+{
+ int tag = track->enc->codec_tag;
+
+ if (!tag || (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
+ (tag == MKTAG('d','v','c','p') ||
+ track->enc->codec_id == CODEC_ID_RAWVIDEO ||
+ av_get_bits_per_sample(track->enc->codec_id)))) { // pcm audio
+ if (track->enc->codec_id == CODEC_ID_DVVIDEO) {
+ tag = mov_get_dv_codec_tag(s, track);
+ } else if (track->enc->codec_id == CODEC_ID_RAWVIDEO) {
+ tag = mov_get_rawvideo_codec_tag(s, track);
} else {
if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
@@ -653,6 +682,22 @@ static int mov_find_codec_tag(AVFormatCo
return tag;
}
+static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
+{
+ int tag = track->enc->codec_tag;
+
+ if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
+ tag = mp4_get_codec_tag(s, track);
+ else if (track->mode == MODE_IPOD)
+ tag = ipod_get_codec_tag(s, track);
+ else if (track->mode & MODE_3GP)
+ tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id);
+ else
+ tag = mov_get_codec_tag(s, track);
+
+ return tag;
+}
+
/** Write uuid atom.
* Needed to make file play in iPods running newest firmware
* goes after avcC atom in moov.trak.mdia.minf.stbl.stsd.avc1
More information about the ffmpeg-cvslog
mailing list