summaryrefslogtreecommitdiff
path: root/libavformat/avc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-25 01:56:53 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-25 01:56:53 +0100
commit8bf95e8bd5c20eb940bd9583d3f947d8210eeb56 (patch)
tree43936a02f5da95392199e07b1ad38980e0ac2bc8 /libavformat/avc.c
parentf4c380a5e65c60422c6f62cab7bfe6155276d11d (diff)
parentd5ed5e7d0c1fa46de348db0de4c82b0f621db3d4 (diff)
downloadffmpeg-8bf95e8bd5c20eb940bd9583d3f947d8210eeb56.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: avc: Add a function for converting mp4 style extradata to annex b pthread: free progress if buffer allocation failed. lavc/avconv: support changing frame sizes in codecs with frame mt. libavformat: Document who sets the AVStream.id field utvideo: mark output picture as keyframe. sunrast: Add support for negative linesize. vp8: fix update_lf_deltas in libavcodec/vp8.c ralf: read Huffman code lengths without GetBitContext Conflicts: ffmpeg.c libavcodec/sunrastenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/avc.c')
-rw-r--r--libavformat/avc.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libavformat/avc.c b/libavformat/avc.c
index eff1ddb121..f5c513bb31 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -160,3 +160,34 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
}
return 0;
}
+
+int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size)
+{
+ uint16_t sps_size, pps_size;
+ uint8_t *out;
+ int out_size;
+
+ *buf = NULL;
+ if (*size >= 4 && (AV_RB32(in) == 0x00000001 || AV_RB24(in) == 0x000001))
+ return 0;
+ if (*size < 11 || in[0] != 1)
+ return AVERROR_INVALIDDATA;
+
+ sps_size = AV_RB16(&in[6]);
+ if (11 + sps_size > *size)
+ return AVERROR_INVALIDDATA;
+ pps_size = AV_RB16(&in[9 + sps_size]);
+ if (11 + sps_size + pps_size > *size)
+ return AVERROR_INVALIDDATA;
+ out_size = 8 + sps_size + pps_size;
+ out = av_mallocz(out_size);
+ if (!out)
+ return AVERROR(ENOMEM);
+ AV_WB32(&out[0], 0x00000001);
+ memcpy(out + 4, &in[8], sps_size);
+ AV_WB32(&out[4 + sps_size], 0x00000001);
+ memcpy(out + 8 + sps_size, &in[11 + sps_size], pps_size);
+ *buf = out;
+ *size = out_size;
+ return 0;
+}