summaryrefslogtreecommitdiff
path: root/libavformat/movenchint.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/movenchint.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/movenchint.c')
-rw-r--r--libavformat/movenchint.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 683d58b7c5..9f5e621a88 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -95,11 +95,12 @@ static void sample_queue_free(HintSampleQueue *queue)
* not copied. sample_queue_retain should be called before pkt->data
* is reused/freed.
*/
-static void sample_queue_push(HintSampleQueue *queue, AVPacket *pkt, int sample)
+static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
+ int sample)
{
/* No need to keep track of smaller samples, since describing them
* with immediates is more efficient. */
- if (pkt->size <= 14)
+ if (size <= 14)
return;
if (!queue->samples || queue->len >= queue->size) {
HintSample* samples;
@@ -109,8 +110,8 @@ static void sample_queue_push(HintSampleQueue *queue, AVPacket *pkt, int sample)
return;
queue->samples = samples;
}
- queue->samples[queue->len].data = pkt->data;
- queue->samples[queue->len].size = pkt->size;
+ queue->samples[queue->len].data = data;
+ queue->samples[queue->len].size = size;
queue->samples[queue->len].sample_number = sample;
queue->samples[queue->len].offset = 0;
queue->samples[queue->len].own_data = 0;
@@ -386,7 +387,8 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
}
int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,
- int track_index, int sample)
+ int track_index, int sample,
+ uint8_t *sample_data, int sample_size)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *trk = &mov->tracks[track_index];
@@ -402,7 +404,10 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,
if (!rtp_ctx->pb)
return AVERROR(ENOMEM);
- sample_queue_push(&trk->sample_queue, pkt, sample);
+ if (sample_data)
+ sample_queue_push(&trk->sample_queue, sample_data, sample_size, sample);
+ else
+ sample_queue_push(&trk->sample_queue, pkt->data, pkt->size, sample);
/* Feed the packet to the RTP muxer */
ff_write_chained(rtp_ctx, 0, pkt, s);