aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-11 23:56:02 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-11 23:57:11 +0200
commit9ca27df52fb4306a8e37c38d1ed9ab40c42a62dc (patch)
tree2da7168c9b3926d8a6886af3586fafeee41c5f4e
parent5f298c679107c3607f6f54c1f38eeb1ba36900a9 (diff)
parent183b1c2268529bbb8389d572deb00083c49682dc (diff)
downloadffmpeg-9ca27df52fb4306a8e37c38d1ed9ab40c42a62dc.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: configure: Check for the math function rint TechSmith Screen Codec 2 decoder rtsp: Add listen mode rtsp: Make rtsp_open_transport_ctx() non-static rtsp: Move rtsp_read_close rtsp: Parse the mode=receive/record parameter in transport lines Conflicts: Changelog libavcodec/avcodec.h libavcodec/version.h libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--Changelog2
-rwxr-xr-xconfigure2
-rw-r--r--doc/general.texi2
-rw-r--r--doc/protocols.texi8
-rw-r--r--libavcodec/Makefile1
-rw-r--r--libavcodec/allcodecs.c1
-rw-r--r--libavcodec/avcodec.h1
-rw-r--r--libavcodec/tscc2.c382
-rw-r--r--libavcodec/tscc2data.h935
-rw-r--r--libavcodec/version.h2
-rw-r--r--libavformat/riff.c1
-rw-r--r--libavformat/rtsp.c44
-rw-r--r--libavformat/rtsp.h20
-rw-r--r--libavformat/rtspcodes.h14
-rw-r--r--libavformat/rtspdec.c599
-rw-r--r--libavformat/version.h2
-rw-r--r--libavutil/libm.h7
17 files changed, 1967 insertions, 56 deletions
diff --git a/Changelog b/Changelog
index 5b86bbc417..7fd2f31073 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,8 @@ version next:
- join audio filter
- audio channel mapping filter
- Microsoft ATC Screen decoder
+- RTSP listen mode
+- TechSmith Screen Codec 2 decoder
- showwaves filter
- LucasArts SMUSH playback support
- SAMI demuxer and decoder
diff --git a/configure b/configure
index 84118365dc..c373640037 100755
--- a/configure
+++ b/configure
@@ -1256,6 +1256,7 @@ HAVE_LIST="
posix_memalign
pthread_cancel
rdtsc
+ rint
round
roundf
rweflags
@@ -3288,6 +3289,7 @@ check_mathfunc log2
check_mathfunc log2f
check_mathfunc lrint
check_mathfunc lrintf
+check_mathfunc rint
check_mathfunc round
check_mathfunc roundf
check_mathfunc trunc
diff --git a/doc/general.texi b/doc/general.texi
index d1925c097b..11907fdec4 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -642,6 +642,8 @@ following image formats are supported:
@tab fourcc: SP5X
@item TechSmith Screen Capture Codec @tab @tab X
@tab fourcc: TSCC
+@item TechSmith Screen Capture Codec 2 @tab @tab X
+ @tab fourcc: TSC2
@item Theora @tab E @tab X
@tab encoding supported through external library libtheora
@item Tiertex Limited SEQ video @tab @tab X
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 16caa84fe0..bed5f0759a 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -377,6 +377,8 @@ Flags for @code{rtsp_flags}:
@table @option
@item filter_src
Accept packets only from negotiated peer address and port.
+@item listen
+Act as a server, listening for an incoming connection.
@end table
When receiving data over UDP, the demuxer tries to reorder received packets
@@ -409,6 +411,12 @@ To send a stream in realtime to a RTSP server, for others to watch:
ffmpeg -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
@end example
+To receive a stream in realtime:
+
+@example
+avconv -rtsp_flags listen -i rtsp://ownaddress/live.sdp @var{output}
+@end example
+
@section sap
Session Announcement Protocol (RFC 2974). This is not technically a
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e695eafa06..91b7eaf591 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -451,6 +451,7 @@ OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o
OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o
OBJS-$(CONFIG_TRUESPEECH_DECODER) += truespeech.o
OBJS-$(CONFIG_TSCC_DECODER) += tscc.o msrledec.o
+OBJS-$(CONFIG_TSCC2_DECODER) += tscc2.o
OBJS-$(CONFIG_TTA_DECODER) += tta.o
OBJS-$(CONFIG_TWINVQ_DECODER) += twinvq.o celp_math.o
OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ef75b08f42..c718ffb566 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -222,6 +222,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (TRUEMOTION1, truemotion1);
REGISTER_DECODER (TRUEMOTION2, truemotion2);
REGISTER_DECODER (TSCC, tscc);
+ REGISTER_DECODER (TSCC2, tscc2);
REGISTER_DECODER (TXD, txd);
REGISTER_DECODER (ULTI, ulti);
REGISTER_DECODER (UTVIDEO, utvideo);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 80bd75e778..c9419ef59f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -259,6 +259,7 @@ enum CodecID {
CODEC_ID_ZEROCODEC,
CODEC_ID_MSS1,
CODEC_ID_MSA1,
+ CODEC_ID_TSCC2,
CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
CODEC_ID_EXR = MKBETAG('0','E','X','R'),
diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c
new file mode 100644
index 0000000000..5e36a0e307
--- /dev/null
+++ b/libavcodec/tscc2.c
@@ -0,0 +1,382 @@
+/*
+ * TechSmith Screen Codec 2 (aka Dora) decoder
+ * Copyright (c) 2012 Konstantin Shishkov
+ *
+ * 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
+ * TechSmith Screen Codec 2 decoder
+ */
+
+#define BITSTREAM_READER_LE
+#include "avcodec.h"
+#include "get_bits.h"
+#include "bytestream.h"
+#include "tscc2data.h"
+
+typedef struct TSCC2Context {
+ AVCodecContext *avctx;
+ AVFrame pic;
+ int mb_width, mb_height;
+ uint8_t *slice_quants;
+ int quant[2];
+ int q[2][3];
+ GetBitContext gb;
+
+ VLC dc_vlc, nc_vlc[NUM_VLC_SETS], ac_vlc[NUM_VLC_SETS];
+ int block[16];
+} TSCC2Context;
+
+static av_cold void free_vlcs(TSCC2Context *c)
+{
+ int i;
+
+ ff_free_vlc(&c->dc_vlc);
+ for (i = 0; i < NUM_VLC_SETS; i++) {
+ ff_free_vlc(c->nc_vlc + i);
+ ff_free_vlc(c->ac_vlc + i);
+ }
+}
+
+static av_cold int init_vlcs(TSCC2Context *c)
+{
+ int i, ret;
+
+ ret = ff_init_vlc_sparse(&c->dc_vlc, 9, DC_VLC_COUNT,
+ tscc2_dc_vlc_bits, 1, 1,
+ tscc2_dc_vlc_codes, 2, 2,
+ tscc2_dc_vlc_syms, 2, 2, INIT_VLC_LE);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < NUM_VLC_SETS; i++) {
+ ret = ff_init_vlc_sparse(c->nc_vlc + i, 9, 16,
+ tscc2_nc_vlc_bits[i], 1, 1,
+ tscc2_nc_vlc_codes[i], 2, 2,
+ tscc2_nc_vlc_syms, 1, 1, INIT_VLC_LE);
+ if (ret) {
+ free_vlcs(c);
+ return ret;
+ }
+ ret = ff_init_vlc_sparse(c->ac_vlc + i, 9, tscc2_ac_vlc_sizes[i],
+ tscc2_ac_vlc_bits[i], 1, 1,
+ tscc2_ac_vlc_codes[i], 2, 2,
+ tscc2_ac_vlc_syms[i], 2, 2, INIT_VLC_LE);
+ if (ret) {
+ free_vlcs(c);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+#define DEQUANT(val, q) ((q * val + 0x80) >> 8)
+#define DCT1D(d0, d1, d2, d3, s0, s1, s2, s3, OP) \
+ OP(d0, 5 * ((s0) + (s1) + (s2)) + 2 * (s3)); \
+ OP(d1, 5 * ((s0) - (s2) - (s3)) + 2 * (s1)); \
+ OP(d2, 5 * ((s0) - (s2) + (s3)) - 2 * (s3)); \
+ OP(d3, 5 * ((s0) - (s1) + (s2)) - 2 * (s3)); \
+
+#define COL_OP(a, b) a = b
+#define ROW_OP(a, b) a = av_clip_uint8((((b) + 0x20) >> 6) + 0x80)
+
+static void tscc2_idct4_put(int *in, int q[3], uint8_t *dst, int stride)
+{
+ int i;
+ int tblk[4 * 4];
+ int t0, t1, t2, t3;
+
+ for (i = 0; i < 4; i++) {
+ t0 = DEQUANT(q[0 + (i & 1)], in[0 * 4 + i]);
+ t1 = DEQUANT(q[1 + (i & 1)], in[1 * 4 + i]);
+ t2 = DEQUANT(q[0 + (i & 1)], in[2 * 4 + i]);
+ t3 = DEQUANT(q[1 + (i & 1)], in[3 * 4 + i]);
+ DCT1D(tblk[0 * 4 + i], tblk[1 * 4 + i],
+ tblk[2 * 4 + i], tblk[3 * 4 + i],
+ t0, t1, t2, t3, COL_OP);
+ }
+ for (i = 0; i < 4; i++) {
+ DCT1D(dst[0], dst[1], dst[2], dst[3],
+ tblk[i * 4 + 0], tblk[i * 4 + 1],
+ tblk[i * 4 + 2], tblk[i * 4 + 3], ROW_OP);
+ dst += stride;
+ }
+}
+
+static int tscc2_decode_mb(TSCC2Context *c, int *q, int vlc_set,
+ uint8_t *dst, int stride, int plane)
+{
+ GetBitContext *gb = &c->gb;
+ int prev_dc, dc, nc, ac, bpos, val;
+ int i, j, k, l;
+
+ if (get_bits1(gb)) {
+ if (get_bits1(gb)) {
+ val = get_bits(gb, 8);
+ for (i = 0; i < 8; i++, dst += stride)
+ memset(dst, val, 16);
+ } else {
+ if (get_bits_left(gb) < 16 * 8 * 8)
+ return AVERROR_INVALIDDATA;
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 16; j++)
+ dst[j] = get_bits(gb, 8);
+ dst += stride;
+ }
+ }
+ return 0;
+ }
+
+ prev_dc = 0;
+ for (j = 0; j < 2; j++) {
+ for (k = 0; k < 4; k++) {
+ if (!(j | k)) {
+ dc = get_bits(gb, 8);
+ } else {
+ dc = get_vlc2(gb, c->dc_vlc.table, 9, 2);
+ if (dc == -1)
+ return AVERROR_INVALIDDATA;
+ if (dc == 0x100)
+ dc = get_bits(gb, 8);
+ }
+ dc = (dc + prev_dc) & 0xFF;
+ prev_dc = dc;
+ c->block[0] = dc - 0x80;
+
+ nc = get_vlc2(gb, c->nc_vlc[vlc_set].table, 9, 1);
+ if (nc == -1)
+ return AVERROR_INVALIDDATA;
+
+ bpos = 1;
+ memset(c->block + 1, 0, 15 * sizeof(*c->block));
+ for (l = 0; l < nc; l++) {
+ ac = get_vlc2(gb, c->ac_vlc[vlc_set].table, 9, 2);
+ if (ac == -1)
+ return AVERROR_INVALIDDATA;
+ if (ac == 0x1000)
+ ac = get_bits(gb, 12);
+ bpos += ac & 0xF;
+ if (bpos >= 64)
+ return AVERROR_INVALIDDATA;
+ val = sign_extend(ac >> 4, 8);
+ c->block[tscc2_zigzag[bpos++]] = val;
+ }
+ tscc2_idct4_put(c->block, q, dst + k * 4, stride);
+ }
+ dst += 4 * stride;
+ }
+ return 0;
+}
+
+static int tscc2_decode_slice(TSCC2Context *c, int mb_y,
+ const uint8_t *buf, int buf_size)
+{
+ int i, mb_x, q, ret;
+ int off;
+
+ init_get_bits(&c->gb, buf, buf_size * 8);
+
+ for (mb_x = 0; mb_x < c->mb_width; mb_x++) {
+ q = c->slice_quants[mb_x + c->mb_width * mb_y];
+
+ if (q == 0 || q == 3) // skip block
+ continue;
+ for (i = 0; i < 3; i++) {
+ off = mb_x * 16 + mb_y * 8 * c->pic.linesize[i];
+ ret = tscc2_decode_mb(c, c->q[q - 1], c->quant[q - 1] - 2,
+ c->pic.data[i] + off, c->pic.linesize[i], i);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
+ int *data_size, AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ TSCC2Context *c = avctx->priv_data;
+ GetByteContext gb;
+ uint32_t frame_type, size;
+ int i, val, len, pos = 0;
+ int num_mb = c->mb_width * c->mb_height;
+ int ret;
+
+ bytestream2_init(&gb, buf, buf_size);
+ frame_type = bytestream2_get_byte(&gb);
+ if (frame_type > 1) {
+ av_log(avctx, AV_LOG_ERROR, "Incorrect frame type %d\n", frame_type);
+ return AVERROR_INVALIDDATA;
+ }
+
+ c->pic.reference = 3;
+ c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
+ FF_BUFFER_HINTS_REUSABLE;
+ if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
+ return ret;
+ }
+
+ if (frame_type == 0) {
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = c->pic;
+
+ return buf_size;
+ }
+
+ if (bytestream2_get_bytes_left(&gb) < 4) {
+ av_log(avctx, AV_LOG_ERROR, "Frame is too short\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ c->quant[0] = bytestream2_get_byte(&gb);
+ c->quant[1] = bytestream2_get_byte(&gb);
+ if (c->quant[0] < 2 || c->quant[0] > NUM_VLC_SETS + 1 ||
+ c->quant[1] < 2 || c->quant[1] > NUM_VLC_SETS + 1) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid quantisers %d / %d\n",
+ c->quant[0], c->quant[1]);
+ return AVERROR_INVALIDDATA;
+ }
+
+ for (i = 0; i < 3; i++) {
+ c->q[0][i] = tscc2_quants[c->quant[0] - 2][i];
+ c->q[1][i] = tscc2_quants[c->quant[1] - 2][i];
+ }
+
+ bytestream2_skip(&gb, 1);
+
+ size = bytestream2_get_le32(&gb);
+ if (size > bytestream2_get_bytes_left(&gb)) {
+ av_log(avctx, AV_LOG_ERROR, "Slice properties chunk is too large\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ for (i = 0; i < size; i++) {
+ val = bytestream2_get_byte(&gb);
+ len = val & 0x3F;
+ val >>= 6;
+ if (pos + len > num_mb) {
+ av_log(avctx, AV_LOG_ERROR, "Too many slice properties\n");
+ return AVERROR_INVALIDDATA;
+ }
+ memset(c->slice_quants + pos, val, len);
+ pos += len;
+ }
+ if (pos < num_mb) {
+ av_log(avctx, AV_LOG_ERROR, "Too few slice properties (%d / %d)\n",
+ pos, num_mb);
+ return AVERROR_INVALIDDATA;
+ }
+
+ for (i = 0; i < c->mb_height; i++) {
+ size = bytestream2_peek_byte(&gb);
+ if (size & 1) {
+ size = bytestream2_get_byte(&gb) - 1;
+ } else {
+ size = bytestream2_get_le32(&gb) >> 1;
+ }
+ if (!size) {
+ int skip_row = 1, j, off = i * c->mb_width;
+ for (j = 0; j < c->mb_width; j++) {
+ if (c->slice_quants[off + i] == 1 ||
+ c->slice_quants[off + i] == 2) {
+ skip_row = 0;
+ break;
+ }
+ }
+ if (!skip_row) {
+ av_log(avctx, AV_LOG_ERROR, "Non-skip row with zero size\n");
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ if (bytestream2_get_bytes_left(&gb) < size) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid slice size (%d/%d)\n",
+ size, bytestream2_get_bytes_left(&gb));
+ return AVERROR_INVALIDDATA;
+ }
+ ret = tscc2_decode_slice(c, i, buf + bytestream2_tell(&gb), size);
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Error decoding slice %d\n", i);
+ return ret;
+ }
+ bytestream2_skip(&gb, size);
+ }
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = c->pic;
+
+ /* always report that the buffer was completely consumed */
+ return buf_size;
+}
+
+static av_cold int tscc2_decode_init(AVCodecContext *avctx)
+{
+ TSCC2Context * const c = avctx->priv_data;
+ int ret;
+
+ c->avctx = avctx;
+
+ avctx->pix_fmt = PIX_FMT_YUV444P;
+
+ if ((ret = init_vlcs(c)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot initialise VLCs\n");
+ return ret;
+ }
+
+ c->mb_width = FFALIGN(avctx->width, 16) >> 4;
+ c->mb_height = FFALIGN(avctx->height, 8) >> 3;
+ c->slice_quants = av_malloc(c->mb_width * c->mb_height);
+ if (!c->slice_quants) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot allocate slice information\n");
+ free_vlcs(c);
+ return AVERROR(ENOMEM);
+ }
+
+ avctx->coded_frame = &c->pic;
+
+ return 0;
+}
+
+static av_cold int tscc2_decode_end(AVCodecContext *avctx)
+{
+ TSCC2Context * const c = avctx->priv_data;
+
+ if (c->pic.data[0])
+ avctx->release_buffer(avctx, &c->pic);
+ av_freep(&c->slice_quants);
+ free_vlcs(c);
+
+ return 0;
+}
+
+AVCodec ff_tscc2_decoder = {
+ .name = "tscc2",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_TSCC2,
+ .priv_data_size = sizeof(TSCC2Context),
+ .init = tscc2_decode_init,
+ .close = tscc2_decode_end,
+ .decode = tscc2_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Codec 2"),
+};
diff --git a/libavcodec/tscc2data.h b/libavcodec/tscc2data.h
new file mode 100644
index 0000000000..4586da77a5
--- /dev/null
+++ b/libavcodec/tscc2data.h
@@ -0,0 +1,935 @@
+/*
+ * TechSmith Screen Codec 2 (aka Dora) decoder
+ * Copyright (c) 2012 Konstantin Shishkov
+ *
+ * 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 AVCODEC_TSCC2_DATA_H
+#define AVCODEC_TSCC2_DATA_H
+
+#include <stdint.h>
+
+static const uint8_t tscc2_zigzag[16] = {
+ 0, 1, 4, 8,
+ 5, 2, 3, 6,
+ 9, 12, 13, 10,
+ 7, 11, 14, 15
+};
+
+#define NUM_VLC_SETS 13
+
+static const uint16_t tscc2_quants[NUM_VLC_SETS][3] = {
+ { 655, 861, 1130 }, { 983, 1291, 1695 }, { 1311, 1721, 2260 },
+ { 1638, 2151, 2825 }, { 1966, 2582, 3390 }, { 2294, 3012, 3955 },
+ { 2621, 3442, 4520 }, { 2949, 3872, 5085 }, { 3277, 4303, 5650 },
+ { 3604, 4733, 6215 }, { 3932, 5163, 6780 }, { 4260, 5593, 7345 },
+ { 4588, 6024, 7910 },
+};
+
+#define DC_VLC_COUNT 47
+
+static const uint16_t tscc2_dc_vlc_syms[DC_VLC_COUNT] = {
+ 0x100, 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9,
+ 0xF8, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1,
+ 0xF0, 0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0x17,
+ 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0F,
+ 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07,
+ 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
+};
+
+static const uint16_t tscc2_dc_vlc_codes[DC_VLC_COUNT] = {
+ 0x000A, 0x0000, 0x0006, 0x002E, 0x0002, 0x000E, 0x001A, 0x007E,
+ 0x004E, 0x005A, 0x00E2, 0x01BE, 0x01BA, 0x00BA, 0x0072, 0x0022,
+ 0x02BE, 0x00BE, 0x033A, 0x03F2, 0x01F2, 0x03A2, 0x0122, 0x0322,
+ 0x01A2, 0x0172, 0x0372, 0x013A, 0x00CE, 0x02CE, 0x02FE, 0x00FE,
+ 0x00A2, 0x00F2, 0x003A, 0x01CE, 0x01FE, 0x0062, 0x00DA, 0x003E,
+ 0x0032, 0x007A, 0x0012, 0x001E, 0x0016, 0x0004, 0x0001,
+};
+
+static const uint8_t tscc2_dc_vlc_bits[DC_VLC_COUNT] = {
+ 5, 3, 5, 6, 6, 7, 7, 8,
+ 8, 8, 8, 9, 9, 9, 9, 9,
+ 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10,
+ 9, 9, 9, 9, 9, 8, 8, 8,
+ 7, 7, 6, 6, 5, 3, 1,
+};
+
+static const uint8_t tscc2_nc_vlc_syms[16] = {
+ 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08,
+ 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
+};
+
+static const uint16_t tscc2_nc_vlc_codes[NUM_VLC_SETS][16] = {
+ { 0x0023, 0x0003, 0x0031, 0x0021, 0x0011, 0x0053, 0x0013, 0x0001,
+ 0x0009, 0x0029, 0x0033, 0x0019, 0x000B, 0x0005, 0x0007, 0x0000, },
+ { 0x0030, 0x0022, 0x0028, 0x0020, 0x0008, 0x0000, 0x0032, 0x0072,
+ 0x0010, 0x0002, 0x0012, 0x0018, 0x000A, 0x0004, 0x0006, 0x0001, },
+ { 0x0032, 0x0038, 0x0020, 0x0008, 0x0002, 0x0018, 0x0072, 0x0000,
+ 0x0028, 0x0022, 0x0012, 0x0010, 0x000A, 0x0004, 0x0006, 0x0001, },
+ { 0x0032, 0x0010, 0x0072, 0x0030, 0x0022, 0x0038, 0x0008, 0x0028,
+ 0x0018, 0x0002, 0x0012, 0x0000, 0x000A, 0x0004, 0x0006, 0x0001, },
+ { 0x0012, 0x0052, 0x0000, 0x0020, 0x0018, 0x0022, 0x0008, 0x0028,
+ 0x0038, 0x0002, 0x0032, 0x0010, 0x000A, 0x0004, 0x0006, 0x0001, },
+ { 0x0016, 0x0096, 0x0006, 0x0046, 0x0056, 0x0002, 0x0036, 0x0076,
+ 0x0012, 0x0022, 0x0032, 0x0026, 0x000A, 0x000E, 0x0000, 0x0001, },
+ { 0x001A, 0x009A, 0x0032, 0x0072, 0x005A, 0x007A, 0x003A, 0x0002,
+ 0x0012, 0x0022, 0x000A, 0x002A, 0x0006, 0x000E, 0x0000, 0x0001, },
+ { 0x002A, 0x00AA, 0x0002, 0x0042, 0x006A, 0x003A, 0x007A, 0x0022,
+ 0x0032, 0x0012, 0x000A, 0x001A, 0x0006, 0x000E, 0x0000, 0x0001, },
+ { 0x0042, 0x00C2, 0x0002, 0x000A, 0x004A, 0x003A, 0x007A, 0x0022,
+ 0x0012, 0x0032, 0x002A, 0x001A, 0x0006, 0x000E, 0x0000, 0x0001, },
+ { 0x00BA, 0x01BA, 0x003A, 0x0012, 0x0052, 0x007A, 0x0002, 0x0022,
+ 0x0032, 0x000A, 0x002A, 0x001A, 0x0000, 0x0004, 0x0006, 0x0001, },
+ { 0x00AA, 0x01AA, 0x002A, 0x0022, 0x0062, 0x006A, 0x0002, 0x0012,
+ 0x0032, 0x000A, 0x001A, 0x003A, 0x0000, 0x0004, 0x0006, 0x0001, },
+ { 0x00AA, 0x01AA, 0x002A, 0x0022, 0x0062, 0x006A, 0x0002, 0x0012,
+ 0x0032, 0x000A, 0x003A, 0x001A, 0x0000, 0x0004, 0x0006, 0x0001, },
+ { 0x008A, 0x018A, 0x000A, 0x0022, 0x0062, 0x004A, 0x0002, 0x0012,
+ 0x0032, 0x002A, 0x001A, 0x003A, 0x0000, 0x0004, 0x0006, 0x0001, },
+};
+
+static const uint8_t tscc2_nc_vlc_bits[NUM_VLC_SETS][16] = {
+ { 6, 6, 6, 6, 6, 7, 7, 6, 6, 6, 6, 5, 4, 3, 3, 1 },
+ { 6, 6, 6, 6, 6, 6, 7, 7, 6, 6, 6, 5, 4, 3, 3, 1 },
+ { 7, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 5, 4, 3, 3, 1 },
+ { 7, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 3, 1 },
+ { 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 3, 1 },
+ { 8, 8, 7, 7, 7, 6, 7, 7, 6, 6, 6, 6, 4, 4, 2, 1 },
+ { 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 4, 4, 2, 1 },
+ { 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 4, 4, 2, 1 },
+ { 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 4, 4, 2, 1 },
+ { 9, 9, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 3, 3, 3, 1 },
+ { 9, 9, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 3, 3, 3, 1 },
+ { 9, 9, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 3, 3, 3, 1 },
+ { 9, 9, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 3, 3, 3, 1 },
+};
+
+static const uint16_t ac_vlc_desc0_syms[172] = {
+ 0x1000, 0xFF8, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2, 0xFF1,
+ 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1, 0xFE0,
+ 0xFD6, 0xFD5, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC6, 0xFC5,
+ 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB5, 0xFB3, 0xFB2, 0xFB1,
+ 0xFB0, 0xFA5, 0xFA3, 0xFA1, 0xFA0, 0xF95, 0xF91, 0xF90,
+ 0xF83, 0xF81, 0xF80, 0xF73, 0xF71, 0xF70, 0xF61, 0xF60,
+ 0xF51, 0xF50, 0xF45, 0xF41, 0xF40, 0xF31, 0xF30, 0xF21,
+ 0xF20, 0xF10, 0xF00, 0xEF0, 0xEE0, 0xED5, 0xED1, 0xED0,
+ 0xEC0, 0xEB0, 0xEA0, 0xE90, 0xE80, 0xE70, 0xE60, 0xE50,
+ 0xE40, 0xE30, 0xE20, 0xE10, 0xE00, 0xDF0, 0xDE0, 0xDD0,
+ 0xDC0, 0xDB0, 0xDA0, 0xD90, 0xD80, 0xD60, 0xCD1, 0x280,
+ 0x270, 0x260, 0x250, 0x240, 0x230, 0x220, 0x210, 0x200,
+ 0x1F0, 0x1E0, 0x1D0, 0x1C0, 0x1B0, 0x1A1, 0x1A0, 0x190,
+ 0x180, 0x170, 0x160, 0x150, 0x140, 0x130, 0x121, 0x120,
+ 0x111, 0x110, 0x101, 0x100, 0x0F1, 0x0F0, 0x0E1, 0x0E0,
+ 0x0D1, 0x0D0, 0x0C1, 0x0C0, 0x0B1, 0x0B0, 0x0A5, 0x0A1,
+ 0x0A0, 0x091, 0x090, 0x081, 0x080, 0x075, 0x071, 0x070,
+ 0x065, 0x063, 0x061, 0x060, 0x055, 0x053, 0x052, 0x051,
+ 0x050, 0x046, 0x045, 0x043, 0x042, 0x041, 0x040, 0x036,
+ 0x035, 0x033, 0x032, 0x031, 0x030, 0x026, 0x025, 0x024,
+ 0x023, 0x022, 0x021, 0x020, 0x018, 0x016, 0x015, 0x014,
+ 0x013, 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc0_codes[172] = {
+ 0x001F, 0x0D71, 0x013F, 0x006C, 0x00A7, 0x0067, 0x001C, 0x0008,
+ 0x0005, 0x06F1, 0x002C, 0x04BA, 0x0072, 0x01AA, 0x0002, 0x0006,
+ 0x06AC, 0x02AF, 0x06EF, 0x018F, 0x000A, 0x0009, 0x02AC, 0x042A,
+ 0x06E1, 0x068F, 0x00B1, 0x0000, 0x0317, 0x0C17, 0x0612, 0x010F,
+ 0x0011, 0x0FBA, 0x002A, 0x0172, 0x000C, 0x05AC, 0x03D7, 0x0037,
+ 0x0E8F, 0x02F2, 0x0041, 0x0BE1, 0x057F, 0x004A, 0x00AF, 0x006F,
+ 0x06AA, 0x0097, 0x0101, 0x0012, 0x0081, 0x0571, 0x0092, 0x0EAF,
+ 0x01BF, 0x00D7, 0x0031, 0x0001, 0x01F2, 0x0F17, 0x053A, 0x00BF,
+ 0x038F, 0x0217, 0x0371, 0x01F1, 0x01BA, 0x022A, 0x02BF, 0x028F,
+ 0x008F, 0x03F1, 0x00E1, 0x00BA, 0x00F2, 0x0EBF, 0x06AF, 0x048F,
+ 0x0FE1, 0x0271, 0x07BA, 0x0D3A, 0x0C12, 0x08AC, 0x0717, 0x00AC,
+ 0x0412, 0x0901, 0x04E1, 0x07E1, 0x0417, 0x0CAF, 0x04AC, 0x01AC,
+ 0x04F2, 0x03BA, 0x05D7, 0x07F1, 0x01D7, 0x04AF, 0x04EF, 0x03AC,
+ 0x00AA, 0x01E1, 0x0071, 0x00F1, 0x012C, 0x03EF, 0x082A, 0x0112,
+ 0x03E1, 0x01FA, 0x0DAC, 0x0131, 0x0E12, 0x000F, 0x0B17, 0x007F,
+ 0x0AEF, 0x007A, 0x02AA, 0x0061, 0x0671, 0x0027, 0x013A, 0x058F,
+ 0x00FF, 0x033A, 0x0032, 0x0301, 0x0021, 0x0C8F, 0x037F, 0x0077,
+ 0x02F1, 0x02E1, 0x003A, 0x003C, 0x0212, 0x0817, 0x0CE1, 0x003F,
+ 0x0007, 0x0017, 0x0501, 0x02BA, 0x06BF, 0x0057, 0x0010, 0x02EF,
+ 0x0117, 0x017F, 0x00EF, 0x006A, 0x0019, 0x0171, 0x01EF, 0x06BA,
+ 0x012A, 0x00FA, 0x0022, 0x000E, 0x0AE1, 0x01AF, 0x0052, 0x002F,
+ 0x004F, 0x001A, 0x0004, 0x0003,
+};
+
+static const uint8_t ac_vlc_desc0_bits[172] = {
+ 6, 12, 9, 7, 8, 7, 6, 4,
+ 3, 11, 9, 11, 9, 9, 6, 4,
+ 11, 11, 11, 11, 7, 5, 11, 11,
+ 11, 12, 8, 5, 12, 12, 12, 9,
+ 6, 12, 12, 9, 6, 12, 10, 7,
+ 12, 10, 7, 12, 11, 7, 11, 8,
+ 11, 8, 12, 11, 8, 12, 8, 12,
+ 9, 9, 9, 9, 9, 12, 12, 10,
+ 10, 10, 10, 10, 10, 10, 11, 11,
+ 11, 11, 11, 11, 11, 12, 12, 12,
+ 12, 11, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 11, 11,
+ 11, 11, 11, 11, 11, 12, 11, 10,
+ 10, 10, 10, 10, 9, 10, 12, 9,
+ 12, 9, 12, 9, 12, 9, 12, 9,
+ 12, 8, 11, 8, 11, 8, 11, 11,
+ 8, 10, 7, 10, 7, 12, 10, 7,
+ 11, 12, 9, 6, 11, 12, 12, 9,
+ 6, 12, 11, 11, 12, 8, 5, 12,
+ 10, 11, 11, 7, 5, 11, 10, 11,
+ 9, 9, 6, 4, 12, 9, 7, 8,
+ 7, 6, 4, 3,
+};
+
+static const uint16_t ac_vlc_desc1_syms[169] = {
+ 0x1000, 0xFF8, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2, 0xFF1,
+ 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1, 0xFE0,
+ 0xFD6, 0xFD5, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC6, 0xFC5,
+ 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB6, 0xFB5, 0xFB3, 0xFB2,
+ 0xFB1, 0xFB0, 0xFA6, 0xFA5, 0xFA3, 0xFA1, 0xFA0, 0xF95,
+ 0xF93, 0xF91, 0xF90, 0xF85, 0xF81, 0xF80, 0xF71, 0xF70,
+ 0xF61, 0xF60, 0xF51, 0xF50, 0xF45, 0xF41, 0xF40, 0xF31,
+ 0xF30, 0xF21, 0xF20, 0xF11, 0xF10, 0xF01, 0xF00, 0xEF1,
+ 0xEF0, 0xEE1, 0xEE0, 0xED0, 0xEC6, 0xEC0, 0xEB6, 0xEB0,
+ 0xEA0, 0xE90, 0xE80, 0xE70, 0xE60, 0xE50, 0xE40, 0xE33,
+ 0xE31, 0xE30, 0xE20, 0xE10, 0xE00, 0xDF0, 0xDE1, 0xDE0,
+ 0xDC0, 0xDB0, 0xDA0, 0x250, 0x240, 0x1F0, 0x1E0, 0x1D0,
+ 0x1C0, 0x1B0, 0x1A0, 0x190, 0x180, 0x170, 0x160, 0x150,
+ 0x140, 0x130, 0x120, 0x111, 0x110, 0x101, 0x100, 0x0F1,
+ 0x0F0, 0x0E1, 0x0E0, 0x0D1, 0x0D0, 0x0C6, 0x0C1, 0x0C0,
+ 0x0B1, 0x0B0, 0x0A1, 0x0A0, 0x095, 0x091, 0x090, 0x085,
+ 0x081, 0x080, 0x075, 0x071, 0x070, 0x065, 0x063, 0x061,
+ 0x060, 0x055, 0x053, 0x052, 0x051, 0x050, 0x046, 0x045,
+ 0x043, 0x042, 0x041, 0x040, 0x036, 0x035, 0x033, 0x032,
+ 0x031, 0x030, 0x026, 0x025, 0x024, 0x023, 0x022, 0x021,
+ 0x020, 0x018, 0x016, 0x015, 0x014, 0x013, 0x012, 0x011,
+ 0x010,
+};
+
+static const uint16_t ac_vlc_desc1_codes[169] = {
+ 0x0019, 0x027D, 0x0084, 0x0044, 0x009D, 0x003D, 0x000A, 0x0002,
+ 0x0003, 0x00EA, 0x02FD, 0x017A, 0x01C6, 0x00B6, 0x0026, 0x000E,
+ 0x0095, 0x0260, 0x032A, 0x0360, 0x0006, 0x0005, 0x05B6, 0x036A,
+ 0x06F6, 0x0704, 0x00FA, 0x0010, 0x0279, 0x04D4, 0x00F6, 0x066A,
+ 0x001D, 0x0029, 0x05F9, 0x0846, 0x04F6, 0x01D4, 0x0038, 0x0446,
+ 0x0160, 0x031D, 0x0075, 0x0054, 0x02D4, 0x005A, 0x05FD, 0x0040,
+ 0x06EA, 0x0055, 0x0460, 0x009A, 0x052A, 0x00A0, 0x00D8, 0x0380,
+ 0x017D, 0x092A, 0x00F9, 0x0D7A, 0x0179, 0x0304, 0x002A, 0x0104,
+ 0x01A0, 0x0780, 0x007D, 0x03F9, 0x0C46, 0x03EA, 0x0E6A, 0x0204,
+ 0x01FD, 0x051D, 0x02AA, 0x05EA, 0x00AA, 0x0080, 0x067D, 0x09EA,
+ 0x0C95, 0x09F9, 0x07B6, 0x0DB6, 0x012A, 0x0904, 0x0454, 0x0FB6,
+ 0x0960, 0x08D4, 0x0495, 0x0F80, 0x0560, 0x0B04, 0x057A, 0x0079,
+ 0x0795, 0x0E7D, 0x0060, 0x076A, 0x03B6, 0x0395, 0x0180, 0x02A0,
+ 0x006A, 0x0195, 0x0295, 0x0646, 0x03FD, 0x01F9, 0x0154, 0x0DF9,
+ 0x00C6, 0x0F95, 0x01F6, 0x0480, 0x0000, 0x0A79, 0x04AA, 0x00E0,
+ 0x0246, 0x001A, 0x0479, 0x0015, 0x0D60, 0x0280, 0x0018, 0x01EA,
+ 0x037A, 0x003A, 0x011D, 0x00FD, 0x0035, 0x0A7D, 0x04A0, 0x0146,
+ 0x0024, 0x01B6, 0x0504, 0x0046, 0x0020, 0x0009, 0x00D4, 0x03AA,
+ 0x0679, 0x026A, 0x0036, 0x0008, 0x02F6, 0x01AA, 0x016A, 0x0254,
+ 0x0039, 0x000D, 0x0004, 0x0176, 0x02EA, 0x007A, 0x0076, 0x0016,
+ 0x0001, 0x0879, 0x0058, 0x0014, 0x00D5, 0x005D, 0x0034, 0x000C,
+ 0x0007,
+};
+
+static const uint8_t ac_vlc_desc1_bits[169] = {
+ 6, 12, 8, 7, 8, 7, 6, 4,
+ 3, 10, 10, 11, 9, 9, 6, 4,
+ 11, 10, 10, 10, 7, 5, 12, 11,
+ 11, 11, 8, 5, 12, 11, 11, 12,
+ 9, 6, 12, 12, 11, 9, 6, 12,
+ 12, 10, 7, 11, 10, 7, 11, 7,
+ 11, 8, 11, 8, 11, 11, 8, 11,
+ 9, 12, 9, 12, 9, 12, 9, 12,
+ 9, 12, 10, 10, 12, 10, 12, 10,
+ 11, 11, 10, 11, 11, 11, 12, 12,
+ 12, 12, 12, 12, 12, 12, 11, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 11, 11, 11, 11, 10, 10,
+ 10, 10, 10, 11, 10, 12, 9, 12,
+ 9, 12, 9, 11, 8, 12, 11, 8,
+ 11, 8, 11, 8, 12, 10, 7, 12,
+ 10, 7, 11, 10, 7, 12, 11, 9,
+ 6, 11, 11, 12, 8, 6, 12, 10,
+ 11, 11, 8, 5, 11, 10, 10, 10,
+ 7, 5, 10, 9, 11, 9, 9, 6,
+ 4, 12, 8, 7, 8, 7, 6, 4,
+ 3,
+};
+
+static const uint16_t ac_vlc_desc2_syms[165] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD6, 0xFD5, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC6,
+ 0xFC5, 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB6, 0xFB5, 0xFB3,
+ 0xFB2, 0xFB1, 0xFB0, 0xFA5, 0xFA3, 0xFA1, 0xFA0, 0xF95,
+ 0xF93, 0xF91, 0xF90, 0xF81, 0xF80, 0xF75, 0xF71, 0xF70,
+ 0xF61, 0xF60, 0xF51, 0xF50, 0xF41, 0xF40, 0xF36, 0xF31,
+ 0xF30, 0xF26, 0xF21, 0xF20, 0xF16, 0xF11, 0xF10, 0xF06,
+ 0xF01, 0xF00, 0xEF1, 0xEF0, 0xEE1, 0xEE0, 0xED0, 0xEC0,
+ 0xEB3, 0xEB1, 0xEB0, 0xEA3, 0xEA1, 0xEA0, 0xE90, 0xE81,
+ 0xE80, 0xE71, 0xE70, 0xE61, 0xE60, 0xE50, 0xE40, 0xE30,
+ 0xE10, 0xE00, 0x241, 0x240, 0x231, 0x1D0, 0x1C0, 0x1B3,
+ 0x1B0, 0x1A0, 0x190, 0x180, 0x170, 0x160, 0x150, 0x140,
+ 0x130, 0x120, 0x110, 0x100, 0x0F0, 0x0E0, 0x0D1, 0x0D0,
+ 0x0C1, 0x0C0, 0x0B1, 0x0B0, 0x0A5, 0x0A1, 0x0A0, 0x096,
+ 0x095, 0x091, 0x090, 0x086, 0x085, 0x081, 0x080, 0x075,
+ 0x071, 0x070, 0x065, 0x063, 0x061, 0x060, 0x055, 0x053,
+ 0x052, 0x051, 0x050, 0x045, 0x043, 0x042, 0x041, 0x040,
+ 0x036, 0x035, 0x033, 0x032, 0x031, 0x030, 0x026, 0x025,
+ 0x024, 0x023, 0x022, 0x021, 0x020, 0x018, 0x016, 0x015,
+ 0x014, 0x013, 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc2_codes[165] = {
+ 0x0034, 0x059C, 0x0280, 0x001C, 0x004C, 0x00BD, 0x0020, 0x003C,
+ 0x000A, 0x0003, 0x00FD, 0x008C, 0x0332, 0x01D5, 0x0055, 0x003E,
+ 0x0001, 0x07E4, 0x0264, 0x00B2, 0x00A2, 0x005C, 0x0005, 0x02A2,
+ 0x011D, 0x0132, 0x076C, 0x0012, 0x0018, 0x01E4, 0x05E4, 0x02B2,
+ 0x0432, 0x017D, 0x000E, 0x055D, 0x0955, 0x0164, 0x0028, 0x0D62,
+ 0x0B24, 0x02DE, 0x001E, 0x0340, 0x0014, 0x0555, 0x0180, 0x00DD,
+ 0x01B2, 0x0092, 0x036C, 0x00EC, 0x00E4, 0x00C0, 0x0C64, 0x095D,
+ 0x01DE, 0x0AE4, 0x0C32, 0x01A2, 0x06E4, 0x0832, 0x01A4, 0x015D,
+ 0x0732, 0x031D, 0x0F9C, 0x03E2, 0x09E2, 0x02FD, 0x0224, 0x051D,
+ 0x02E4, 0x019C, 0x05B2, 0x0355, 0x0064, 0x016C, 0x038C, 0x0880,
+ 0x0480, 0x06B2, 0x0540, 0x0080, 0x075D, 0x0155, 0x0424, 0x0680,
+ 0x0A62, 0x0A80, 0x078C, 0x0D9C, 0x0F8C, 0x0562, 0x0FF2, 0x0464,
+ 0x0B55, 0x01E2, 0x0032, 0x07F2, 0x0140, 0x03E4, 0x0662, 0x0755,
+ 0x0380, 0x026C, 0x0232, 0x001D, 0x0040, 0x00E2, 0x035D, 0x00F2,
+ 0x0162, 0x01FD, 0x03F2, 0x000C, 0x0EA2, 0x05F2, 0x0072, 0x04E4,
+ 0x0F32, 0x018C, 0x009D, 0x0324, 0x079C, 0x006C, 0x0054, 0x0F5D,
+ 0x021D, 0x0015, 0x0024, 0x06A2, 0x009C, 0x0004, 0x0062, 0x056C,
+ 0x0262, 0x0000, 0x002E, 0x01F2, 0x0124, 0x039C, 0x005E, 0x0010,
+ 0x0724, 0x00A4, 0x00DE, 0x0362, 0x0052, 0x000D, 0x03B2, 0x007D,
+ 0x05E2, 0x00D5, 0x005D, 0x0035, 0x0009, 0x099C, 0x0022, 0x002C,
+ 0x003D, 0x0008, 0x0002, 0x0006, 0x0007,
+};
+
+static const uint8_t ac_vlc_desc2_bits[165] = {
+ 6, 12, 12, 8, 7, 8, 6, 6,
+ 4, 3, 10, 9, 11, 9, 9, 6,
+ 4, 11, 10, 10, 10, 7, 5, 11,
+ 11, 10, 11, 8, 5, 11, 11, 11,
+ 12, 9, 6, 11, 12, 9, 6, 12,
+ 12, 10, 7, 10, 7, 11, 10, 8,
+ 11, 8, 11, 8, 11, 8, 12, 12,
+ 9, 12, 12, 9, 11, 12, 9, 12,
+ 12, 10, 12, 10, 12, 10, 10, 11,
+ 12, 12, 11, 12, 11, 11, 11, 12,
+ 11, 11, 11, 12, 12, 12, 11, 11,
+ 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 11, 11, 11, 11,
+ 10, 10, 10, 10, 9, 9, 11, 9,
+ 11, 9, 11, 8, 12, 11, 8, 11,
+ 12, 10, 8, 12, 12, 10, 7, 12,
+ 10, 7, 11, 12, 9, 6, 10, 11,
+ 12, 8, 6, 11, 10, 11, 8, 5,
+ 11, 9, 10, 10, 7, 5, 10, 9,
+ 11, 9, 9, 6, 4, 12, 8, 7,
+ 8, 6, 6, 4, 3,
+};
+
+static const uint16_t ac_vlc_desc3_syms[162] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD6, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0,
+ 0xFC6, 0xFC5, 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB5, 0xFB3,
+ 0xFB2, 0xFB1, 0xFB0, 0xFA5, 0xFA3, 0xFA1, 0xFA0, 0xF95,
+ 0xF93, 0xF91, 0xF90, 0xF85, 0xF83, 0xF81, 0xF80, 0xF71,
+ 0xF70, 0xF66, 0xF61, 0xF60, 0xF56, 0xF51, 0xF50, 0xF46,
+ 0xF41, 0xF40, 0xF36, 0xF31, 0xF30, 0xF26, 0xF21, 0xF20,
+ 0xF11, 0xF10, 0xF01, 0xF00, 0xEF3, 0xEF1, 0xEF0, 0xEE3,
+ 0xEE1, 0xEE0, 0xED3, 0xED1, 0xED0, 0xEC1, 0xEC0, 0xEB1,
+ 0xEB0, 0xEA0, 0xE90, 0xE80, 0xE70, 0x1E1, 0x1D1, 0x1D0,
+ 0x1C1, 0x1B1, 0x1A1, 0x180, 0x170, 0x163, 0x160, 0x150,
+ 0x140, 0x130, 0x123, 0x120, 0x113, 0x110, 0x100, 0x0F0,
+ 0x0E0, 0x0D1, 0x0D0, 0x0C1, 0x0C0, 0x0B1, 0x0B0, 0x0A1,
+ 0x0A0, 0x095, 0x091, 0x090, 0x085, 0x081, 0x080, 0x076,
+ 0x075, 0x073, 0x071, 0x070, 0x066, 0x065, 0x063, 0x061,
+ 0x060, 0x055, 0x053, 0x052, 0x051, 0x050, 0x045, 0x043,
+ 0x042, 0x041, 0x040, 0x036, 0x035, 0x034, 0x033, 0x032,
+ 0x031, 0x030, 0x026, 0x025, 0x024, 0x023, 0x022, 0x021,
+ 0x020, 0x018, 0x017, 0x016, 0x015, 0x014, 0x013, 0x012,
+ 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc3_codes[162] = {
+ 0x001D, 0x087C, 0x0AE8, 0x003A, 0x001C, 0x0008, 0x000C, 0x0032,
+ 0x0006, 0x0003, 0x03A5, 0x01EC, 0x01A5, 0x0080, 0x0030, 0x0005,
+ 0x0001, 0x0040, 0x03FC, 0x02D4, 0x0154, 0x02FC, 0x003C, 0x0015,
+ 0x051A, 0x0000, 0x02EC, 0x077C, 0x00D2, 0x0018, 0x03E8, 0x04EC,
+ 0x027C, 0x01FA, 0x0022, 0x0765, 0x0EA5, 0x0054, 0x0010, 0x08EC,
+ 0x0AAC, 0x03BA, 0x0042, 0x065D, 0x0AD4, 0x005C, 0x0028, 0x03C0,
+ 0x00E5, 0x035C, 0x04FA, 0x00DC, 0x06A5, 0x075C, 0x00C8, 0x05A5,
+ 0x04D4, 0x00BA, 0x01C0, 0x05E8, 0x012C, 0x00E8, 0x01B0, 0x00B0,
+ 0x025D, 0x002C, 0x0A52, 0x025C, 0x01E8, 0x00FA, 0x0348, 0x0652,
+ 0x0B7C, 0x0365, 0x031A, 0x0E52, 0x011A, 0x0200, 0x01BA, 0x02AC,
+ 0x06D4, 0x01FC, 0x05BA, 0x0DFC, 0x0248, 0x0EE8, 0x0B1A, 0x0CFC,
+ 0x0F65, 0x0B5C, 0x0DC0, 0x007C, 0x0548, 0x08A5, 0x00FC, 0x03B0,
+ 0x0148, 0x06AC, 0x0252, 0x071A, 0x02E8, 0x0240, 0x00AC, 0x021A,
+ 0x0140, 0x08E8, 0x01AC, 0x00EC, 0x0152, 0x00A5, 0x0068, 0x001A,
+ 0x006C, 0x05C0, 0x015C, 0x0025, 0x05B0, 0x017C, 0x0014, 0x047C,
+ 0x00D4, 0x06E8, 0x00C0, 0x0002, 0x0A5D, 0x04E8, 0x0A7C, 0x01D4,
+ 0x0020, 0x04A5, 0x07B0, 0x037C, 0x015D, 0x002A, 0x005D, 0x0048,
+ 0x067C, 0x007A, 0x0004, 0x04FC, 0x02FA, 0x0648, 0x0100, 0x0052,
+ 0x005A, 0x000D, 0x0165, 0x0065, 0x02A5, 0x0070, 0x00F0, 0x003D,
+ 0x0009, 0x05FC, 0x0E48, 0x009A, 0x0012, 0x00DD, 0x0034, 0x000A,
+ 0x000E, 0x0007,
+};
+
+static const uint8_t ac_vlc_desc3_bits[162] = {
+ 7, 12, 12, 8, 7, 7, 6, 6,
+ 4, 3, 10, 9, 11, 8, 8, 6,
+ 4, 10, 10, 12, 9, 10, 7, 5,
+ 11, 10, 10, 11, 8, 5, 10, 11,
+ 12, 9, 6, 12, 12, 9, 6, 12,
+ 12, 10, 7, 11, 12, 10, 7, 10,
+ 8, 12, 11, 8, 12, 11, 8, 11,
+ 11, 9, 11, 11, 9, 12, 11, 9,
+ 12, 9, 12, 10, 11, 11, 10, 12,
+ 12, 11, 12, 12, 11, 10, 11, 12,
+ 11, 11, 11, 12, 11, 12, 12, 12,
+ 12, 12, 12, 12, 11, 12, 11, 11,
+ 11, 11, 12, 11, 12, 10, 10, 10,
+ 9, 12, 9, 12, 9, 12, 8, 10,
+ 8, 12, 10, 8, 11, 10, 7, 11,
+ 11, 12, 9, 7, 12, 11, 12, 9,
+ 6, 11, 11, 12, 9, 6, 10, 10,
+ 11, 8, 5, 12, 10, 12, 9, 10,
+ 7, 5, 10, 9, 11, 8, 8, 6,
+ 4, 12, 12, 8, 7, 8, 6, 6,
+ 4, 3,
+};
+
+static const uint16_t ac_vlc_desc4_syms[131] = {
+ 0x1000, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2, 0xFF1, 0xFF0,
+ 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1, 0xFE0, 0xFD6,
+ 0xFD5, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC5, 0xFC3, 0xFC2,
+ 0xFC1, 0xFC0, 0xFB5, 0xFB3, 0xFB1, 0xFB0, 0xFA5, 0xFA3,
+ 0xFA1, 0xFA0, 0xF93, 0xF91, 0xF90, 0xF81, 0xF80, 0xF76,
+ 0xF71, 0xF70, 0xF66, 0xF61, 0xF60, 0xF56, 0xF51, 0xF50,
+ 0xF41, 0xF40, 0xF31, 0xF30, 0xF23, 0xF21, 0xF20, 0xF13,
+ 0xF11, 0xF10, 0xF03, 0xF01, 0xF00, 0xEF1, 0xEF0, 0xEE0,
+ 0xED0, 0xEC0, 0xEB0, 0x191, 0x181, 0x180, 0x171, 0x161,
+ 0x140, 0x130, 0x123, 0x120, 0x110, 0x100, 0x0F3, 0x0F0,
+ 0x0E0, 0x0D0, 0x0C0, 0x0B1, 0x0B0, 0x0A1, 0x0A0, 0x091,
+ 0x090, 0x085, 0x081, 0x080, 0x075, 0x071, 0x070, 0x066,
+ 0x065, 0x063, 0x061, 0x060, 0x056, 0x055, 0x053, 0x051,
+ 0x050, 0x045, 0x043, 0x042, 0x041, 0x040, 0x036, 0x035,
+ 0x033, 0x032, 0x031, 0x030, 0x026, 0x025, 0x024, 0x023,
+ 0x022, 0x021, 0x020, 0x018, 0x016, 0x015, 0x014, 0x013,
+ 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc4_codes[131] = {
+ 0x006B, 0x00BE, 0x0052, 0x00F3, 0x005B, 0x003A, 0x0009, 0x0007,
+ 0x00DA, 0x03FB, 0x0123, 0x00B3, 0x01B3, 0x002E, 0x0006, 0x030A,
+ 0x005A, 0x004A, 0x034A, 0x0072, 0x0005, 0x02DA, 0x0173, 0x04FB,
+ 0x0032, 0x0013, 0x039B, 0x0B9B, 0x011E, 0x0002, 0x00FB, 0x021E,
+ 0x009B, 0x007E, 0x0E1A, 0x03CA, 0x007B, 0x02FB, 0x0033, 0x03AB,
+ 0x0463, 0x008A, 0x0773, 0x041E, 0x002B, 0x031B, 0x065A, 0x011A,
+ 0x060A, 0x01DA, 0x0963, 0x0323, 0x0BAB, 0x059E, 0x010A, 0x05AB,
+ 0x0CFB, 0x071B, 0x079E, 0x0F9E, 0x0263, 0x079B, 0x0563, 0x019E,
+ 0x01AB, 0x0E63, 0x029B, 0x04CA, 0x0DAB, 0x0663, 0x0B1B, 0x020A,
+ 0x0A1E, 0x021A, 0x0063, 0x061E, 0x06FB, 0x025A, 0x0163, 0x0573,
+ 0x000A, 0x0223, 0x011B, 0x0C1A, 0x015A, 0x0863, 0x00AB, 0x02CA,
+ 0x00B2, 0x0A0A, 0x01CA, 0x00A3, 0x0B73, 0x0023, 0x0012, 0x039E,
+ 0x001A, 0x0CCA, 0x01FB, 0x005E, 0x0A9B, 0x00CA, 0x0373, 0x009E,
+ 0x0022, 0x07AB, 0x001E, 0x0EFB, 0x009A, 0x000B, 0x041A, 0x019B,
+ 0x0363, 0x014A, 0x006A, 0x0015, 0x069B, 0x0073, 0x0523, 0x001B,
+ 0x012B, 0x0003, 0x0001, 0x061A, 0x003E, 0x002A, 0x00E3, 0x003B,
+ 0x000E, 0x000D, 0x0000,
+};
+
+static const uint8_t ac_vlc_desc4_bits[131] = {
+ 7, 8, 7, 8, 7, 6, 4, 3,
+ 10, 10, 11, 9, 9, 6, 4, 10,
+ 10, 9, 10, 7, 5, 10, 11, 12,
+ 8, 6, 12, 12, 9, 6, 11, 12,
+ 10, 7, 12, 10, 8, 11, 8, 12,
+ 11, 8, 11, 11, 9, 12, 11, 9,
+ 11, 9, 12, 10, 12, 11, 10, 12,
+ 12, 11, 12, 12, 11, 11, 11, 11,
+ 11, 12, 12, 12, 12, 12, 12, 12,
+ 12, 11, 12, 11, 12, 11, 12, 11,
+ 10, 10, 10, 12, 9, 12, 9, 10,
+ 8, 12, 10, 8, 12, 10, 7, 11,
+ 11, 12, 10, 7, 12, 11, 12, 9,
+ 6, 11, 11, 12, 8, 6, 12, 10,
+ 10, 10, 7, 5, 11, 9, 11, 9,
+ 9, 6, 4, 12, 8, 7, 8, 7,
+ 6, 4, 2,
+};
+
+static const uint16_t ac_vlc_desc5_syms[132] = {
+ 0x1000, 0xFF8, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2, 0xFF1,
+ 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1, 0xFE0,
+ 0xFD6, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC5,
+ 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB5, 0xFB3, 0xFB1, 0xFB0,
+ 0xFA3, 0xFA1, 0xFA0, 0xF96, 0xF93, 0xF91, 0xF90, 0xF86,
+ 0xF85, 0xF81, 0xF80, 0xF76, 0xF75, 0xF71, 0xF70, 0xF66,
+ 0xF61, 0xF60, 0xF51, 0xF50, 0xF43, 0xF41, 0xF40, 0xF33,
+ 0xF31, 0xF30, 0xF23, 0xF21, 0xF20, 0xF11, 0xF10, 0xF00,
+ 0xEF0, 0xEE0, 0xEC1, 0xEC0, 0x151, 0x141, 0x140, 0x131,
+ 0x121, 0x120, 0x111, 0x110, 0x103, 0x100, 0x0F0, 0x0E0,
+ 0x0D3, 0x0D0, 0x0C3, 0x0C1, 0x0C0, 0x0B1, 0x0B0, 0x0A1,
+ 0x0A0, 0x091, 0x090, 0x081, 0x080, 0x075, 0x071, 0x070,
+ 0x065, 0x061, 0x060, 0x056, 0x055, 0x053, 0x052, 0x051,
+ 0x050, 0x046, 0x045, 0x043, 0x042, 0x041, 0x040, 0x035,
+ 0x034, 0x033, 0x032, 0x031, 0x030, 0x026, 0x025, 0x024,
+ 0x023, 0x022, 0x021, 0x020, 0x018, 0x016, 0x015, 0x014,
+ 0x013, 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc5_codes[132] = {
+ 0x0001, 0x0D62, 0x00BD, 0x0022, 0x009B, 0x0032, 0x0019, 0x0005,
+ 0x0007, 0x034D, 0x009A, 0x012B, 0x0052, 0x006B, 0x003A, 0x0006,
+ 0x06FD, 0x017D, 0x081A, 0x031B, 0x031A, 0x0012, 0x0011, 0x0202,
+ 0x00FD, 0x051B, 0x00D2, 0x001D, 0x011A, 0x0782, 0x018D, 0x007B,
+ 0x067D, 0x037D, 0x0021, 0x0E8D, 0x0562, 0x008D, 0x00BB, 0x053D,
+ 0x082A, 0x0002, 0x000D, 0x0302, 0x007D, 0x053B, 0x003B, 0x0A4D,
+ 0x027D, 0x01FD, 0x042A, 0x01C2, 0x041A, 0x0182, 0x014D, 0x0162,
+ 0x00C2, 0x032A, 0x0D9A, 0x012A, 0x0102, 0x087D, 0x072B, 0x039A,
+ 0x0362, 0x019A, 0x0C62, 0x04C2, 0x0D1B, 0x028D, 0x0762, 0x0E7D,
+ 0x0E41, 0x059A, 0x024D, 0x093B, 0x052B, 0x011B, 0x064D, 0x013D,
+ 0x0382, 0x0262, 0x0641, 0x0462, 0x004D, 0x0CC2, 0x033B, 0x068D,
+ 0x0141, 0x0D2B, 0x001B, 0x0041, 0x00C1, 0x0C41, 0x01E2, 0x00EB,
+ 0x062A, 0x0082, 0x0061, 0x02FD, 0x047D, 0x013B, 0x002A, 0x003D,
+ 0x005B, 0x022A, 0x02C2, 0x0241, 0x0062, 0x00AA, 0x000B, 0x00E2,
+ 0x001A, 0x033D, 0x021A, 0x006A, 0x0009, 0x032B, 0x002B, 0x04FD,
+ 0x0042, 0x016B, 0x002D, 0x000E, 0x0441, 0x00CD, 0x005A, 0x00AB,
+ 0x000A, 0x0039, 0x0003, 0x0000,
+};
+
+static const uint8_t ac_vlc_desc5_bits[132] = {
+ 7, 12, 8, 7, 8, 6, 6, 4,
+ 3, 10, 9, 11, 8, 9, 6, 4,
+ 11, 10, 12, 10, 10, 7, 5, 10,
+ 11, 12, 8, 6, 10, 11, 9, 7,
+ 12, 10, 7, 12, 12, 10, 8, 11,
+ 12, 10, 8, 10, 12, 11, 9, 12,
+ 11, 9, 11, 9, 11, 10, 10, 11,
+ 11, 10, 12, 10, 10, 12, 11, 10,
+ 11, 11, 12, 12, 12, 11, 11, 12,
+ 12, 12, 12, 12, 12, 11, 11, 11,
+ 11, 10, 12, 12, 10, 12, 10, 12,
+ 9, 12, 9, 11, 8, 12, 9, 8,
+ 11, 9, 7, 11, 11, 12, 12, 9,
+ 7, 11, 10, 11, 11, 8, 6, 9,
+ 12, 10, 10, 7, 5, 11, 9, 11,
+ 8, 9, 6, 4, 12, 8, 7, 8,
+ 6, 6, 4, 2,
+};
+
+static const uint16_t ac_vlc_desc6_syms[130] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD6, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0,
+ 0xFC5, 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB5, 0xFB3, 0xFB1,
+ 0xFB0, 0xFA6, 0xFA3, 0xFA1, 0xFA0, 0xF96, 0xF95, 0xF93,
+ 0xF91, 0xF90, 0xF86, 0xF85, 0xF81, 0xF80, 0xF76, 0xF71,
+ 0xF70, 0xF63, 0xF61, 0xF60, 0xF53, 0xF51, 0xF50, 0xF43,
+ 0xF41, 0xF40, 0xF31, 0xF30, 0xF20, 0xF10, 0xF00, 0xEF0,
+ 0xEE1, 0x131, 0x121, 0x120, 0x111, 0x110, 0x101, 0x100,
+ 0x0F1, 0x0F0, 0x0E3, 0x0E1, 0x0E0, 0x0D1, 0x0D0, 0x0C3,
+ 0x0C0, 0x0B3, 0x0B1, 0x0B0, 0x0A1, 0x0A0, 0x091, 0x090,
+ 0x081, 0x080, 0x075, 0x071, 0x070, 0x065, 0x063, 0x061,
+ 0x060, 0x056, 0x055, 0x053, 0x051, 0x050, 0x046, 0x045,
+ 0x043, 0x042, 0x041, 0x040, 0x036, 0x035, 0x034, 0x033,
+ 0x032, 0x031, 0x030, 0x026, 0x025, 0x024, 0x023, 0x022,
+ 0x021, 0x020, 0x018, 0x016, 0x015, 0x014, 0x013, 0x012,
+ 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc6_codes[130] = {
+ 0x0022, 0x0BB2, 0x0942, 0x002B, 0x0072, 0x0002, 0x001A, 0x0039,
+ 0x000D, 0x0007, 0x007B, 0x008E, 0x06DB, 0x00EA, 0x015B, 0x002E,
+ 0x0006, 0x0959, 0x027B, 0x0A0E, 0x01AB, 0x008A, 0x0012, 0x001E,
+ 0x0575, 0x005B, 0x02AB, 0x00C2, 0x0015, 0x036A, 0x04B2, 0x0099,
+ 0x001B, 0x0519, 0x0C19, 0x00DB, 0x004E, 0x0042, 0x0159, 0x03B2,
+ 0x030E, 0x00EB, 0x0252, 0x0EAB, 0x018A, 0x00E2, 0x06AB, 0x0242,
+ 0x017B, 0x0452, 0x0319, 0x0152, 0x025B, 0x016A, 0x00AB, 0x0052,
+ 0x05B2, 0x010E, 0x038E, 0x028A, 0x0359, 0x0019, 0x078A, 0x0C52,
+ 0x0D8E, 0x0ED9, 0x02D9, 0x0662, 0x0119, 0x09B2, 0x0BAB, 0x0D19,
+ 0x0C5B, 0x00B2, 0x0542, 0x0B8A, 0x02B2, 0x0142, 0x065B, 0x058E,
+ 0x0062, 0x018E, 0x038A, 0x00D9, 0x0419, 0x0162, 0x03AB, 0x0075,
+ 0x07B2, 0x0032, 0x020E, 0x07AB, 0x006B, 0x045B, 0x01B2, 0x0199,
+ 0x002A, 0x0375, 0x0775, 0x0AAB, 0x01D9, 0x003B, 0x060E, 0x0342,
+ 0x0175, 0x0262, 0x000A, 0x0005, 0x0559, 0x006A, 0x0D59, 0x0219,
+ 0x000E, 0x004A, 0x0009, 0x0719, 0x0059, 0x02DB, 0x00D2, 0x01DB,
+ 0x0025, 0x0001, 0x06D9, 0x00F5, 0x0035, 0x00FB, 0x003A, 0x000B,
+ 0x0003, 0x0000,
+};
+
+static const uint8_t ac_vlc_desc6_bits[130] = {
+ 7, 12, 12, 8, 7, 7, 6, 6,
+ 4, 3, 10, 9, 11, 8, 9, 6,
+ 4, 12, 10, 12, 10, 10, 7, 5,
+ 11, 11, 12, 8, 6, 10, 11, 9,
+ 7, 12, 12, 10, 7, 10, 12, 12,
+ 10, 8, 10, 12, 10, 8, 12, 10,
+ 9, 12, 11, 9, 11, 10, 10, 11,
+ 11, 10, 10, 10, 10, 11, 11, 12,
+ 12, 12, 11, 11, 11, 12, 12, 12,
+ 12, 11, 11, 12, 10, 12, 11, 12,
+ 10, 11, 12, 10, 12, 9, 12, 9,
+ 11, 8, 12, 11, 8, 12, 12, 9,
+ 7, 11, 11, 12, 9, 7, 11, 10,
+ 11, 11, 8, 6, 12, 9, 12, 10,
+ 10, 7, 5, 11, 9, 11, 8, 9,
+ 6, 4, 12, 8, 7, 8, 6, 6,
+ 4, 2,
+};
+
+static const uint16_t ac_vlc_desc7_syms[125] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC5,
+ 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB5, 0xFB3, 0xFB1, 0xFB0,
+ 0xFA6, 0xFA5, 0xFA3, 0xFA1, 0xFA0, 0xF96, 0xF95, 0xF93,
+ 0xF91, 0xF90, 0xF86, 0xF81, 0xF80, 0xF73, 0xF71, 0xF70,
+ 0xF63, 0xF61, 0xF60, 0xF53, 0xF51, 0xF50, 0xF41, 0xF40,
+ 0xF31, 0xF30, 0xF20, 0xF10, 0xF01, 0xF00, 0x121, 0x111,
+ 0x101, 0x100, 0x0F1, 0x0F0, 0x0E1, 0x0E0, 0x0D1, 0x0D0,
+ 0x0C3, 0x0C1, 0x0C0, 0x0B1, 0x0B0, 0x0A3, 0x0A1, 0x0A0,
+ 0x093, 0x091, 0x090, 0x081, 0x080, 0x071, 0x070, 0x065,
+ 0x063, 0x061, 0x060, 0x055, 0x053, 0x052, 0x051, 0x050,
+ 0x046, 0x045, 0x043, 0x042, 0x041, 0x040, 0x036, 0x035,
+ 0x034, 0x033, 0x032, 0x031, 0x030, 0x026, 0x025, 0x024,
+ 0x023, 0x022, 0x021, 0x020, 0x018, 0x017, 0x016, 0x015,
+ 0x014, 0x013, 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc7_codes[125] = {
+ 0x0053, 0x009A, 0x0EE2, 0x00D3, 0x006A, 0x0052, 0x003A, 0x0035,
+ 0x000D, 0x0007, 0x0062, 0x0125, 0x0142, 0x0019, 0x01F3, 0x0029,
+ 0x000E, 0x0082, 0x0ADA, 0x02E3, 0x00E2, 0x0022, 0x0006, 0x0065,
+ 0x05E3, 0x0765, 0x0032, 0x0039, 0x0F99, 0x05E2, 0x0099, 0x0033,
+ 0x0362, 0x0799, 0x0F65, 0x0073, 0x004A, 0x02A5, 0x0162, 0x0742,
+ 0x01A5, 0x00D9, 0x0342, 0x005A, 0x00AA, 0x0EF3, 0x0182, 0x01DA,
+ 0x0382, 0x035A, 0x00F3, 0x0673, 0x0165, 0x00E5, 0x06F3, 0x0225,
+ 0x0842, 0x025A, 0x07E3, 0x0399, 0x07A5, 0x072A, 0x0F2A, 0x09E3,
+ 0x0273, 0x049A, 0x02E5, 0x0B99, 0x02E2, 0x0E73, 0x0562, 0x02F3,
+ 0x032A, 0x0F42, 0x00DA, 0x0999, 0x012A, 0x0365, 0x00A5, 0x00E3,
+ 0x0199, 0x03E3, 0x019A, 0x01E2, 0x0173, 0x06E5, 0x0059, 0x01E3,
+ 0x02DA, 0x002A, 0x000A, 0x06DA, 0x0FA5, 0x0042, 0x01E5, 0x0013,
+ 0x03E2, 0x015A, 0x03A5, 0x0442, 0x001A, 0x0005, 0x04A5, 0x0265,
+ 0x08A5, 0x0025, 0x029A, 0x0072, 0x0016, 0x0599, 0x00C2, 0x0242,
+ 0x00B2, 0x0002, 0x0015, 0x0001, 0x0BE3, 0x06E2, 0x0063, 0x0023,
+ 0x0012, 0x0009, 0x0003, 0x000B, 0x0000,
+};
+
+static const uint8_t ac_vlc_desc7_bits[125] = {
+ 8, 11, 12, 8, 7, 7, 6, 6,
+ 4, 3, 9, 9, 10, 8, 9, 6,
+ 4, 9, 12, 10, 10, 7, 5, 10,
+ 11, 12, 8, 6, 12, 11, 9, 7,
+ 10, 12, 12, 10, 7, 10, 11, 12,
+ 10, 8, 11, 10, 8, 12, 10, 9,
+ 10, 10, 10, 12, 10, 10, 12, 10,
+ 12, 10, 11, 12, 12, 12, 12, 12,
+ 11, 11, 11, 12, 11, 12, 11, 11,
+ 11, 12, 10, 12, 10, 11, 12, 10,
+ 12, 12, 9, 11, 9, 11, 8, 12,
+ 12, 9, 7, 11, 12, 12, 9, 7,
+ 10, 10, 11, 11, 8, 6, 11, 10,
+ 12, 10, 10, 7, 5, 11, 8, 10,
+ 8, 8, 6, 4, 12, 12, 8, 7,
+ 7, 6, 6, 4, 2,
+};
+
+static const uint16_t ac_vlc_desc8_syms[121] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC5,
+ 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB6, 0xFB5, 0xFB3, 0xFB1,
+ 0xFB0, 0xFA6, 0xFA5, 0xFA3, 0xFA1, 0xFA0, 0xF96, 0xF95,
+ 0xF93, 0xF91, 0xF90, 0xF86, 0xF83, 0xF81, 0xF80, 0xF73,
+ 0xF71, 0xF70, 0xF63, 0xF61, 0xF60, 0xF51, 0xF50, 0xF41,
+ 0xF40, 0xF30, 0xF21, 0xF20, 0x111, 0x101, 0x0F1, 0x0E1,
+ 0x0E0, 0x0D1, 0x0D0, 0x0C1, 0x0C0, 0x0B3, 0x0B1, 0x0B0,
+ 0x0A3, 0x0A1, 0x0A0, 0x093, 0x091, 0x090, 0x083, 0x081,
+ 0x080, 0x073, 0x071, 0x070, 0x065, 0x063, 0x061, 0x060,
+ 0x055, 0x053, 0x051, 0x050, 0x046, 0x045, 0x043, 0x042,
+ 0x041, 0x040, 0x036, 0x035, 0x034, 0x033, 0x032, 0x031,
+ 0x030, 0x026, 0x025, 0x024, 0x023, 0x022, 0x021, 0x020,
+ 0x018, 0x017, 0x016, 0x015, 0x014, 0x013, 0x012, 0x011,
+ 0x010,
+};
+
+static const uint16_t ac_vlc_desc8_codes[121] = {
+ 0x00F6, 0x0676, 0x0EB6, 0x00F3, 0x0056, 0x006A, 0x0039, 0x0003,
+ 0x000D, 0x0007, 0x00A2, 0x0173, 0x00CA, 0x0025, 0x0082, 0x0019,
+ 0x0001, 0x00B6, 0x0276, 0x02E3, 0x00B2, 0x0062, 0x001A, 0x0175,
+ 0x01E3, 0x0BE5, 0x004A, 0x0029, 0x07A5, 0x00E3, 0x030A, 0x0176,
+ 0x0023, 0x0042, 0x05CA, 0x00A5, 0x0142, 0x0052, 0x04A5, 0x0B02,
+ 0x0D22, 0x0375, 0x0065, 0x0522, 0x0DE3, 0x010A, 0x00F5, 0x0136,
+ 0x0275, 0x01B2, 0x03F5, 0x03E3, 0x0002, 0x08E3, 0x01A2, 0x0B36,
+ 0x020A, 0x0076, 0x0CE3, 0x07E5, 0x070A, 0x03A5, 0x02B6, 0x0036,
+ 0x01E5, 0x02A5, 0x05E3, 0x07B6, 0x07F5, 0x0736, 0x0BA5, 0x0075,
+ 0x0302, 0x0FE5, 0x01B6, 0x0102, 0x04E3, 0x0022, 0x08A5, 0x01CA,
+ 0x00E5, 0x0F0A, 0x05E5, 0x0096, 0x0A76, 0x0336, 0x0236, 0x0012,
+ 0x03B6, 0x0BF5, 0x0073, 0x0035, 0x02B2, 0x000A, 0x0476, 0x0122,
+ 0x0016, 0x0009, 0x0322, 0x01F5, 0x03E5, 0x01A5, 0x03CA, 0x0072,
+ 0x0006, 0x06A5, 0x0032, 0x02CA, 0x008A, 0x00C2, 0x0015, 0x000E,
+ 0x0702, 0x06B6, 0x0063, 0x0033, 0x002A, 0x0005, 0x0013, 0x000B,
+ 0x0000,
+};
+
+static const uint8_t ac_vlc_desc8_bits[121] = {
+ 8, 11, 12, 8, 7, 7, 6, 6,
+ 4, 3, 9, 9, 10, 8, 8, 6,
+ 4, 10, 12, 10, 10, 7, 5, 10,
+ 11, 12, 8, 6, 11, 12, 11, 9,
+ 7, 9, 11, 12, 9, 7, 11, 12,
+ 12, 10, 8, 12, 12, 10, 9, 10,
+ 10, 9, 12, 10, 9, 12, 9, 12,
+ 10, 11, 12, 12, 12, 12, 11, 10,
+ 11, 11, 12, 11, 11, 11, 12, 10,
+ 12, 12, 10, 10, 12, 9, 12, 11,
+ 9, 12, 11, 8, 12, 12, 10, 7,
+ 11, 12, 9, 7, 10, 10, 11, 11,
+ 8, 6, 10, 10, 12, 10, 10, 7,
+ 5, 11, 8, 10, 8, 8, 6, 4,
+ 11, 12, 8, 7, 7, 6, 6, 4,
+ 2,
+};
+
+static const uint16_t ac_vlc_desc9_syms[114] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC5,
+ 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB6, 0xFB5, 0xFB3, 0xFB2,
+ 0xFB1, 0xFB0, 0xFA6, 0xFA5, 0xFA3, 0xFA1, 0xFA0, 0xF96,
+ 0xF93, 0xF91, 0xF90, 0xF83, 0xF81, 0xF80, 0xF73, 0xF71,
+ 0xF70, 0xF61, 0xF60, 0xF51, 0xF50, 0xF40, 0xF31, 0xF30,
+ 0xF21, 0x121, 0x0F1, 0x0E1, 0x0D1, 0x0D0, 0x0C1, 0x0C0,
+ 0x0B1, 0x0B0, 0x0A3, 0x0A1, 0x0A0, 0x093, 0x091, 0x090,
+ 0x083, 0x081, 0x080, 0x073, 0x071, 0x070, 0x065, 0x063,
+ 0x061, 0x060, 0x055, 0x053, 0x051, 0x050, 0x045, 0x043,
+ 0x042, 0x041, 0x040, 0x036, 0x035, 0x034, 0x033, 0x032,
+ 0x031, 0x030, 0x026, 0x025, 0x024, 0x023, 0x022, 0x021,
+ 0x020, 0x018, 0x017, 0x016, 0x015, 0x014, 0x013, 0x012,
+ 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_desc9_codes[114] = {
+ 0x0061, 0x0403, 0x0DB1, 0x0012, 0x0071, 0x0056, 0x0035, 0x0023,
+ 0x000D, 0x0007, 0x0243, 0x01D3, 0x026A, 0x00A1, 0x00A2, 0x0011,
+ 0x000E, 0x01AA, 0x0531, 0x0093, 0x0222, 0x0032, 0x0006, 0x07F2,
+ 0x04D3, 0x0C43, 0x0072, 0x0001, 0x0343, 0x05F2, 0x04AA, 0x03F2,
+ 0x0031, 0x0045, 0x0143, 0x00AA, 0x0B31, 0x00F2, 0x00C3, 0x0693,
+ 0x0BF2, 0x0203, 0x00E1, 0x03B1, 0x02D3, 0x00B1, 0x056A, 0x01D2,
+ 0x008A, 0x046A, 0x01E2, 0x0003, 0x0103, 0x01B1, 0x02E2, 0x0293,
+ 0x016A, 0x04E2, 0x0443, 0x0521, 0x0321, 0x0043, 0x00D3, 0x00E2,
+ 0x0703, 0x00D2, 0x0731, 0x0A93, 0x0393, 0x0803, 0x0422, 0x0383,
+ 0x018A, 0x006A, 0x0021, 0x096A, 0x0303, 0x0052, 0x0CE2, 0x0D31,
+ 0x038A, 0x0013, 0x01F2, 0x0E93, 0x0083, 0x0005, 0x02D2, 0x0121,
+ 0x0022, 0x00EA, 0x0036, 0x0122, 0x0193, 0x0331, 0x0183, 0x02AA,
+ 0x004A, 0x001A, 0x0131, 0x002A, 0x036A, 0x000A, 0x0062, 0x0025,
+ 0x0009, 0x06E2, 0x05B1, 0x0053, 0x0002, 0x0016, 0x0015, 0x0033,
+ 0x000B, 0x0000,
+};
+
+static const uint8_t ac_vlc_desc9_bits[114] = {
+ 8, 11, 12, 7, 7, 7, 6, 6,
+ 4, 3, 10, 9, 10, 8, 8, 6,
+ 4, 9, 12, 10, 10, 7, 5, 11,
+ 11, 12, 8, 6, 10, 11, 11, 12,
+ 9, 7, 10, 11, 12, 9, 8, 12,
+ 12, 10, 8, 10, 10, 9, 11, 9,
+ 9, 11, 9, 12, 10, 11, 11, 12,
+ 12, 12, 12, 11, 10, 11, 11, 11,
+ 11, 10, 11, 12, 10, 12, 11, 10,
+ 10, 11, 9, 12, 11, 8, 12, 12,
+ 10, 8, 11, 12, 9, 7, 10, 11,
+ 11, 8, 6, 9, 10, 12, 10, 10,
+ 7, 5, 11, 8, 10, 8, 8, 6,
+ 4, 11, 12, 8, 6, 7, 6, 6,
+ 4, 2,
+};
+
+static const uint16_t ac_vlc_descA_syms[110] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC6,
+ 0xFC5, 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB6, 0xFB5, 0xFB3,
+ 0xFB2, 0xFB1, 0xFB0, 0xFA6, 0xFA5, 0xFA3, 0xFA1, 0xFA0,
+ 0xF96, 0xF93, 0xF91, 0xF90, 0xF83, 0xF81, 0xF80, 0xF73,
+ 0xF71, 0xF70, 0xF61, 0xF60, 0xF51, 0xF50, 0xF41, 0xF40,
+ 0xF31, 0x0E1, 0x0D1, 0x0C1, 0x0C0, 0x0B1, 0x0B0, 0x0A1,
+ 0x0A0, 0x093, 0x091, 0x090, 0x083, 0x081, 0x080, 0x073,
+ 0x071, 0x070, 0x063, 0x061, 0x060, 0x055, 0x053, 0x051,
+ 0x050, 0x045, 0x044, 0x043, 0x042, 0x041, 0x040, 0x036,
+ 0x035, 0x034, 0x033, 0x032, 0x031, 0x030, 0x026, 0x025,
+ 0x024, 0x023, 0x022, 0x021, 0x020, 0x018, 0x017, 0x016,
+ 0x015, 0x014, 0x013, 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_descA_codes[110] = {
+ 0x002A, 0x04C5, 0x02A3, 0x004A, 0x0015, 0x0005, 0x0003, 0x0013,
+ 0x000D, 0x0007, 0x0171, 0x0032, 0x0371, 0x0076, 0x0042, 0x0011,
+ 0x000E, 0x00AA, 0x04D5, 0x03A3, 0x06A3, 0x0062, 0x001A, 0x06D5,
+ 0x07F2, 0x0223, 0x0CD5, 0x006A, 0x0001, 0x00F6, 0x0623, 0x03F2,
+ 0x07EA, 0x01F1, 0x0021, 0x03D5, 0x08C2, 0x07F6, 0x00F2, 0x00E3,
+ 0x0FEA, 0x02C5, 0x01AA, 0x0082, 0x04A3, 0x00B6, 0x0071, 0x03B2,
+ 0x0023, 0x01B6, 0x08A3, 0x0002, 0x0BB2, 0x00C5, 0x02EA, 0x0C23,
+ 0x0FF6, 0x0423, 0x07B2, 0x01C5, 0x07D5, 0x01EA, 0x06EA, 0x02C2,
+ 0x01F6, 0x01D5, 0x01B2, 0x00B2, 0x04F1, 0x03EA, 0x01A2, 0x02A2,
+ 0x02D5, 0x0123, 0x00D5, 0x01F2, 0x0055, 0x05B2, 0x04C2, 0x0102,
+ 0x0061, 0x05D5, 0x00C2, 0x00F1, 0x00A3, 0x0045, 0x0016, 0x01A3,
+ 0x01C2, 0x08D5, 0x03C5, 0x00EA, 0x000A, 0x0006, 0x00A2, 0x0036,
+ 0x02F1, 0x0072, 0x0022, 0x0025, 0x0009, 0x03F6, 0x0AA3, 0x0063,
+ 0x0012, 0x0031, 0x0035, 0x0033, 0x000B, 0x0000,
+};
+
+static const uint8_t ac_vlc_descA_bits[110] = {
+ 8, 11, 12, 7, 7, 7, 6, 6,
+ 4, 3, 10, 8, 10, 8, 8, 6,
+ 4, 9, 12, 10, 11, 7, 5, 11,
+ 11, 11, 12, 8, 6, 9, 11, 11,
+ 12, 9, 7, 11, 12, 12, 9, 8,
+ 12, 10, 9, 8, 11, 9, 9, 12,
+ 11, 9, 12, 9, 12, 11, 11, 12,
+ 12, 12, 11, 10, 11, 10, 11, 10,
+ 10, 11, 11, 9, 11, 11, 9, 10,
+ 11, 9, 12, 10, 8, 11, 11, 9,
+ 7, 11, 12, 11, 12, 8, 6, 10,
+ 9, 12, 10, 10, 7, 5, 10, 8,
+ 10, 8, 8, 6, 4, 11, 12, 8,
+ 6, 7, 6, 6, 4, 2,
+};
+
+static const uint16_t ac_vlc_descB_syms[101] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC6,
+ 0xFC5, 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB6, 0xFB5, 0xFB3,
+ 0xFB1, 0xFB0, 0xFA6, 0xFA3, 0xFA1, 0xFA0, 0xF93, 0xF91,
+ 0xF90, 0xF83, 0xF81, 0xF80, 0xF71, 0xF70, 0xF61, 0xF60,
+ 0xF51, 0xF50, 0xF41, 0x0F1, 0x0D1, 0x0C1, 0x0B1, 0x0B0,
+ 0x0A1, 0x0A0, 0x091, 0x090, 0x083, 0x081, 0x080, 0x073,
+ 0x071, 0x070, 0x063, 0x061, 0x060, 0x055, 0x053, 0x051,
+ 0x050, 0x045, 0x043, 0x042, 0x041, 0x040, 0x036, 0x035,
+ 0x034, 0x033, 0x032, 0x031, 0x030, 0x026, 0x025, 0x024,
+ 0x023, 0x022, 0x021, 0x020, 0x018, 0x017, 0x016, 0x015,
+ 0x014, 0x013, 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_descB_codes[101] = {
+ 0x00EE, 0x03A5, 0x0B73, 0x004E, 0x0035, 0x0015, 0x0023, 0x0013,
+ 0x000D, 0x0007, 0x0673, 0x01F3, 0x02FE, 0x0096, 0x0133, 0x001E,
+ 0x0001, 0x0116, 0x00F5, 0x03F5, 0x0473, 0x0052, 0x001A, 0x01D5,
+ 0x0025, 0x0073, 0x0633, 0x0086, 0x0036, 0x012E, 0x0155, 0x0006,
+ 0x0055, 0x000E, 0x0106, 0x023E, 0x0192, 0x0075, 0x0173, 0x01AE,
+ 0x00D5, 0x08F5, 0x002E, 0x01FE, 0x0406, 0x00AE, 0x0E3E, 0x0206,
+ 0x013E, 0x0373, 0x0D55, 0x063E, 0x0E33, 0x033E, 0x01F5, 0x0273,
+ 0x003E, 0x06A5, 0x0092, 0x03D5, 0x04F5, 0x053E, 0x0016, 0x00FE,
+ 0x07A5, 0x0125, 0x0506, 0x0292, 0x00BE, 0x0425, 0x0F73, 0x02F5,
+ 0x0056, 0x0233, 0x02A5, 0x0C25, 0x007E, 0x0026, 0x0355, 0x0033,
+ 0x0555, 0x01A5, 0x0306, 0x0046, 0x000A, 0x0225, 0x006E, 0x00A5,
+ 0x0012, 0x00F3, 0x0005, 0x0009, 0x073E, 0x0773, 0x00B3, 0x0032,
+ 0x0065, 0x0003, 0x0002, 0x000B, 0x0000,
+};
+
+static const uint8_t ac_vlc_descB_bits[101] = {
+ 8, 11, 12, 7, 7, 7, 6, 6,
+ 4, 3, 11, 9, 10, 8, 9, 6,
+ 4, 9, 12, 10, 11, 7, 5, 10,
+ 11, 11, 12, 8, 6, 9, 11, 11,
+ 9, 7, 11, 11, 9, 8, 10, 9,
+ 9, 12, 9, 9, 11, 9, 12, 10,
+ 11, 12, 12, 12, 12, 11, 10, 11,
+ 10, 11, 10, 10, 11, 11, 9, 10,
+ 11, 9, 11, 10, 8, 12, 12, 10,
+ 7, 11, 11, 12, 8, 6, 10, 10,
+ 12, 10, 10, 7, 5, 10, 8, 10,
+ 8, 9, 6, 4, 11, 12, 8, 6,
+ 7, 6, 5, 4, 2,
+};
+
+static const uint16_t ac_vlc_descC_syms[96] = {
+ 0x1000, 0xFF8, 0xFF7, 0xFF6, 0xFF5, 0xFF4, 0xFF3, 0xFF2,
+ 0xFF1, 0xFF0, 0xFE6, 0xFE5, 0xFE4, 0xFE3, 0xFE2, 0xFE1,
+ 0xFE0, 0xFD5, 0xFD4, 0xFD3, 0xFD2, 0xFD1, 0xFD0, 0xFC6,
+ 0xFC5, 0xFC3, 0xFC2, 0xFC1, 0xFC0, 0xFB6, 0xFB5, 0xFB3,
+ 0xFB1, 0xFB0, 0xFA6, 0xFA3, 0xFA1, 0xFA0, 0xF93, 0xF91,
+ 0xF90, 0xF81, 0xF80, 0xF71, 0xF70, 0xF61, 0xF60, 0xF51,
+ 0x0E1, 0x0C1, 0x0B1, 0x0A1, 0x0A0, 0x091, 0x090, 0x083,
+ 0x081, 0x080, 0x073, 0x071, 0x070, 0x063, 0x061, 0x060,
+ 0x055, 0x053, 0x051, 0x050, 0x045, 0x043, 0x042, 0x041,
+ 0x040, 0x036, 0x035, 0x034, 0x033, 0x032, 0x031, 0x030,
+ 0x026, 0x025, 0x024, 0x023, 0x022, 0x021, 0x020, 0x018,
+ 0x017, 0x016, 0x015, 0x014, 0x013, 0x012, 0x011, 0x010,
+};
+
+static const uint16_t ac_vlc_descC_codes[96] = {
+ 0x00DE, 0x072E, 0x0576, 0x006E, 0x0075, 0x0055, 0x0013, 0x0033,
+ 0x000D, 0x0007, 0x07D2, 0x0052, 0x0065, 0x00CE, 0x0183, 0x003E,
+ 0x0001, 0x002E, 0x0F35, 0x0003, 0x0243, 0x001A, 0x0006, 0x01A5,
+ 0x0043, 0x0012, 0x0E43, 0x00B6, 0x0016, 0x0135, 0x0176, 0x0643,
+ 0x0035, 0x001E, 0x0735, 0x0283, 0x0125, 0x00AE, 0x00D2, 0x0165,
+ 0x0103, 0x0603, 0x00E5, 0x0C43, 0x02B5, 0x04A5, 0x00A5, 0x0443,
+ 0x0265, 0x0476, 0x0212, 0x0112, 0x0376, 0x012E, 0x02D2, 0x0083,
+ 0x0483, 0x015E, 0x06A5, 0x0335, 0x005E, 0x0025, 0x01D2, 0x00F6,
+ 0x03D2, 0x032E, 0x03B5, 0x005A, 0x0203, 0x02A5, 0x0BD2, 0x004E,
+ 0x0032, 0x01B5, 0x00B5, 0x0A65, 0x0225, 0x0276, 0x000E, 0x000A,
+ 0x03E5, 0x0143, 0x01E5, 0x0036, 0x0092, 0x0005, 0x0009, 0x0665,
+ 0x0076, 0x00C3, 0x003A, 0x0015, 0x0023, 0x0002, 0x000B, 0x0000,
+};
+
+static const uint8_t ac_vlc_descC_bits[96] = {
+ 8, 11, 11, 7, 7, 7, 6, 6,
+ 4, 3, 11, 8, 10, 8, 9, 6,
+ 4, 9, 12, 10, 11, 7, 5, 9,
+ 11, 10, 12, 8, 6, 10, 11, 12,
+ 9, 7, 12, 10, 9, 8, 10, 9,
+ 9, 11, 9, 12, 10, 11, 11, 12,
+ 12, 11, 10, 9, 10, 10, 10, 11,
+ 11, 9, 11, 11, 9, 10, 10, 8,
+ 12, 11, 10, 7, 11, 11, 12, 8,
+ 6, 10, 10, 12, 10, 10, 7, 5,
+ 10, 9, 10, 8, 8, 6, 4, 11,
+ 11, 8, 6, 7, 6, 5, 4, 2,
+};
+
+static const int tscc2_ac_vlc_sizes[NUM_VLC_SETS] = {
+ 172, 169, 165, 162, 131, 132, 130, 125, 121, 114, 110, 101, 96
+};
+
+static const uint16_t *tscc2_ac_vlc_syms[NUM_VLC_SETS] = {
+ ac_vlc_desc0_syms, ac_vlc_desc1_syms, ac_vlc_desc2_syms, ac_vlc_desc3_syms,
+ ac_vlc_desc4_syms, ac_vlc_desc5_syms, ac_vlc_desc6_syms, ac_vlc_desc7_syms,
+ ac_vlc_desc8_syms, ac_vlc_desc9_syms, ac_vlc_descA_syms, ac_vlc_descB_syms,
+ ac_vlc_descC_syms,
+};
+
+static const uint16_t *tscc2_ac_vlc_codes[NUM_VLC_SETS] = {
+ ac_vlc_desc0_codes, ac_vlc_desc1_codes, ac_vlc_desc2_codes,
+ ac_vlc_desc3_codes, ac_vlc_desc4_codes, ac_vlc_desc5_codes,
+ ac_vlc_desc6_codes, ac_vlc_desc7_codes, ac_vlc_desc8_codes,
+ ac_vlc_desc9_codes, ac_vlc_descA_codes, ac_vlc_descB_codes,
+ ac_vlc_descC_codes,
+};
+
+static const uint8_t *tscc2_ac_vlc_bits[NUM_VLC_SETS] = {
+ ac_vlc_desc0_bits, ac_vlc_desc1_bits, ac_vlc_desc2_bits, ac_vlc_desc3_bits,
+ ac_vlc_desc4_bits, ac_vlc_desc5_bits, ac_vlc_desc6_bits, ac_vlc_desc7_bits,
+ ac_vlc_desc8_bits, ac_vlc_desc9_bits, ac_vlc_descA_bits, ac_vlc_descB_bits,
+ ac_vlc_descC_bits,
+};
+
+#endif /* AVCODEC_TSCC2_DATA_H */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 64c1dc6b1b..c5136078e8 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -27,7 +27,7 @@
*/
#define LIBAVCODEC_VERSION_MAJOR 54
-#define LIBAVCODEC_VERSION_MINOR 33
+#define LIBAVCODEC_VERSION_MINOR 34
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavformat/riff.c b/libavformat/riff.c
index fe8b49fc28..f6b2177796 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -310,6 +310,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_EXR, MKTAG('e', 'x', 'r', ' ') },
{ CODEC_ID_MSS1, MKTAG('M', 'S', 'S', '1') },
{ CODEC_ID_MSA1, MKTAG('M', 'S', 'A', '1') },
+ { CODEC_ID_TSCC2, MKTAG('T', 'S', 'C', '2') },
{ CODEC_ID_NONE, 0 }
};
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index c3b40aad86..abfdca80db 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -63,7 +63,8 @@
#define RTSP_FLAG_OPTS(name, longname) \
{ name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC, "rtsp_flags" }, \
- { "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }
+ { "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }, \
+ { "listen", "Wait for incoming connections", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_LISTEN}, 0, 0, DEC, "rtsp_flags" }
#define RTSP_MEDIATYPE_OPTS(name, longname) \
{ name, longname, OFFSET(media_type_mask), AV_OPT_TYPE_FLAGS, { (1 << (AVMEDIA_TYPE_DATA+1)) - 1 }, INT_MIN, INT_MAX, DEC, "allowed_media_types" }, \
@@ -83,6 +84,7 @@ const AVOption ff_rtsp_options[] = {
RTSP_MEDIATYPE_OPTS("allowed_media_types", "Media types to accept from the server"),
{ "min_port", "Minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC },
{ "max_port", "Maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC },
+ { "timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies flag listen", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {-1}, INT_MIN, INT_MAX, DEC },
{ NULL },
};
@@ -595,7 +597,7 @@ void ff_rtsp_close_streams(AVFormatContext *s)
av_free(rt->recvbuf);
}
-static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
+int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
{
RTSPState *rt = s->priv_data;
AVStream *st = NULL;
@@ -749,6 +751,14 @@ static void rtsp_parse_transport(RTSPMessageHeader *reply, const char *p)
get_word_sep(buf, sizeof(buf), ";,", &p);
av_strlcpy(th->source, buf, sizeof(th->source));
}
+ } else if (!strcmp(parameter, "mode")) {
+ if (*p == '=') {
+ p++;
+ get_word_sep(buf, sizeof(buf), ";, ", &p);
+ if (!strcmp(buf, "record") ||
+ !strcmp(buf, "receive"))
+ th->mode_record = 1;
+ }
}
while (*p != ';' && *p != '\0' && *p != ',')
@@ -1389,7 +1399,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
}
}
- if ((err = rtsp_open_transport_ctx(s, rtsp_st)))
+ if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
@@ -1701,14 +1711,24 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
}
#if CONFIG_RTSP_DEMUXER
if (tcp_fd != -1 && p[0].revents & POLLIN) {
- RTSPMessageHeader reply;
-
- ret = ff_rtsp_read_reply(s, &reply, NULL, 0, NULL);
- if (ret < 0)
- return ret;
- /* XXX: parse message */
- if (rt->state != RTSP_STATE_STREAMING)
- return 0;
+ if (rt->rtsp_flags & RTSP_FLAG_LISTEN) {
+ if (rt->state == RTSP_STATE_STREAMING) {
+ if (!ff_rtsp_parse_streaming_commands(s))
+ return AVERROR_EOF;
+ else
+ av_log(s, AV_LOG_WARNING,
+ "Unable to answer to TEARDOWN\n");
+ } else
+ return 0;
+ } else {
+ RTSPMessageHeader reply;
+ ret = ff_rtsp_read_reply(s, &reply, NULL, 0, NULL);
+ if (ret < 0)
+ return ret;
+ /* XXX: parse message */
+ if (rt->state != RTSP_STATE_STREAMING)
+ return 0;
+ }
}
#endif
} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
@@ -1912,7 +1932,7 @@ static int sdp_read_header(AVFormatContext *s)
err = AVERROR_INVALIDDATA;
goto fail;
}
- if ((err = rtsp_open_transport_ctx(s, rtsp_st)))
+ if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
return 0;
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 9bb50cf07c..6d9680161e 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -102,6 +102,9 @@ typedef struct RTSPTransportField {
* packets will be allowed to make before being discarded. */
int ttl;
+ /** transport set to record data */
+ int mode_record;
+
struct sockaddr_storage destination; /**< destination IP address */
char source[INET6_ADDRSTRLEN + 1]; /**< source IP address */
@@ -369,11 +372,17 @@ typedef struct RTSPState {
* Minimum and maximum local UDP ports.
*/
int rtp_port_min, rtp_port_max;
+
+ /**
+ * Timeout to wait for incoming connections.
+ */
+ int initial_timeout;
} RTSPState;
#define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets -
receive packets only from the right
source address and port. */
+#define RTSP_FLAG_LISTEN 0x2 /**< Wait for incoming connections. */
/**
* Describe a single stream, as identified by a single m= line block in the
@@ -526,6 +535,12 @@ int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply);
int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr);
/**
+ * Parse RTSP commands (OPTIONS, PAUSE and TEARDOWN) during streaming in
+ * listen mode.
+ */
+int ff_rtsp_parse_streaming_commands(AVFormatContext *s);
+
+/**
* Parse an SDP description of streams by populating an RTSPState struct
* within the AVFormatContext; also allocate the RTP streams and the
* pollfd array used for UDP streams.
@@ -558,6 +573,11 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
*/
void ff_rtsp_undo_setup(AVFormatContext *s);
+/**
+ * Open RTSP transport context.
+ */
+int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st);
+
extern const AVOption ff_rtsp_options[];
#endif /* AVFORMAT_RTSP_H */
diff --git a/libavformat/rtspcodes.h b/libavformat/rtspcodes.h
index 9ee96bfcd0..4245e48642 100644
--- a/libavformat/rtspcodes.h
+++ b/libavformat/rtspcodes.h
@@ -37,4 +37,18 @@ RTSP_STATUS_SERVICE =503, /**< Service Unavailable */
RTSP_STATUS_VERSION =505, /**< RTSP Version not supported */
};
+enum RTSPMethod {
+ DESCRIBE,
+ ANNOUNCE,
+ OPTIONS,
+ SETUP,
+ PLAY,
+ PAUSE,
+ TEARDOWN,
+ GET_PARAMETER,
+ SET_PARAMETER,
+ REDIRECT,
+ RECORD,
+ UNKNOWN = -1,
+};
#endif /* AVFORMAT_RTSPCODES_H */
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 9c7df96a8f..d34da53ded 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -22,6 +22,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
+#include "libavutil/random_seed.h"
#include "avformat.h"
#include "internal.h"
@@ -31,6 +32,462 @@
#include "rdt.h"
#include "url.h"
+static const struct RTSPStatusMessage {
+ enum RTSPStatusCode code;
+ const char *message;
+} status_messages[] = {
+ { RTSP_STATUS_OK, "OK" },
+ { RTSP_STATUS_METHOD, "Method Not Allowed" },
+ { RTSP_STATUS_BANDWIDTH, "Not Enough Bandwidth" },
+ { RTSP_STATUS_SESSION, "Session Not Found" },
+ { RTSP_STATUS_STATE, "Method Not Valid in This State" },
+ { RTSP_STATUS_AGGREGATE, "Aggregate operation not allowed" },
+ { RTSP_STATUS_ONLY_AGGREGATE, "Only aggregate operation allowed" },
+ { RTSP_STATUS_TRANSPORT, "Unsupported transport" },
+ { RTSP_STATUS_INTERNAL, "Internal Server Error" },
+ { RTSP_STATUS_SERVICE, "Service Unavailable" },
+ { RTSP_STATUS_VERSION, "RTSP Version not supported" },
+ { 0, "NULL" }
+};
+
+static int rtsp_read_close(AVFormatContext *s)
+{
+ RTSPState *rt = s->priv_data;
+
+ if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN))
+ ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
+
+ ff_rtsp_close_streams(s);
+ ff_rtsp_close_connections(s);
+ ff_network_close();
+ rt->real_setup = NULL;
+ av_freep(&rt->real_setup_cache);
+ return 0;
+}
+
+static inline int read_line(AVFormatContext *s, char *rbuf, const int rbufsize,
+ int *rbuflen)
+{
+ RTSPState *rt = s->priv_data;
+ int idx = 0;
+ int ret = 0;
+ *rbuflen = 0;
+
+ do {
+ ret = ffurl_read_complete(rt->rtsp_hd, rbuf + idx, 1);
+ if (ret < 0)
+ return ret;
+ if (rbuf[idx] == '\r') {
+ /* Ignore */
+ } else if (rbuf[idx] == '\n') {
+ rbuf[idx] = '\0';
+ *rbuflen = idx;
+ return 0;
+ } else
+ idx++;
+ } while (idx < rbufsize);
+ av_log(s, AV_LOG_ERROR, "Message too long\n");
+ return AVERROR(EIO);
+}
+
+static int rtsp_send_reply(AVFormatContext *s, enum RTSPStatusCode code,
+ const char *extracontent, uint16_t seq)
+{
+ RTSPState *rt = s->priv_data;
+ char message[4096];
+ int index = 0;
+ while (status_messages[index].code) {
+ if (status_messages[index].code == code) {
+ snprintf(message, sizeof(message), "RTSP/1.0 %d %s\r\n",
+ code, status_messages[index].message);
+ break;
+ }
+ index++;
+ }
+ if (!status_messages[index].code)
+ return AVERROR(EINVAL);
+ av_strlcatf(message, sizeof(message), "CSeq: %d\r\n", seq);
+ av_strlcatf(message, sizeof(message), "Server: %s\r\n", LIBAVFORMAT_IDENT);
+ if (extracontent)
+ av_strlcat(message, extracontent, sizeof(message));
+ av_strlcat(message, "\r\n", sizeof(message));
+ av_dlog(s, "Sending response:\n%s", message);
+ ffurl_write(rt->rtsp_hd, message, strlen(message));
+
+ return 0;
+}
+
+static inline int check_sessionid(AVFormatContext *s,
+ RTSPMessageHeader *request)
+{
+ RTSPState *rt = s->priv_data;
+ unsigned char *session_id = rt->session_id;
+ if (!session_id[0]) {
+ av_log(s, AV_LOG_WARNING, "There is no session-id at the moment\n");
+ return 0;
+ }
+ if (strcmp(session_id, request->session_id)) {
+ av_log(s, AV_LOG_ERROR, "Unexpected session-id %s\n",
+ request->session_id);
+ rtsp_send_reply(s, RTSP_STATUS_SESSION, NULL, request->seq);
+ return AVERROR_STREAM_NOT_FOUND;
+ }
+ return 0;
+}
+
+static inline int rtsp_read_request(AVFormatContext *s,
+ RTSPMessageHeader *request,
+ const char *method)
+{
+ RTSPState *rt = s->priv_data;
+ char rbuf[1024];
+ int rbuflen, ret;
+ do {
+ ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
+ if (ret)
+ return ret;
+ if (rbuflen > 1) {
+ av_dlog(s, "Parsing[%d]: %s\n", rbuflen, rbuf);
+ ff_rtsp_parse_line(request, rbuf, rt, method);
+ }
+ } while (rbuflen > 0);
+ if (request->seq != rt->seq + 1) {
+ av_log(s, AV_LOG_ERROR, "Unexpected Sequence number %d\n",
+ request->seq);
+ return AVERROR(EINVAL);
+ }
+ if (rt->session_id[0] && strcmp(method, "OPTIONS")) {
+ ret = check_sessionid(s, request);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int rtsp_read_announce(AVFormatContext *s)
+{
+ RTSPState *rt = s->priv_data;
+ RTSPMessageHeader request = { 0 };
+ char sdp[4096];
+ int ret;
+
+ ret = rtsp_read_request(s, &request, "ANNOUNCE");
+ if (ret)
+ return ret;
+ rt->seq++;
+ if (strcmp(request.content_type, "application/sdp")) {
+ av_log(s, AV_LOG_ERROR, "Unexpected content type %s\n",
+ request.content_type);
+ rtsp_send_reply(s, RTSP_STATUS_SERVICE, NULL, request.seq);
+ return AVERROR_OPTION_NOT_FOUND;
+ }
+ if (request.content_length && request.content_length < sizeof(sdp) - 1) {
+ /* Read SDP */
+ if (ffurl_read_complete(rt->rtsp_hd, sdp, request.content_length)
+ < request.content_length) {
+ av_log(s, AV_LOG_ERROR,
+ "Unable to get complete SDP Description in ANNOUNCE\n");
+ rtsp_send_reply(s, RTSP_STATUS_INTERNAL, NULL, request.seq);
+ return AVERROR(EIO);
+ }
+ sdp[request.content_length] = '\0';
+ av_log(s, AV_LOG_VERBOSE, "SDP: %s\n", sdp);
+ ret = ff_sdp_parse(s, sdp);
+ if (ret)
+ return ret;
+ rtsp_send_reply(s, RTSP_STATUS_OK, NULL, request.seq);
+ return 0;
+ }
+ av_log(s, AV_LOG_ERROR,
+ "Content-Length header value exceeds sdp allocated buffer (4KB)\n");
+ rtsp_send_reply(s, RTSP_STATUS_INTERNAL,
+ "Content-Length exceeds buffer size", request.seq);
+ return AVERROR(EIO);
+}
+
+static int rtsp_read_options(AVFormatContext *s)
+{
+ RTSPState *rt = s->priv_data;
+ RTSPMessageHeader request = { 0 };
+ int ret = 0;
+
+ /* Parsing headers */
+ ret = rtsp_read_request(s, &request, "OPTIONS");
+ if (ret)
+ return ret;
+ rt->seq++;
+ /* Send Reply */
+ rtsp_send_reply(s, RTSP_STATUS_OK,
+ "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, RECORD\r\n",
+ request.seq);
+ return 0;
+}
+
+static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl)
+{
+ RTSPState *rt = s->priv_data;
+ RTSPMessageHeader request = { 0 };
+ int ret = 0;
+ char url[1024];
+ RTSPStream *rtsp_st;
+ char responseheaders[1024];
+ int localport = -1;
+ int transportidx = 0;
+ int streamid = 0;
+
+ ret = rtsp_read_request(s, &request, "SETUP");
+ if (ret)
+ return ret;
+ rt->seq++;
+ if (!request.nb_transports) {
+ av_log(s, AV_LOG_ERROR, "No transport defined in SETUP\n");
+ return AVERROR_INVALIDDATA;
+ }
+ for (transportidx = 0; transportidx < request.nb_transports;
+ transportidx++) {
+ if (!request.transports[transportidx].mode_record ||
+ (request.transports[transportidx].lower_transport !=
+ RTSP_LOWER_TRANSPORT_UDP &&
+ request.transports[transportidx].lower_transport !=
+ RTSP_LOWER_TRANSPORT_TCP)) {
+ av_log(s, AV_LOG_ERROR, "mode=record/receive not set or transport"
+ " protocol not supported (yet)\n");
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ if (request.nb_transports > 1)
+ av_log(s, AV_LOG_WARNING, "More than one transport not supported, "
+ "using first of all\n");
+ for (streamid = 0; streamid < rt->nb_rtsp_streams; streamid++) {
+ if (!strcmp(rt->rtsp_streams[streamid]->control_url,
+ controlurl))
+ break;
+ }
+ if (streamid == rt->nb_rtsp_streams) {
+ av_log(s, AV_LOG_ERROR, "Unable to find requested track\n");
+ return AVERROR_STREAM_NOT_FOUND;
+ }
+ rtsp_st = rt->rtsp_streams[streamid];
+ localport = rt->rtp_port_min;
+
+ if (request.transports[0].lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
+ rt->lower_transport = RTSP_LOWER_TRANSPORT_TCP;
+ if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) {
+ rtsp_send_reply(s, RTSP_STATUS_TRANSPORT, NULL, request.seq);
+ return ret;
+ }
+ rtsp_st->interleaved_min = request.transports[0].interleaved_min;
+ rtsp_st->interleaved_max = request.transports[0].interleaved_max;
+ snprintf(responseheaders, sizeof(responseheaders), "Transport: "
+ "RTP/AVP/TCP;unicast;mode=receive;interleaved=%d-%d"
+ "\r\n", request.transports[0].interleaved_min,
+ request.transports[0].interleaved_max);
+ } else {
+ do {
+ ff_url_join(url, sizeof(url), "rtp", NULL, host, localport, NULL);
+ av_dlog(s, "Opening: %s", url);
+ ret = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
+ &s->interrupt_callback, NULL);
+ if (ret)
+ localport += 2;
+ } while (ret || localport > rt->rtp_port_max);
+ if (localport > rt->rtp_port_max) {
+ rtsp_send_reply(s, RTSP_STATUS_TRANSPORT, NULL, request.seq);
+ return ret;
+ }
+
+ av_dlog(s, "Listening on: %d",
+ ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle));
+ if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) {
+ rtsp_send_reply(s, RTSP_STATUS_TRANSPORT, NULL, request.seq);
+ return ret;
+ }
+
+ localport = ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle);
+ snprintf(responseheaders, sizeof(responseheaders), "Transport: "
+ "RTP/AVP/UDP;unicast;mode=receive;source=%s;"
+ "client_port=%d-%d;server_port=%d-%d\r\n",
+ host, request.transports[0].client_port_min,
+ request.transports[0].client_port_max, localport,
+ localport + 1);
+ }
+
+ /* Establish sessionid if not previously set */
+ /* Put this in a function? */
+ /* RFC 2326: session id must be at least 8 digits */
+ while (strlen(rt->session_id) < 8)
+ av_strlcatf(rt->session_id, 512, "%u", av_get_random_seed());
+
+ av_strlcatf(responseheaders, sizeof(responseheaders), "Session: %s\r\n",
+ rt->session_id);
+ /* Send Reply */
+ rtsp_send_reply(s, RTSP_STATUS_OK, responseheaders, request.seq);
+
+ rt->state = RTSP_STATE_PAUSED;
+ return 0;
+}
+
+static int rtsp_read_record(AVFormatContext *s)
+{
+ RTSPState *rt = s->priv_data;
+ RTSPMessageHeader request = { 0 };
+ int ret = 0;
+ char responseheaders[1024];
+
+ ret = rtsp_read_request(s, &request, "RECORD");
+ if (ret)
+ return ret;
+ ret = check_sessionid(s, &request);
+ if (ret)
+ return ret;
+ rt->seq++;
+ snprintf(responseheaders, sizeof(responseheaders), "Session: %s\r\n",
+ rt->session_id);
+ rtsp_send_reply(s, RTSP_STATUS_OK, responseheaders, request.seq);
+
+ rt->state = RTSP_STATE_STREAMING;
+ return 0;
+}
+
+static inline int parse_command_line(AVFormatContext *s, const char *line,
+ int linelen, char *uri, int urisize,
+ char *method, int methodsize,
+ enum RTSPMethod *methodcode)
+{
+ RTSPState *rt = s->priv_data;
+ const char *linept, *searchlinept;
+ linept = strchr(line, ' ');
+ if (linept - line > methodsize - 1) {
+ av_log(s, AV_LOG_ERROR, "Method string too long\n");
+ return AVERROR(EIO);
+ }
+ memcpy(method, line, linept - line);
+ method[linept - line] = '\0';
+ linept++;
+ if (!strcmp(method, "ANNOUNCE"))
+ *methodcode = ANNOUNCE;
+ else if (!strcmp(method, "OPTIONS"))
+ *methodcode = OPTIONS;
+ else if (!strcmp(method, "RECORD"))
+ *methodcode = RECORD;
+ else if (!strcmp(method, "SETUP"))
+ *methodcode = SETUP;
+ else if (!strcmp(method, "PAUSE"))
+ *methodcode = PAUSE;
+ else if (!strcmp(method, "TEARDOWN"))
+ *methodcode = TEARDOWN;
+ else
+ *methodcode = UNKNOWN;
+ /* Check method with the state */
+ if (rt->state == RTSP_STATE_IDLE) {
+ if ((*methodcode != ANNOUNCE) && (*methodcode != OPTIONS)) {
+ av_log(s, AV_LOG_ERROR, "Unexpected command in Idle State %s\n",
+ line);
+ return AVERROR_PROTOCOL_NOT_FOUND;
+ }
+ } else if (rt->state == RTSP_STATE_PAUSED) {
+ if ((*methodcode != OPTIONS) && (*methodcode != RECORD)
+ && (*methodcode != SETUP)) {
+ av_log(s, AV_LOG_ERROR, "Unexpected command in Paused State %s\n",
+ line);
+ return AVERROR_PROTOCOL_NOT_FOUND;
+ }
+ } else if (rt->state == RTSP_STATE_STREAMING) {
+ if ((*methodcode != PAUSE) && (*methodcode != OPTIONS)
+ && (*methodcode != TEARDOWN)) {
+ av_log(s, AV_LOG_ERROR, "Unexpected command in Streaming State"
+ " %s\n", line);
+ return AVERROR_PROTOCOL_NOT_FOUND;
+ }
+ } else {
+ av_log(s, AV_LOG_ERROR, "Unexpected State [%d]\n", rt->state);
+ return AVERROR_BUG;
+ }
+
+ searchlinept = strchr(linept, ' ');
+ if (searchlinept == NULL) {
+ av_log(s, AV_LOG_ERROR, "Error parsing message URI\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (searchlinept - linept > urisize - 1) {
+ av_log(s, AV_LOG_ERROR, "uri string length exceeded buffer size\n");
+ return AVERROR(EIO);
+ }
+ memcpy(uri, linept, searchlinept - linept);
+ uri[searchlinept - linept] = '\0';
+ if (strcmp(rt->control_uri, uri)) {
+ char host[128], path[512], auth[128];
+ int port;
+ char ctl_host[128], ctl_path[512], ctl_auth[128];
+ int ctl_port;
+ av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port,
+ path, sizeof(path), uri);
+ av_url_split(NULL, 0, ctl_auth, sizeof(ctl_auth), ctl_host,
+ sizeof(ctl_host), &ctl_port, ctl_path, sizeof(ctl_path),
+ rt->control_uri);
+ if (strcmp(host, ctl_host))
+ av_log(s, AV_LOG_INFO, "Host %s differs from expected %s\n",
+ host, ctl_host);
+ if (strcmp(path, ctl_path) && *methodcode != SETUP)
+ av_log(s, AV_LOG_WARNING, "WARNING: Path %s differs from expected"
+ " %s\n", path, ctl_path);
+ if (*methodcode == ANNOUNCE) {
+ av_log(s, AV_LOG_INFO,
+ "Updating control URI to %s\n", uri);
+ strcpy(rt->control_uri, uri);
+ }
+ }
+
+ linept = searchlinept + 1;
+ if (!av_strstart(linept, "RTSP/1.0", NULL)) {
+ av_log(s, AV_LOG_ERROR, "Error parsing protocol or version\n");
+ return AVERROR_PROTOCOL_NOT_FOUND;
+ }
+ return 0;
+}
+
+int ff_rtsp_parse_streaming_commands(AVFormatContext *s)
+{
+ RTSPState *rt = s->priv_data;
+ unsigned char rbuf[4096];
+ unsigned char method[10];
+ char uri[500];
+ int ret;
+ int rbuflen = 0;
+ RTSPMessageHeader request = { 0 };
+ enum RTSPMethod methodcode;
+
+ ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
+ if (ret < 0)
+ return ret;
+ ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method,
+ sizeof(method), &methodcode);
+ if (ret) {
+ av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n");
+ return ret;
+ }
+
+ ret = rtsp_read_request(s, &request, method);
+ if (ret)
+ return ret;
+ rt->seq++;
+ if (methodcode == PAUSE) {
+ rt->state = RTSP_STATE_PAUSED;
+ ret = rtsp_send_reply(s, RTSP_STATUS_OK, NULL , request.seq);
+ // TODO: Missing date header in response
+ } else if (methodcode == OPTIONS) {
+ ret = rtsp_send_reply(s, RTSP_STATUS_OK,
+ "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, "
+ "RECORD\r\n", request.seq);
+ } else if (methodcode == TEARDOWN) {
+ rt->state = RTSP_STATE_IDLE;
+ ret = rtsp_send_reply(s, RTSP_STATUS_OK, NULL , request.seq);
+ return 0;
+ }
+ return ret;
+}
+
static int rtsp_read_play(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
@@ -143,6 +600,67 @@ int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
return 0;
}
+static int rtsp_listen(AVFormatContext *s)
+{
+ RTSPState *rt = s->priv_data;
+ char host[128], path[512], auth[128];
+ char uri[500];
+ int port;
+ char tcpname[500];
+ unsigned char rbuf[4096];
+ unsigned char method[10];
+ int rbuflen = 0;
+ int ret;
+ enum RTSPMethod methodcode;
+
+ /* extract hostname and port */
+ av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port,
+ path, sizeof(path), s->filename);
+
+ /* ff_url_join. No authorization by now (NULL) */
+ ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL, host,
+ port, "%s", path);
+ /* Create TCP connection */
+ ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port,
+ "?listen&listen_timeout=%d", rt->initial_timeout * 1000);
+
+ if (ret = ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE,
+ &s->interrupt_callback, NULL)) {
+ av_log(s, AV_LOG_ERROR, "Unable to open RTSP for listening\n");
+ return ret;
+ }
+ rt->state = RTSP_STATE_IDLE;
+ rt->rtsp_hd_out = rt->rtsp_hd;
+ for (;;) { /* Wait for incoming RTSP messages */
+ ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
+ if (ret < 0)
+ return ret;
+ ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method,
+ sizeof(method), &methodcode);
+ if (ret) {
+ av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n");
+ return ret;
+ }
+
+ if (methodcode == ANNOUNCE) {
+ ret = rtsp_read_announce(s);
+ rt->state = RTSP_STATE_PAUSED;
+ } else if (methodcode == OPTIONS) {
+ ret = rtsp_read_options(s);
+ } else if (methodcode == RECORD) {
+ ret = rtsp_read_record(s);
+ if (!ret)
+ return 0; // We are ready for streaming
+ } else if (methodcode == SETUP)
+ ret = rtsp_read_setup(s, host, uri);
+ if (ret) {
+ ffurl_close(rt->rtsp_hd);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ return 0;
+}
+
static int rtsp_probe(AVProbeData *p)
{
if (av_strstart(p->filename, "rtsp:", NULL))
@@ -155,23 +673,32 @@ static int rtsp_read_header(AVFormatContext *s)
RTSPState *rt = s->priv_data;
int ret;
- ret = ff_rtsp_connect(s);
- if (ret)
- return ret;
-
- rt->real_setup_cache = !s->nb_streams ? NULL :
- av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
- if (!rt->real_setup_cache && s->nb_streams)
- return AVERROR(ENOMEM);
- rt->real_setup = rt->real_setup_cache + s->nb_streams;
+ if (rt->initial_timeout > 0)
+ rt->rtsp_flags |= RTSP_FLAG_LISTEN;
- if (rt->initial_pause) {
- /* do not start immediately */
+ if (rt->rtsp_flags & RTSP_FLAG_LISTEN) {
+ ret = rtsp_listen(s);
+ if (ret)
+ return ret;
} else {
- if (rtsp_read_play(s) < 0) {
- ff_rtsp_close_streams(s);
- ff_rtsp_close_connections(s);
- return AVERROR_INVALIDDATA;
+ ret = ff_rtsp_connect(s);
+ if (ret)
+ return ret;
+
+ rt->real_setup_cache = !s->nb_streams ? NULL :
+ av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
+ if (!rt->real_setup_cache && s->nb_streams)
+ return AVERROR(ENOMEM);
+ rt->real_setup = rt->real_setup_cache + s->nb_streams;
+
+ if (rt->initial_pause) {
+ /* do not start immediately */
+ } else {
+ if (rtsp_read_play(s) < 0) {
+ ff_rtsp_close_streams(s);
+ ff_rtsp_close_connections(s);
+ return AVERROR_INVALIDDATA;
+ }
}
}
@@ -335,20 +862,22 @@ retry:
}
rt->packets++;
- /* send dummy request to keep TCP connection alive */
- if ((av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 ||
- rt->auth_state.stale) {
- if (rt->server_type == RTSP_SERVER_WMS ||
- (rt->server_type != RTSP_SERVER_REAL &&
- rt->get_parameter_supported)) {
- ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL);
- } else {
- ff_rtsp_send_cmd_async(s, "OPTIONS", "*", NULL);
+ if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) {
+ /* send dummy request to keep TCP connection alive */
+ if ((av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 ||
+ rt->auth_state.stale) {
+ if (rt->server_type == RTSP_SERVER_WMS ||
+ (rt->server_type != RTSP_SERVER_REAL &&
+ rt->get_parameter_supported)) {
+ ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL);
+ } else {
+ ff_rtsp_send_cmd_async(s, "OPTIONS", "*", NULL);
+ }
+ /* The stale flag should be reset when creating the auth response in
+ * ff_rtsp_send_cmd_async, but reset it here just in case we never
+ * called the auth code (if we didn't have any credentials set). */
+ rt->auth_state.stale = 0;
}
- /* The stale flag should be reset when creating the auth response in
- * ff_rtsp_send_cmd_async, but reset it here just in case we never
- * called the auth code (if we didn't have any credentials set). */
- rt->auth_state.stale = 0;
}
return 0;
@@ -380,20 +909,6 @@ static int rtsp_read_seek(AVFormatContext *s, int stream_index,
return 0;
}
-static int rtsp_read_close(AVFormatContext *s)
-{
- RTSPState *rt = s->priv_data;
-
- ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
-
- ff_rtsp_close_streams(s);
- ff_rtsp_close_connections(s);
- ff_network_close();
- rt->real_setup = NULL;
- av_freep(&rt->real_setup_cache);
- return 0;
-}
-
static const AVClass rtsp_demuxer_class = {
.class_name = "RTSP demuxer",
.item_name = av_default_item_name,
diff --git a/libavformat/version.h b/libavformat/version.h
index e0d8061038..215ce13e33 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 54
-#define LIBAVFORMAT_VERSION_MINOR 15
+#define LIBAVFORMAT_VERSION_MINOR 16
#define LIBAVFORMAT_VERSION_MICRO 104
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/libavutil/libm.h b/libavutil/libm.h
index 41b20f64c1..d36420bc9b 100644
--- a/libavutil/libm.h
+++ b/libavutil/libm.h
@@ -90,6 +90,13 @@ static av_always_inline av_const int isnan(float x)
#define log2f(x) ((float)log2(x))
#endif /* HAVE_LOG2F */
+#if !HAVE_RINT
+static inline double rint(double x)
+{
+ return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif /* HAVE_RINT */
+
#if !HAVE_LRINT
static av_always_inline av_const long int lrint(double x)
{