From 117d8c6d1f1c187ffc6098d9618457e00534e013 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 15 Sep 2012 00:59:05 +0200 Subject: matroska: implement support for ProRes Support Matroska native formatting. On demuxing prepend a Frame container atom (32bit big endian encoded frame size and 'icpf' string). On muxing remove it. --- libavformat/matroskadec.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'libavformat/matroskadec.c') diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 69a8c7f06e..c00ebaac8e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -37,6 +37,7 @@ #include "isom.h" #include "rm.h" #include "matroska.h" +#include "libavcodec/bytestream.h" #include "libavcodec/mpeg4audio.h" #include "libavutil/intfloat.h" #include "libavutil/intreadwrite.h" @@ -1966,6 +1967,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, MatroskaTrackEncoding *encodings = track->encodings.elem; uint32_t pkt_size = lace_size[n]; uint8_t *pkt_data = data; + int offset = 0; if (encodings && encodings->scope & 1) { res = matroska_decode_buffer(&pkt_data, &pkt_size, track); @@ -1973,15 +1975,24 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, break; } + if (st->codec->codec_id == AV_CODEC_ID_PRORES) + offset = 8; + pkt = av_mallocz(sizeof(AVPacket)); /* XXX: prevent data copy... */ - if (av_new_packet(pkt, pkt_size) < 0) { + if (av_new_packet(pkt, pkt_size + offset) < 0) { av_free(pkt); res = AVERROR(ENOMEM); break; } - memcpy(pkt->data, pkt_data, pkt_size); + if (st->codec->codec_id == AV_CODEC_ID_PRORES) { + uint8_t *buf = pkt->data; + bytestream_put_be32(&buf, pkt_size); + bytestream_put_be32(&buf, MKBETAG('i', 'c', 'p', 'f')); + } + + memcpy(pkt->data + offset, pkt_data, pkt_size); if (pkt_data != data) av_free(pkt_data); -- cgit v1.2.3