Hi guys,

Here is the depacketizer for SVQ3 that Ronald wrote some time ago. To
test, you'll need to disable audio until we get QDM2 merged -- thanks
Martin for the tip. (s1->skip_media = 1; return; in line 272 of
rtsp.c, and add "-an" to your ffmpeg/ffplay parameters).

I also updated the Changelog entry with a reference to RTSP-HTTP.

Josh
From 68668572962b2542458d268c76bac0e1a7611cf9 Mon Sep 17 00:00:00 2001
From: Josh Allmann <[email protected]>
Date: Wed, 30 Jun 2010 00:44:30 -0700
Subject: [PATCH] Add RTP depacketization of SVQ3.

---
 Changelog                 |    3 +-
 libavformat/Makefile      |    1 +
 libavformat/rtpdec.c      |    2 +
 libavformat/rtpdec_svq3.c |  145 +++++++++++++++++++++++++++++++++++++++++++++
 libavformat/rtpdec_svq3.h |   33 ++++++++++
 5 files changed, 183 insertions(+), 1 deletions(-)
 create mode 100644 libavformat/rtpdec_svq3.c
 create mode 100644 libavformat/rtpdec_svq3.h

diff --git a/Changelog b/Changelog
index bde39d3..5549287 100644
--- a/Changelog
+++ b/Changelog
@@ -15,7 +15,8 @@ version <next>:
 - libfaad2 wrapper removed
 - DTS-ES extension (XCh) decoding support
 - native VP8 decoder
-
+- RTSP tunneling over HTTP
+- RTP depacketization of SVQ3
 
 
 version 0.6:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2977673..5291fe3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -229,6 +229,7 @@ OBJS-$(CONFIG_SDP_DEMUXER)               += rtsp.o        \
                                             rtpdec_h263.o \
                                             rtpdec_h264.o \
                                             rtpdec_mpeg4.o \
+                                            rtpdec_svq3.o \
                                             rtpdec_xiph.o
 OBJS-$(CONFIG_SEGAFILM_DEMUXER)          += segafilm.o
 OBJS-$(CONFIG_SHORTEN_DEMUXER)           += raw.o id3v2.o
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 38a4c5b..ca06bff 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -35,6 +35,7 @@
 #include "rtpdec_h263.h"
 #include "rtpdec_h264.h"
 #include "rtpdec_mpeg4.h"
+#include "rtpdec_svq3.h"
 #include "rtpdec_xiph.h"
 
 //#define DEBUG
@@ -68,6 +69,7 @@ void av_register_rtp_dynamic_payload_handlers(void)
     ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
     ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);
     ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler);
+    ff_register_dynamic_payload_handler(&ff_svq3_dynamic_handler);
 
     ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfv_handler);
     ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfa_handler);
diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c
new file mode 100644
index 0000000..4a03a9c
--- /dev/null
+++ b/libavformat/rtpdec_svq3.c
@@ -0,0 +1,145 @@
+/*
+ * Sorenson-3 (SVQ3/SV3V) payload for RTP
+ * Copyright (c) 2010 Ronald S. Bultje
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file libavformat/rtpdec_svq3.c
+ * @brief RTP support for the SV3V (SVQ3) payload
+ * @author Ronald S. Bultje <[email protected]>
+ */
+
+#include <string.h>
+#include <libavcodec/get_bits.h>
+#include "rtp.h"
+#include "rtpdec.h"
+#include "rtpdec_svq3.h"
+
+struct PayloadContext {
+    ByteIOContext *pktbuf;
+    int64_t        timestamp;
+    int            is_keyframe;
+};
+
+/** return 0 on packet, <1 on partial packet or error... */
+static int sv3v_parse_packet (AVFormatContext *s, PayloadContext *sv,
+                              AVStream *st, AVPacket *pkt,
+                              uint32_t *timestamp,
+                              const uint8_t *buf, int len, int flags)
+{
+    int config_packet, start_packet, end_packet;
+
+    if (len < 2)
+        return AVERROR_INVALIDDATA;
+
+    config_packet = buf[0] & 0x40;
+    start_packet  = buf[0] & 0x20;
+    end_packet    = buf[0] & 0x10;
+    buf += 2;
+    len -= 2;
+
+    if (config_packet) {
+        GetBitContext gb;
+        int config;
+
+        if (len < 2 || !(st->codec->extradata = av_malloc(len + 8 + FF_INPUT_BUFFER_PADDING_SIZE)))
+            return AVERROR_INVALIDDATA;
+
+        /* frame size code */
+        init_get_bits(&gb, buf, len << 3);
+        config = get_bits(&gb, 3);
+        switch (config) {
+            case 0: st->codec->width = 160; st->codec->height = 128 /* FIXME: Wiki says 120? */; break;
+            case 1: st->codec->width = 128; st->codec->height =  96; break;
+            case 2: st->codec->width = 176; st->codec->height = 144; break;
+            case 3: st->codec->width = 352; st->codec->height = 288; break;
+            case 4: st->codec->width = 704; st->codec->height = 576; break;
+            case 5: st->codec->width = 240; st->codec->height = 180; break;
+            case 6: st->codec->width = 320; st->codec->height = 240; break;
+            case 7: /**< in case of '111', the next 2x12 bits carry optional width/height */
+                st->codec->width  = get_bits(&gb, 12);
+                st->codec->height = get_bits(&gb, 12);
+                break;
+        }
+        st->codec->extradata_size = len + 6;
+        memcpy(st->codec->extradata, "SEQH", 4);
+        AV_WB32(st->codec->extradata + 4, len);
+        memcpy(st->codec->extradata + 8, buf, len);
+
+        return AVERROR(EAGAIN);
+    }
+
+    if (start_packet) {
+        int res;
+
+        if (sv->pktbuf) {
+            uint8_t *tmp;
+            url_close_dyn_buf(sv->pktbuf, &tmp);
+            av_free(tmp);
+        }
+        if ((res = url_open_dyn_buf(&sv->pktbuf)) < 0)
+            return res;
+        sv->timestamp   = *timestamp;
+        sv->is_keyframe = flags & RTP_FLAG_KEY;
+    }
+
+    if (!sv->pktbuf)
+        return AVERROR_INVALIDDATA;
+
+    put_buffer(sv->pktbuf, buf, len);
+
+    if (end_packet) {
+        av_init_packet(pkt);
+        pkt->stream_index = st->index;
+        pkt->pts          = sv->timestamp;
+        pkt->flags        = sv->is_keyframe ? AV_PKT_FLAG_KEY : 0;
+        pkt->size         = url_close_dyn_buf(sv->pktbuf, &pkt->data);
+        sv->pktbuf        = NULL;
+        return 0;
+    }
+
+    return AVERROR(EAGAIN);
+}
+
+static PayloadContext *
+sv3v_extradata_new(void)
+{
+    return av_mallocz(sizeof(PayloadContext));
+}
+
+static void
+sv3v_extradata_free(PayloadContext *sv)
+{
+    if (sv->pktbuf) {
+        uint8_t *buf;
+        url_close_dyn_buf(sv->pktbuf, &buf);
+        av_free(buf);
+    }
+    av_free(sv);
+}
+
+RTPDynamicProtocolHandler ff_svq3_dynamic_handler = {
+    "X-SV3V-ES",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_SVQ3,
+    NULL,                   // parse sdp line
+    sv3v_extradata_new,
+    sv3v_extradata_free,
+    sv3v_parse_packet,
+};
diff --git a/libavformat/rtpdec_svq3.h b/libavformat/rtpdec_svq3.h
new file mode 100644
index 0000000..267d4d9
--- /dev/null
+++ b/libavformat/rtpdec_svq3.h
@@ -0,0 +1,33 @@
+/*
+ * Sorenson-3 (SVQ3/SV3V) payload for RTP
+ * Copyright (c) 2010 Ronald S. Bultje
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_RTPDEC_SVQ3_H
+#define AVFORMAT_RTPDEC_SVQ3_H
+
+#include "libavcodec/avcodec.h"
+#include "rtpdec.h"
+
+/**
+ * Sorenson-3 RTP callbacks.
+ */
+extern RTPDynamicProtocolHandler ff_svq3_dynamic_handler;
+
+#endif /* AVFORMAT_RTPDEC_SVQ3_H */
-- 
1.7.0.4

_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to