| @@ -5612,21 +5612,18 @@ static int mov_write_header(AVFormatContext *s) | |||||
| if (mov->encryption_key_len != AES_CTR_KEY_SIZE) { | if (mov->encryption_key_len != AES_CTR_KEY_SIZE) { | ||||
| av_log(s, AV_LOG_ERROR, "Invalid encryption key len %d expected %d\n", | av_log(s, AV_LOG_ERROR, "Invalid encryption key len %d expected %d\n", | ||||
| mov->encryption_key_len, AES_CTR_KEY_SIZE); | mov->encryption_key_len, AES_CTR_KEY_SIZE); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| if (mov->encryption_kid_len != CENC_KID_SIZE) { | if (mov->encryption_kid_len != CENC_KID_SIZE) { | ||||
| av_log(s, AV_LOG_ERROR, "Invalid encryption kid len %d expected %d\n", | av_log(s, AV_LOG_ERROR, "Invalid encryption kid len %d expected %d\n", | ||||
| mov->encryption_kid_len, CENC_KID_SIZE); | mov->encryption_kid_len, CENC_KID_SIZE); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| } else { | } else { | ||||
| av_log(s, AV_LOG_ERROR, "unsupported encryption scheme %s\n", | av_log(s, AV_LOG_ERROR, "unsupported encryption scheme %s\n", | ||||
| mov->encryption_scheme_str); | mov->encryption_scheme_str); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| } | } | ||||
| @@ -5646,8 +5643,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, " | av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, " | ||||
| "codec not currently supported in container\n", | "codec not currently supported in container\n", | ||||
| avcodec_get_name(st->codecpar->codec_id), i); | avcodec_get_name(st->codecpar->codec_id), i); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| /* If hinting of this track is enabled by a later hint track, | /* If hinting of this track is enabled by a later hint track, | ||||
| * this is updated. */ | * this is updated. */ | ||||
| @@ -5661,8 +5657,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { | track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { | ||||
| if (st->codecpar->width != 720 || (st->codecpar->height != 608 && st->codecpar->height != 512)) { | if (st->codecpar->width != 720 || (st->codecpar->height != 608 && st->codecpar->height != 512)) { | ||||
| av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); | av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| track->height = track->tag >> 24 == 'n' ? 486 : 576; | track->height = track->tag >> 24 == 'n' ? 486 : 576; | ||||
| } | } | ||||
| @@ -5675,8 +5670,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| } | } | ||||
| if (st->codecpar->width > 65535 || st->codecpar->height > 65535) { | if (st->codecpar->width > 65535 || st->codecpar->height > 65535) { | ||||
| av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codecpar->width, st->codecpar->height); | av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codecpar->width, st->codecpar->height); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| if (track->mode == MODE_MOV && track->timescale > 100000) | if (track->mode == MODE_MOV && track->timescale > 100000) | ||||
| av_log(s, AV_LOG_WARNING, | av_log(s, AV_LOG_WARNING, | ||||
| @@ -5704,8 +5698,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| "VP9 in MP4 support is experimental, add " | "VP9 in MP4 support is experimental, add " | ||||
| "'-strict %d' if you want to use it.\n", | "'-strict %d' if you want to use it.\n", | ||||
| FF_COMPLIANCE_EXPERIMENTAL); | FF_COMPLIANCE_EXPERIMENTAL); | ||||
| ret = AVERROR_EXPERIMENTAL; | |||||
| goto error; | |||||
| return AVERROR_EXPERIMENTAL; | |||||
| } | } | ||||
| } | } | ||||
| } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { | } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { | ||||
| @@ -5718,8 +5711,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| st->codecpar->codec_id == AV_CODEC_ID_ILBC){ | st->codecpar->codec_id == AV_CODEC_ID_ILBC){ | ||||
| if (!st->codecpar->block_align) { | if (!st->codecpar->block_align) { | ||||
| av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i); | av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| track->sample_size = st->codecpar->block_align; | track->sample_size = st->codecpar->block_align; | ||||
| }else if (st->codecpar->frame_size > 1){ /* assume compressed audio */ | }else if (st->codecpar->frame_size > 1){ /* assume compressed audio */ | ||||
| @@ -5736,8 +5728,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { | if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { | ||||
| av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n", | av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n", | ||||
| i, track->par->sample_rate); | i, track->par->sample_rate); | ||||
| ret = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } else { | } else { | ||||
| av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n", | av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n", | ||||
| i, track->par->sample_rate); | i, track->par->sample_rate); | ||||
| @@ -5767,8 +5758,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| track->vos_len = st->codecpar->extradata_size; | track->vos_len = st->codecpar->extradata_size; | ||||
| track->vos_data = av_malloc(track->vos_len); | track->vos_data = av_malloc(track->vos_len); | ||||
| if (!track->vos_data) { | if (!track->vos_data) { | ||||
| ret = AVERROR(ENOMEM); | |||||
| goto error; | |||||
| return AVERROR(ENOMEM); | |||||
| } | } | ||||
| memcpy(track->vos_data, st->codecpar->extradata, track->vos_len); | memcpy(track->vos_data, st->codecpar->extradata, track->vos_len); | ||||
| } | } | ||||
| @@ -5777,9 +5767,8 @@ static int mov_write_header(AVFormatContext *s) | |||||
| if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) { | if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) { | ||||
| ret = ff_mov_cenc_init(&track->cenc, mov->encryption_key, | ret = ff_mov_cenc_init(&track->cenc, mov->encryption_key, | ||||
| track->par->codec_id == AV_CODEC_ID_H264, s->flags & AVFMT_FLAG_BITEXACT); | track->par->codec_id == AV_CODEC_ID_H264, s->flags & AVFMT_FLAG_BITEXACT); | ||||
| if (ret) { | |||||
| goto error; | |||||
| } | |||||
| if (ret) | |||||
| return ret; | |||||
| } | } | ||||
| } | } | ||||
| @@ -5835,7 +5824,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| if (mov->chapter_track) | if (mov->chapter_track) | ||||
| if ((ret = mov_create_chapter_track(s, mov->chapter_track)) < 0) | if ((ret = mov_create_chapter_track(s, mov->chapter_track)) < 0) | ||||
| goto error; | |||||
| return ret; | |||||
| if (mov->flags & FF_MOV_FLAG_RTP_HINT) { | if (mov->flags & FF_MOV_FLAG_RTP_HINT) { | ||||
| /* Initialize the hint tracks for each audio and video stream */ | /* Initialize the hint tracks for each audio and video stream */ | ||||
| @@ -5844,7 +5833,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || | if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || | ||||
| st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { | st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { | ||||
| if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0) | if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0) | ||||
| goto error; | |||||
| return ret; | |||||
| hint_track++; | hint_track++; | ||||
| } | } | ||||
| } | } | ||||
| @@ -5865,7 +5854,7 @@ static int mov_write_header(AVFormatContext *s) | |||||
| if (mov_check_timecode_track(s, &tc, i, t->value) < 0) | if (mov_check_timecode_track(s, &tc, i, t->value) < 0) | ||||
| continue; | continue; | ||||
| if ((ret = mov_create_timecode_track(s, tmcd_track, i, tc)) < 0) | if ((ret = mov_create_timecode_track(s, tmcd_track, i, tc)) < 0) | ||||
| goto error; | |||||
| return ret; | |||||
| tmcd_track++; | tmcd_track++; | ||||
| } | } | ||||
| } | } | ||||
| @@ -5887,9 +5876,6 @@ static int mov_write_header(AVFormatContext *s) | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| error: | |||||
| mov_free(s); | |||||
| return ret; | |||||
| } | } | ||||
| static int get_moov_size(AVFormatContext *s) | static int get_moov_size(AVFormatContext *s) | ||||
| @@ -6044,10 +6030,8 @@ static int mov_write_trailer(AVFormatContext *s) | |||||
| track->vos_len = par->extradata_size; | track->vos_len = par->extradata_size; | ||||
| track->vos_data = av_malloc(track->vos_len); | track->vos_data = av_malloc(track->vos_len); | ||||
| if (!track->vos_data) { | |||||
| res = AVERROR(ENOMEM); | |||||
| goto error; | |||||
| } | |||||
| if (!track->vos_data) | |||||
| return AVERROR(ENOMEM); | |||||
| memcpy(track->vos_data, par->extradata, track->vos_len); | memcpy(track->vos_data, par->extradata, track->vos_len); | ||||
| } | } | ||||
| mov->need_rewrite_extradata = 0; | mov->need_rewrite_extradata = 0; | ||||
| @@ -6073,7 +6057,7 @@ static int mov_write_trailer(AVFormatContext *s) | |||||
| if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) { | if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) { | ||||
| mov->chapter_track = mov->nb_streams++; | mov->chapter_track = mov->nb_streams++; | ||||
| if ((res = mov_create_chapter_track(s, mov->chapter_track)) < 0) | if ((res = mov_create_chapter_track(s, mov->chapter_track)) < 0) | ||||
| goto error; | |||||
| return res; | |||||
| } | } | ||||
| } | } | ||||
| @@ -6099,19 +6083,18 @@ static int mov_write_trailer(AVFormatContext *s) | |||||
| av_log(s, AV_LOG_INFO, "Starting second pass: moving the moov atom to the beginning of the file\n"); | av_log(s, AV_LOG_INFO, "Starting second pass: moving the moov atom to the beginning of the file\n"); | ||||
| res = shift_data(s); | res = shift_data(s); | ||||
| if (res < 0) | if (res < 0) | ||||
| goto error; | |||||
| return res; | |||||
| avio_seek(pb, mov->reserved_header_pos, SEEK_SET); | avio_seek(pb, mov->reserved_header_pos, SEEK_SET); | ||||
| if ((res = mov_write_moov_tag(pb, mov, s)) < 0) | if ((res = mov_write_moov_tag(pb, mov, s)) < 0) | ||||
| goto error; | |||||
| return res; | |||||
| } else if (mov->reserved_moov_size > 0) { | } else if (mov->reserved_moov_size > 0) { | ||||
| int64_t size; | int64_t size; | ||||
| if ((res = mov_write_moov_tag(pb, mov, s)) < 0) | if ((res = mov_write_moov_tag(pb, mov, s)) < 0) | ||||
| goto error; | |||||
| return res; | |||||
| size = mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_header_pos); | size = mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_header_pos); | ||||
| if (size < 8){ | if (size < 8){ | ||||
| av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size); | av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size); | ||||
| res = AVERROR(EINVAL); | |||||
| goto error; | |||||
| return AVERROR(EINVAL); | |||||
| } | } | ||||
| avio_wb32(pb, size); | avio_wb32(pb, size); | ||||
| ffio_wfourcc(pb, "free"); | ffio_wfourcc(pb, "free"); | ||||
| @@ -6119,7 +6102,7 @@ static int mov_write_trailer(AVFormatContext *s) | |||||
| avio_seek(pb, moov_pos, SEEK_SET); | avio_seek(pb, moov_pos, SEEK_SET); | ||||
| } else { | } else { | ||||
| if ((res = mov_write_moov_tag(pb, mov, s)) < 0) | if ((res = mov_write_moov_tag(pb, mov, s)) < 0) | ||||
| goto error; | |||||
| return res; | |||||
| } | } | ||||
| res = 0; | res = 0; | ||||
| } else { | } else { | ||||
| @@ -6131,7 +6114,7 @@ static int mov_write_trailer(AVFormatContext *s) | |||||
| av_log(s, AV_LOG_INFO, "Starting second pass: inserting sidx atoms\n"); | av_log(s, AV_LOG_INFO, "Starting second pass: inserting sidx atoms\n"); | ||||
| res = shift_data(s); | res = shift_data(s); | ||||
| if (res < 0) | if (res < 0) | ||||
| goto error; | |||||
| return res; | |||||
| end = avio_tell(pb); | end = avio_tell(pb); | ||||
| avio_seek(pb, mov->reserved_header_pos, SEEK_SET); | avio_seek(pb, mov->reserved_header_pos, SEEK_SET); | ||||
| mov_write_sidx_tags(pb, mov, -1, 0); | mov_write_sidx_tags(pb, mov, -1, 0); | ||||
| @@ -6144,9 +6127,6 @@ static int mov_write_trailer(AVFormatContext *s) | |||||
| } | } | ||||
| } | } | ||||
| error: | |||||
| mov_free(s); | |||||
| return res; | return res; | ||||
| } | } | ||||
| @@ -6163,6 +6143,7 @@ AVOutputFormat ff_mov_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | ||||
| .codec_tag = (const AVCodecTag* const []){ | .codec_tag = (const AVCodecTag* const []){ | ||||
| ff_codec_movvideo_tags, ff_codec_movaudio_tags, 0 | ff_codec_movvideo_tags, ff_codec_movaudio_tags, 0 | ||||
| @@ -6182,6 +6163,7 @@ AVOutputFormat ff_tgp_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | ||||
| .codec_tag = (const AVCodecTag* const []){ codec_3gp_tags, 0 }, | .codec_tag = (const AVCodecTag* const []){ codec_3gp_tags, 0 }, | ||||
| .priv_class = &tgp_muxer_class, | .priv_class = &tgp_muxer_class, | ||||
| @@ -6201,6 +6183,7 @@ AVOutputFormat ff_mp4_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | ||||
| .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, | .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, | ||||
| .priv_class = &mp4_muxer_class, | .priv_class = &mp4_muxer_class, | ||||
| @@ -6219,6 +6202,7 @@ AVOutputFormat ff_psp_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | ||||
| .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, | .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, | ||||
| .priv_class = &psp_muxer_class, | .priv_class = &psp_muxer_class, | ||||
| @@ -6236,6 +6220,7 @@ AVOutputFormat ff_tg2_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | ||||
| .codec_tag = (const AVCodecTag* const []){ codec_3gp_tags, 0 }, | .codec_tag = (const AVCodecTag* const []){ codec_3gp_tags, 0 }, | ||||
| .priv_class = &tg2_muxer_class, | .priv_class = &tg2_muxer_class, | ||||
| @@ -6254,6 +6239,7 @@ AVOutputFormat ff_ipod_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | ||||
| .codec_tag = (const AVCodecTag* const []){ codec_ipod_tags, 0 }, | .codec_tag = (const AVCodecTag* const []){ codec_ipod_tags, 0 }, | ||||
| .priv_class = &ipod_muxer_class, | .priv_class = &ipod_muxer_class, | ||||
| @@ -6272,6 +6258,7 @@ AVOutputFormat ff_ismv_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, | ||||
| .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, | .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, | ||||
| .priv_class = &ismv_muxer_class, | .priv_class = &ismv_muxer_class, | ||||
| @@ -6290,6 +6277,7 @@ AVOutputFormat ff_f4v_muxer = { | |||||
| .write_header = mov_write_header, | .write_header = mov_write_header, | ||||
| .write_packet = mov_write_packet, | .write_packet = mov_write_packet, | ||||
| .write_trailer = mov_write_trailer, | .write_trailer = mov_write_trailer, | ||||
| .deinit = mov_free, | |||||
| .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, | .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, | ||||
| .codec_tag = (const AVCodecTag* const []){ codec_f4v_tags, 0 }, | .codec_tag = (const AVCodecTag* const []){ codec_f4v_tags, 0 }, | ||||
| .priv_class = &f4v_muxer_class, | .priv_class = &f4v_muxer_class, | ||||