summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-07-07 16:35:32 -0300
committerJames Almer <jamrial@gmail.com>2018-07-20 12:00:32 -0300
commit9888a19db477cb8cc217321468c12a2ebe521d32 (patch)
treec7fc2529a2e7a8948388d92088a751b2ae257e8b /libavformat/movenc.c
parent9ca7ad246d536a78245b0d12dab4590004ec775d (diff)
avformat/movenc: add support for AV1 streams
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 54a248cf8e..d530f40cab 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -30,6 +30,7 @@
#include "riff.h"
#include "avio.h"
#include "isom.h"
+#include "av1.h"
#include "avc.h"
#include "libavcodec/ac3_parser_internal.h"
#include "libavcodec/dnxhddata.h"
@@ -1163,6 +1164,19 @@ static int mov_write_d263_tag(AVIOContext *pb)
return 0xf;
}
+static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track)
+{
+ int64_t pos = avio_tell(pb);
+
+ avio_wb32(pb, 0);
+ ffio_wfourcc(pb, "av1C");
+ avio_w8(pb, 0); /* version */
+ avio_wb24(pb, 0); /* flags */
+ avio_w8(pb, 0); /* reserved (3), initial_presentation_delay_present (1), initial_presentation_delay_minus_one/reserved (4) */
+ ff_isom_write_av1c(pb, track->vos_data, track->vos_len);
+ return update_size(pb, pos);
+}
+
static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
@@ -2009,6 +2023,8 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
mov_write_uuid_tag_ipod(pb);
} else if (track->par->codec_id == AV_CODEC_ID_VP9) {
mov_write_vpcc_tag(mov->fc, pb, track);
+ } else if (track->par->codec_id == AV_CODEC_ID_AV1) {
+ mov_write_av1c_tag(pb, track);
} else if (track->par->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
mov_write_dvc1_tag(pb, track);
else if (track->par->codec_id == AV_CODEC_ID_VP6F ||
@@ -5324,6 +5340,13 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
} else {
size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL);
}
+ } else if (par->codec_id == AV_CODEC_ID_AV1) {
+ if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
+ ff_av1_filter_obus_buf(pkt->data, &reformatted_data, &size);
+ avio_write(pb, reformatted_data, size);
+ } else {
+ size = ff_av1_filter_obus(pb, pkt->data, pkt->size);
+ }
#if CONFIG_AC3_PARSER
} else if (par->codec_id == AV_CODEC_ID_EAC3) {
size = handle_eac3(mov, pkt, trk);
@@ -5517,6 +5540,7 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
if (trk->par->codec_id == AV_CODEC_ID_MP4ALS ||
trk->par->codec_id == AV_CODEC_ID_AAC ||
+ trk->par->codec_id == AV_CODEC_ID_AV1 ||
trk->par->codec_id == AV_CODEC_ID_FLAC) {
int side_size = 0;
uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
@@ -6214,15 +6238,20 @@ static int mov_init(AVFormatContext *s)
pix_fmt == AV_PIX_FMT_MONOWHITE ||
pix_fmt == AV_PIX_FMT_MONOBLACK;
}
- if (track->par->codec_id == AV_CODEC_ID_VP9) {
+ if (track->par->codec_id == AV_CODEC_ID_VP9 ||
+ track->par->codec_id == AV_CODEC_ID_AV1) {
if (track->mode != MODE_MP4) {
- av_log(s, AV_LOG_ERROR, "VP9 only supported in MP4.\n");
+ av_log(s, AV_LOG_ERROR, "%s only supported in MP4.\n", avcodec_get_name(track->par->codec_id));
return AVERROR(EINVAL);
}
- } else if (track->par->codec_id == AV_CODEC_ID_AV1) {
- /* spec is not finished, so forbid for now */
- av_log(s, AV_LOG_ERROR, "AV1 muxing is currently not supported.\n");
- return AVERROR_PATCHWELCOME;
+ if (track->par->codec_id == AV_CODEC_ID_AV1 &&
+ s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+ av_log(s, AV_LOG_ERROR,
+ "av1 in MP4 support is experimental, add "
+ "'-strict %d' if you want to use it.\n",
+ FF_COMPLIANCE_EXPERIMENTAL);
+ return AVERROR_EXPERIMENTAL;
+ }
} else if (track->par->codec_id == AV_CODEC_ID_VP8) {
/* altref frames handling is not defined in the spec as of version v1.0,
* so just forbid muxing VP8 streams altogether until a new version does */
@@ -6737,6 +6766,7 @@ const AVCodecTag codec_mp4_tags[] = {
{ AV_CODEC_ID_DIRAC , MKTAG('d', 'r', 'a', 'c') },
{ AV_CODEC_ID_TSCC2 , MKTAG('m', 'p', '4', 'v') },
{ AV_CODEC_ID_VP9 , MKTAG('v', 'p', '0', '9') },
+ { AV_CODEC_ID_AV1 , MKTAG('a', 'v', '0', '1') },
{ AV_CODEC_ID_AAC , MKTAG('m', 'p', '4', 'a') },
{ AV_CODEC_ID_MP4ALS , MKTAG('m', 'p', '4', 'a') },
{ AV_CODEC_ID_MP3 , MKTAG('m', 'p', '4', 'a') },