aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-04-07 22:19:58 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-04-07 22:19:58 +0000
commit6b60028595bc362682ff882e656f12b6ca6f7a8c (patch)
treea074d71af9e91a4a7b56e5a3c161a5c88f2520cb /libavformat/movenc.c
parentf3370e14ea97810858ebecb58aa6ab86c4a0ca7c (diff)
downloadffmpeg-6b60028595bc362682ff882e656f12b6ca6f7a8c.tar.gz
split mov_find_codec_tag in separate per format functions
Originally committed as revision 18362 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c67
1 files changed, 56 insertions, 11 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index bb5fbe22b5..d7fdf43653 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -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(AVFormatContext *s, MOVTrack *track)
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(AVFormatContext *s, MOVTrack *track)
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(AVFormatContext *s, MOVTrack *track)
}
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(AVFormatContext *s, MOVTrack *track)
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