FFmpeg
Data Structures | Macros | Functions | Variables
siren.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/tx.h"
#include "libavutil/float_dsp.h"
#include "libavutil/mem_internal.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"

Go to the source code of this file.

Data Structures

struct  SirenContext
 

Macros

#define FRAME_SIZE   320
 
#define REGION_SIZE   20
 

Functions

static av_cold int siren_init (AVCodecContext *avctx)
 
static int decode_envelope (SirenContext *s, GetBitContext *gb, int number_of_regions, float *decoder_standard_deviation, int *absolute_region_power_index, int esf_adjustment)
 
static int categorize_regions (int number_of_regions, int number_of_available_bits, int *absolute_region_power_index, int *power_categories, int *category_balance)
 
static int get_dw (SirenContext *s)
 
static int decode_vector (SirenContext *s, int number_of_regions, float *decoder_standard_deviation, int *power_categories, float *coefs, int scale_factor)
 
static int siren_decode (AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
 
static av_cold void siren_flush (AVCodecContext *avctx)
 
static av_cold int siren_close (AVCodecContext *avctx)
 

Variables

static const uint8_t index_table [8] = {4, 4, 3, 3, 2, 2, 1, 0}
 
static const uint8_t vector_dimension [8] = { 2, 2, 2, 4, 4, 5, 5, 1 }
 
static const uint8_t number_of_vectors [8] = { 10, 10, 10, 5, 5, 4, 4, 20 }
 
static const uint8_t expected_bits_table [8] = { 52, 47, 43, 37, 29, 22, 16, 0 }
 
static const int8_t differential_decoder_tree [27][24][2]
 
static const uint16_t decoder_tree0 [360]
 
static const uint16_t decoder_tree1 [188]
 
static const uint16_t decoder_tree2 [96]
 
static const uint16_t decoder_tree3 [1040]
 
static const uint16_t decoder_tree4 [416]
 
static const uint16_t decoder_tree5 [384]
 
static const uint16_t decoder_tree6 [62]
 
static const uint16_t *const decoder_tables [7]
 
static const int decoder_tables_elements [7]
 
static const float mlt_quant [7][14]
 
static const float noise_category5 [21]
 
static const float noise_category6 [21]
 
const FFCodec ff_siren_decoder
 
const FFCodec ff_msnsiren_decoder
 

Macro Definition Documentation

◆ FRAME_SIZE

#define FRAME_SIZE   320

Definition at line 356 of file siren.c.

◆ REGION_SIZE

#define REGION_SIZE   20

Definition at line 357 of file siren.c.

Function Documentation

◆ siren_init()

static av_cold int siren_init ( AVCodecContext avctx)
static

Definition at line 390 of file siren.c.

◆ decode_envelope()

static int decode_envelope ( SirenContext s,
GetBitContext gb,
int  number_of_regions,
float decoder_standard_deviation,
int absolute_region_power_index,
int  esf_adjustment 
)
static

Definition at line 438 of file siren.c.

Referenced by siren_decode().

◆ categorize_regions()

static int categorize_regions ( int  number_of_regions,
int  number_of_available_bits,
int absolute_region_power_index,
int power_categories,
int category_balance 
)
static

Definition at line 462 of file siren.c.

Referenced by siren_decode().

◆ get_dw()

static int get_dw ( SirenContext s)
static

Definition at line 557 of file siren.c.

Referenced by decode_vector().

◆ decode_vector()

static int decode_vector ( SirenContext s,
int  number_of_regions,
float decoder_standard_deviation,
int power_categories,
float coefs,
int  scale_factor 
)
static

Definition at line 572 of file siren.c.

Referenced by siren_decode().

◆ siren_decode()

static int siren_decode ( AVCodecContext avctx,
AVFrame frame,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 705 of file siren.c.

◆ siren_flush()

static av_cold void siren_flush ( AVCodecContext avctx)
static

Definition at line 824 of file siren.c.

◆ siren_close()

static av_cold int siren_close ( AVCodecContext avctx)
static

Definition at line 833 of file siren.c.

Variable Documentation

◆ index_table

const uint8_t index_table[8] = {4, 4, 3, 3, 2, 2, 1, 0}
static

◆ vector_dimension

const uint8_t vector_dimension[8] = { 2, 2, 2, 4, 4, 5, 5, 1 }
static

Definition at line 35 of file siren.c.

Referenced by decode_vector().

◆ number_of_vectors

const uint8_t number_of_vectors[8] = { 10, 10, 10, 5, 5, 4, 4, 20 }
static

Definition at line 36 of file siren.c.

Referenced by decode_vector().

◆ expected_bits_table

const uint8_t expected_bits_table[8] = { 52, 47, 43, 37, 29, 22, 16, 0 }
static

Definition at line 37 of file siren.c.

Referenced by categorize_regions().

◆ differential_decoder_tree

const int8_t differential_decoder_tree[27][24][2]
static

Definition at line 38 of file siren.c.

Referenced by decode_envelope().

◆ decoder_tree0

const uint16_t decoder_tree0[360]
static
Initial value:
= {
2, 1, 4, 6, 8, 10, 12, 14, 16, 18, 33, 3, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 35, 40,
42, 44, 46, 5, 48, 65, 50, 52, 54, 56, 58, 60, 62, 64, 37, 66, 67, 68, 97, 70, 72, 74, 7,
76, 78, 80, 82, 84, 86, 88, 99, 90, 39, 92, 94, 96, 129, 98, 9, 100, 102, 104, 106, 108,
110, 112, 41, 161, 69, 114, 116, 118, 131, 120, 122, 11, 124, 126, 128, 193, 130, 132, 71,
134, 43, 136, 138, 140, 163, 101, 13, 142, 144, 146, 148, 150, 152, 154, 225, 156, 158, 195,
160, 162, 45, 164, 15, 166, 73, 168, 170, 133, 47, 172, 257, 174, 176, 178, 75, 103, 180, 165,
182, 17, 227, 184, 105, 49, 135, 186, 289, 188, 259, 190, 192, 194, 196, 198, 291, 77, 200,
202, 197, 107, 204, 19, 51, 229, 206, 167, 208, 210, 212, 214, 21, 79, 81, 109, 216, 218, 220,
222, 53, 137, 224, 199, 226, 323, 321, 169, 228, 111, 230, 232, 139, 261, 234, 83, 236, 201,
238, 240, 293, 242, 353, 231, 141, 244, 246, 113, 23, 355, 85, 248, 55, 115, 250, 263, 252,
254, 203, 171, 256, 258, 233, 235, 143, 357, 325, 260, 295, 262, 173, 145, 177, 87, 264, 327,
267, 266, 268, 175, 270, 272, 117, 297, 274, 265, 147, 179, 205, 276, 207, 237, 269, 278, 57,
59, 387, 209, 280, 282, 149, 329, 385, 284, 25, 286, 239, 119, 288, 27, 290, 292, 299, 294, 359,
89, 296, 298, 419, 181, 300, 331, 271, 417, 211, 361, 151, 389, 241, 302, 304, 303, 306, 308,
421, 91, 310, 312, 391, 314, 121, 316, 333, 318, 275, 213, 301, 243, 183, 335, 320, 363, 322,
215, 324, 393, 273, 337, 153, 326, 423, 365, 328, 367, 247, 395, 185, 123, 330, 425, 245, 155,
332, 334, 305, 397, 336, 277, 217, 338, 340, 339, 427, 342, 344, 346, 307, 399, 187, 348, 309,
341, 350, 369, 279, 311, 429, 249, 219, 352, 354, 356, 358, 431, 373, 401, 371, 313, 281, 433,
343, 403, 251, 283
}

Definition at line 176 of file siren.c.

◆ decoder_tree1

const uint16_t decoder_tree1[188]
static
Initial value:
= {
2, 1, 4, 6, 8, 10, 12, 14, 16, 3, 33, 18, 20, 22, 24, 26, 35, 28, 30, 32, 34, 36, 5, 65, 38, 40,
37, 42, 44, 46, 67, 48, 50, 52, 54, 56, 58, 60, 7, 62, 39, 97, 64, 69, 66, 99, 68, 70, 72, 74, 76,
78, 80, 129, 41, 131, 82, 9, 71, 84, 86, 101, 88, 90, 92, 94, 96, 161, 43, 11, 73, 98, 103, 100,
163, 102, 104, 106, 108, 133, 110, 105, 112, 75, 114, 45, 13, 116, 165, 118, 195, 135, 193, 120, 77,
122, 47, 124, 167, 225, 126, 79, 107, 227, 128, 137, 197, 15, 130, 169, 199, 132, 109, 134, 17, 139,
49, 136, 229, 138, 140, 81, 259, 142, 144, 171, 146, 141, 148, 111, 150, 201, 231, 152, 51, 257, 289,
154, 19, 113, 156, 261, 158, 203, 173, 263, 143, 160, 291, 235, 83, 162, 233, 265, 164, 205, 166, 293,
145, 168, 175, 177, 237, 115, 295, 170, 207, 172, 267, 174, 176, 297, 147, 178, 180, 269, 182, 271,
209, 299, 239, 179, 184, 301, 241, 211, 0, 0
}

Definition at line 198 of file siren.c.

◆ decoder_tree2

const uint16_t decoder_tree2[96]
static
Initial value:
= {
2, 1, 4, 6, 8, 10, 12, 3, 17, 14, 19, 16, 18, 20, 22, 24, 26, 5, 21, 35, 33, 28, 30, 32, 34, 36, 38, 37,
40, 23, 51, 42, 7, 49, 44, 46, 48, 50, 39, 53, 52, 54, 56, 25, 67, 9, 58, 60, 65, 55, 41, 62, 64, 69, 66,
11, 27, 68, 57, 83, 70, 71, 81, 43, 72, 74, 13, 76, 85, 29, 73, 78, 99, 59, 87, 101, 80, 97, 45, 82, 84,
75, 89, 61, 86, 103, 88, 77, 90, 105, 91, 92, 107, 93, 0, 0
}

Definition at line 210 of file siren.c.

◆ decoder_tree3

const uint16_t decoder_tree3[1040]
static

Definition at line 217 of file siren.c.

◆ decoder_tree4

const uint16_t decoder_tree4[416]
static
Initial value:
= {
2, 4, 6, 1, 8, 10, 12, 14, 16, 18, 20, 22, 24, 3, 129, 26, 28, 9, 33, 30, 32,
34, 36, 11, 161, 38, 40, 42, 41, 44, 46, 131, 43, 169, 35, 48, 137, 50, 52, 54, 56, 139,
163, 171, 58, 60, 62, 64, 5, 66, 68, 70, 257, 72, 74, 76, 13, 78, 80, 289, 82, 84, 17,
86, 88, 65, 90, 201, 19, 92, 94, 51, 193, 96, 98, 49, 100, 73, 102, 104, 106, 45, 108, 110,
297, 112, 114, 116, 37, 203, 118, 120, 179, 122, 177, 124, 265, 126, 75, 133, 259, 291, 147, 128, 67,
195, 130, 141, 173, 299, 132, 145, 134, 165, 136, 138, 140, 142, 7, 144, 146, 21, 267, 148, 53, 150,
321, 152, 154, 15, 156, 81, 158, 160, 385, 162, 417, 164, 166, 168, 83, 170, 172, 329, 174, 211, 176,
27, 178, 180, 182, 209, 184, 186, 188, 190, 25, 192, 331, 194, 196, 105, 57, 198, 97, 200, 202, 323,
225, 59, 149, 204, 206, 233, 307, 208, 77, 181, 210, 212, 214, 216, 218, 220, 222, 47, 224, 226, 69,
228, 230, 197, 232, 425, 393, 205, 275, 293, 39, 234, 236, 238, 305, 135, 155, 301, 143, 240, 242, 235,
395, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 273, 269, 185, 264, 266, 268, 270, 272, 274, 276,
261, 153, 278, 280, 282, 187, 337, 387, 107, 284, 427, 227, 167, 419, 286, 288, 290, 292, 294, 296, 298,
300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 115,
99, 85, 213, 29, 113, 23, 89, 241, 61, 449, 339, 175, 340, 342, 344, 346, 348, 350, 352, 354, 356,
358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398,
400, 402, 404, 406, 408, 410, 412, 414, 389, 361, 457, 465, 429, 451, 333, 109, 277, 243, 263, 295, 199,
283, 151, 55, 183, 229, 357, 363, 123, 491, 397, 411, 251, 313, 441, 467, 345, 433, 461, 219, 237, 365,
435, 353, 347, 405, 409, 217, 309, 437, 369, 371, 341, 117, 245, 249, 157, 285, 403, 189, 317, 93, 221,
315, 401, 481, 391, 489, 121, 421, 423, 71, 483, 327, 103, 231, 443, 459, 271, 399, 355, 91, 303, 431,
79, 207, 335, 111, 239, 281, 325, 279, 453, 101, 311, 87, 215, 31, 159, 63, 191
}

Definition at line 266 of file siren.c.

◆ decoder_tree5

const uint16_t decoder_tree5[384]
static
Initial value:
= {
2, 4, 1, 6, 8, 10, 12, 14, 16, 18, 20, 22, 3, 513, 24, 26, 28, 9, 129, 33, 30, 32, 34, 36, 38, 40, 11, 42, 641, 44, 46, 41,
161, 48, 515, 50, 52, 131, 54, 35, 545, 137, 56, 58, 60, 521, 62, 43, 673, 64, 169, 66, 68, 523, 70, 163, 643, 139, 553, 72, 649, 74, 547,
76, 78, 80, 681, 171, 82, 84, 555, 86, 675, 88, 651, 5, 90, 92, 1025, 94, 96, 98, 683, 13,
100, 17, 102, 104, 106, 65, 108, 110, 257, 112, 114, 1153, 19, 116, 118, 120, 122, 124, 49, 126, 128,
769, 289, 130, 132, 134, 73, 136, 138, 140, 142, 193, 144, 146, 148, 150, 152, 154, 517, 156, 158, 37,
51, 160, 201, 162, 145, 164, 166, 168, 133, 170, 801, 45, 172, 174, 1057, 176, 178, 67, 180, 1027, 577,
182, 184, 186, 188, 190, 192, 194, 196, 198, 259, 200, 202, 204, 525, 177, 265, 141, 206, 208, 210, 212,
195, 297, 214, 75, 216, 1033, 203, 585, 1155, 1185, 267, 1161, 549, 218, 220, 657, 777, 147, 222, 224, 226,
228, 230, 232, 234, 236, 238, 240, 587, 645, 165, 242, 244, 246, 248, 250, 771, 291, 252, 579, 1065, 1035,
705, 531, 529, 659, 173, 254, 561, 653, 256, 713, 677, 557, 258, 260, 262, 264, 266, 268, 270, 272, 274,
276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 707, 1059, 809, 715, 563, 179, 691, 1193,
21, 779, 1067, 299, 1187, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332,
334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374,
376, 378, 380, 83, 69, 1281, 803, 321, 1195, 1163, 811, 1323, 689, 1321, 1099, 305, 835, 1227, 331, 843, 785,
593, 1043, 1291, 1283, 1171, 275, 787, 1217, 833, 1075, 1313, 1219, 1203, 307, 819, 841, 595, 211, 723, 721, 817,
1029, 329, 81, 1157, 261, 773, 1097, 1089, 1061, 1169, 1091, 1189, 293, 805, 1201, 581, 197, 709, 1289, 273, 1037,
1315, 1041, 1165, 269, 781, 209, 1073, 1069, 323, 685, 1197, 301, 813, 77, 589, 205, 717, 1225, 533, 149, 661,
53, 565, 181, 693, 0, 0
}

Definition at line 289 of file siren.c.

◆ decoder_tree6

const uint16_t decoder_tree6[62]
static
Initial value:
= {
2, 1, 4, 6, 8, 10, 12, 14, 16, 3, 33, 5, 17, 9, 18, 20, 22, 24, 26, 28, 30, 32, 34, 7, 49, 13, 25, 36, 38, 11,
21, 41, 35, 37, 19, 40, 42, 44, 46, 48, 50, 15, 52, 57, 29, 27, 23, 53, 54, 51, 39, 45, 43, 56, 58, 31, 55, 60,
61, 47, 59, 63
}

Definition at line 310 of file siren.c.

◆ decoder_tables

const uint16_t* const decoder_tables[7]
static
Initial value:

Definition at line 316 of file siren.c.

Referenced by decode_vector().

◆ decoder_tables_elements

const int decoder_tables_elements[7]
static

◆ mlt_quant

const float mlt_quant[7][14]
static
Initial value:
= {
{ 0.0f, 0.392f, 0.761f, 1.120f, 1.477f, 1.832f, 2.183f, 2.541f, 2.893f, 3.245f, 3.598f, 3.942f, 4.288f, 4.724f },
{ 0.0f, 0.544f, 1.060f, 1.563f, 2.068f, 2.571f, 3.072f, 3.562f, 4.070f, 4.620f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.746f, 1.464f, 2.180f, 2.882f, 3.584f, 4.316f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.006f, 2.000f, 2.993f, 3.985f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.321f, 2.703f, 3.983f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.657f, 3.491f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.964f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }
}

Definition at line 336 of file siren.c.

Referenced by decode_vector().

◆ noise_category5

const float noise_category5[21]
static
Initial value:
= {
0.70711f, 0.6179f, 0.5005f, 0.3220f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f,
0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f
}

Definition at line 346 of file siren.c.

Referenced by decode_vector().

◆ noise_category6

const float noise_category6[21]
static
Initial value:
= {
0.70711f, 0.5686f, 0.3563f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f,
0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f
}

Definition at line 351 of file siren.c.

Referenced by decode_vector().

◆ ff_siren_decoder

const FFCodec ff_siren_decoder
Initial value:
= {
.p.name = "siren",
CODEC_LONG_NAME("Siren"),
.priv_data_size = sizeof(SirenContext),
.p.type = AVMEDIA_TYPE_AUDIO,
.init = siren_init,
.close = siren_close,
.flush = siren_flush,
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 843 of file siren.c.

◆ ff_msnsiren_decoder

const FFCodec ff_msnsiren_decoder
Initial value:
= {
.p.name = "msnsiren",
CODEC_LONG_NAME("MSN Siren"),
.priv_data_size = sizeof(SirenContext),
.p.type = AVMEDIA_TYPE_AUDIO,
.init = siren_init,
.close = siren_close,
.flush = siren_flush,
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 858 of file siren.c.

FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
AV_CODEC_ID_SIREN
@ AV_CODEC_ID_SIREN
Definition: codec_id.h:532
decoder_tree3
static const uint16_t decoder_tree3[1040]
Definition: siren.c:217
siren_init
static av_cold int siren_init(AVCodecContext *avctx)
Definition: siren.c:390
siren_flush
static av_cold void siren_flush(AVCodecContext *avctx)
Definition: siren.c:824
decoder_tree5
static const uint16_t decoder_tree5[384]
Definition: siren.c:289
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
decoder_tree0
static const uint16_t decoder_tree0[360]
Definition: siren.c:176
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
decoder_tree1
static const uint16_t decoder_tree1[188]
Definition: siren.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
siren_decode
static int siren_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: siren.c:705
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
SirenContext
Definition: siren.c:359
AV_CODEC_ID_MSNSIREN
@ AV_CODEC_ID_MSNSIREN
Definition: codec_id.h:535
decoder_tree2
static const uint16_t decoder_tree2[96]
Definition: siren.c:210
siren_close
static av_cold int siren_close(AVCodecContext *avctx)
Definition: siren.c:833
decoder_tree4
static const uint16_t decoder_tree4[416]
Definition: siren.c:266
decoder_tree6
static const uint16_t decoder_tree6[62]
Definition: siren.c:310