+struct RMStream {
+ AVPacket pkt; ///< place to store merged video frame / reordered audio data
+ int videobufsize; ///< current assembled frame size
+ int videobufpos; ///< position for the next slice in the video buffer
+ int curpic_num; ///< picture number of current frame
+ int cur_slice, slices;
+ int64_t pktpos; ///< first slice position in file
+ /// Audio descrambling matrix parameters
+ int64_t audiotimestamp; ///< Audio packet timestamp
+ int sub_packet_cnt; // Subpacket counter, used while reading
+ int sub_packet_size, sub_packet_h, coded_framesize; ///< Descrambling parameters from container
+ int audio_framesize; /// Audio frame size from container
+ int sub_packet_lengths[16]; /// Length of each subpacket
+};
+
+typedef struct {
+ int nb_packets;
+ int old_format;
+ int current_stream;
+ int remaining_len;
+ int audio_stream_num; ///< Stream number for audio packets
+ int audio_pkt_cnt; ///< Output packet counter
+} RMDemuxContext;
+
+static const AVCodecTag rm_codec_tags[] = {
+ { CODEC_ID_RV10, MKTAG('R','V','1','0') },
+ { CODEC_ID_RV20, MKTAG('R','V','2','0') },
+ { CODEC_ID_RV20, MKTAG('R','V','T','R') },
+ { CODEC_ID_RV30, MKTAG('R','V','3','0') },
+ { CODEC_ID_RV40, MKTAG('R','V','4','0') },
+ { CODEC_ID_AC3, MKTAG('d','n','e','t') },
+ { CODEC_ID_RA_144, MKTAG('l','p','c','J') },
+ { CODEC_ID_RA_288, MKTAG('2','8','_','8') },
+ { CODEC_ID_COOK, MKTAG('c','o','o','k') },
+ { CODEC_ID_ATRAC3, MKTAG('a','t','r','c') },
+ { CODEC_ID_SIPR, MKTAG('s','i','p','r') },
+ { CODEC_ID_AAC, MKTAG('r','a','a','c') },
+ { CODEC_ID_AAC, MKTAG('r','a','c','p') },
+ { CODEC_ID_NONE },
+};
+
+static const unsigned char sipr_swaps[38][2] = {
+ { 0, 63 }, { 1, 22 }, { 2, 44 }, { 3, 90 },
+ { 5, 81 }, { 7, 31 }, { 8, 86 }, { 9, 58 },
+ { 10, 36 }, { 12, 68 }, { 13, 39 }, { 14, 73 },
+ { 15, 53 }, { 16, 69 }, { 17, 57 }, { 19, 88 },
+ { 20, 34 }, { 21, 71 }, { 24, 46 }, { 25, 94 },
+ { 26, 54 }, { 28, 75 }, { 29, 50 }, { 32, 70 },
+ { 33, 92 }, { 35, 74 }, { 38, 85 }, { 40, 56 },
+ { 42, 87 }, { 43, 65 }, { 45, 59 }, { 48, 79 },
+ { 49, 93 }, { 51, 89 }, { 55, 95 }, { 61, 76 },
+ { 67, 83 }, { 77, 80 }
+};
+
+static const unsigned char sipr_subpk_size[4] = { 29, 19, 37, 20 };
+