aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-03-02 16:52:26 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-03-08 19:36:26 +0000
commit0051174c70810b66378cf8ea093eab01302f6049 (patch)
treec6d8b2e48d32f1b3e9620e4a2e4f78abf57a00d2
parent61c966ef30129a0e4dba485242c039a895914d33 (diff)
downloadffmpeg-0051174c70810b66378cf8ea093eab01302f6049.tar.gz
rmenc: limit packet size
The chunk size is limited to UINT16_MAX (written by avio_wb16), so make sure that the packet size is not too large. Such large frames need to be split into slices smaller than 64 kB, but that is currently supported neither by the rv10/rv20 encoders nor the rm muxer. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r--libavformat/rmenc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index fba8feb802..3d9c866ace 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -44,6 +44,10 @@ typedef struct {
/* in ms */
#define BUFFER_DURATION 0
+/* the header needs at most 7 + 4 + 12 B */
+#define MAX_HEADER_SIZE (7 + 4 + 12)
+/* UINT16_MAX is the maximal chunk size */
+#define MAX_PACKET_SIZE (UINT16_MAX - MAX_HEADER_SIZE)
static void put_str(AVIOContext *s, const char *tag)
@@ -386,6 +390,10 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int
/* Well, I spent some time finding the meaning of these bits. I am
not sure I understood everything, but it works !! */
#if 1
+ if (size > MAX_PACKET_SIZE) {
+ avpriv_report_missing_feature(s, "Muxing packets larger than 64 kB");
+ return AVERROR(ENOSYS);
+ }
write_packet_header(s, stream, size + 7 + (size >= 0x4000)*4, key_frame);
/* bit 7: '1' if final packet of a frame converted in several packets */
avio_w8(pb, 0x81);