summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-12-09 21:19:57 +0200
committerMartin Storsjö <martin@martin.st>2011-12-11 01:37:26 +0200
commite2484fb644b8dc0a0704e4155100c897e6e9739c (patch)
tree634f9ec4fb31787af02a6e63ba4104ef64abbe20 /libavformat/movenc.c
parentda9cea77e314dad2fbc615a76085a0c330741f92 (diff)
movenc: Use the actual converted sample for RTP hinting
If an annex b bitstream is muxed into mov, the actual written sample is reformatted to mp4 syntax before writing. Currently, the RTP hints that copy data from the normal video track, where the payload data might be offset compared to the original sample that the RTP hinting used (when 3 byte annex b startcodes have been converted into 4 byte mp4 format startcodes). Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 09932f83fb..b4f6aeebb4 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2002,6 +2002,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecContext *enc = trk->enc;
unsigned int samplesInChunk = 0;
int size= pkt->size;
+ uint8_t *reformatted_data = NULL;
if (!s->pb->seekable) return 0; /* Can't handle that */
if (!size) return 0; /* Discard 0 sized packets */
@@ -2035,7 +2036,13 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) {
/* from x264 or from bytestream h264 */
/* nal reformating needed */
- size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
+ if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
+ ff_avc_parse_nal_units_buf(pkt->data, &reformatted_data,
+ &size);
+ avio_write(pb, reformatted_data, size);
+ } else {
+ size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
+ }
} else {
avio_write(pb, pkt->data, size);
}
@@ -2090,7 +2097,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
avio_flush(pb);
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)
- ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry);
+ ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry,
+ reformatted_data, size);
+ av_free(reformatted_data);
return 0;
}