aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer2015-01-03 01:18:54 +0100
committerMichael Niedermayer2015-01-03 01:18:54 +0100
commit7ca10d10aae32fa42b6afc486328a7ec017bd457 (patch)
tree4166767dd61134388da12cf5cf7b5103a81711fb
parenta3ab87427c53aa7dfcc9f235848e555b9d99b06f (diff)
parent355d01a1bf55297b1d1f04e4bfbf0ddc93b6247e (diff)
Merge commit '355d01a1bf55297b1d1f04e4bfbf0ddc93b6247e'
* commit '355d01a1bf55297b1d1f04e4bfbf0ddc93b6247e': movenc: Factorize writing ftyp and other identification tags to a separate function Conflicts: libavformat/movenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/movenc.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index cd98f762b8..e9256f8ce4 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3722,6 +3722,33 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
avio_wb32(pb, 0x010001); /* ? */
}
+static int mov_write_identification(AVIOContext *pb, AVFormatContext *s)
+{
+ MOVMuxContext *mov = s->priv_data;
+ int i;
+
+ mov_write_ftyp_tag(pb,s);
+ if (mov->mode == MODE_PSP) {
+ int video_streams_nb = 0, audio_streams_nb = 0, other_streams_nb = 0;
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+ if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ video_streams_nb++;
+ else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ audio_streams_nb++;
+ else
+ other_streams_nb++;
+ }
+
+ if (video_streams_nb != 1 || audio_streams_nb != 1 || other_streams_nb) {
+ av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
+ return AVERROR(EINVAL);
+ }
+ mov_write_uuidprof_tag(pb, s);
+ }
+ return 0;
+}
+
static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
{
uint32_t c = -1;
@@ -4590,25 +4617,8 @@ static int mov_write_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
- mov_write_ftyp_tag(pb,s);
- if (mov->mode == MODE_PSP) {
- int video_streams_nb = 0, audio_streams_nb = 0, other_streams_nb = 0;
- for (i = 0; i < s->nb_streams; i++) {
- AVStream *st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
- video_streams_nb++;
- else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
- audio_streams_nb++;
- else
- other_streams_nb++;
- }
-
- if (video_streams_nb != 1 || audio_streams_nb != 1 || other_streams_nb) {
- av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
- return AVERROR(EINVAL);
- }
- mov_write_uuidprof_tag(pb, s);
- }
+ if ((ret = mov_write_identification(pb, s)) < 0)
+ return ret;
mov->nb_streams = s->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)