82 #define SPDIF_FLAG_BIGENDIAN 0x01
91 {
"spdif_flags",
"IEC 61937 encapsulation flags", offsetof(
IEC61937Context, spdif_flags),
AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM,
"spdif_flags" },
93 {
"dtshd_rate",
"mux complete DTS frames in HD mode at the specified IEC958 rate (in Hz, default 0=disabled)", offsetof(
IEC61937Context, dtshd_rate),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 768000,
AV_OPT_FLAG_ENCODING_PARAM },
94 {
"dtshd_fallback_time",
"min secs to strip HD for after an overflow (-1: till the end, default 60)", offsetof(
IEC61937Context, dtshd_fallback),
AV_OPT_TYPE_INT, {.i64 = 60}, -1, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM },
108 int bitstream_mode = pkt->
data[5] & 0x7;
118 static const uint8_t eac3_repeat[4] = {6, 3, 2, 1};
121 if ((pkt->
data[4] & 0xc0) != 0xc0)
122 repeat = eac3_repeat[(pkt->
data[4] & 0x30) >> 4];
156 case 512:
return 0x0;
157 case 1024:
return 0x1;
158 case 2048:
return 0x2;
159 case 4096:
return 0x3;
160 case 8192:
return 0x4;
161 case 16384:
return 0x5;
170 static const char dtshd_start_code[10] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe };
171 int pkt_size = pkt->
size;
185 period = ctx->
dtshd_rate * (blocks << 5) / sample_rate;
190 "impossible repetition period of %d for the current DTS stream"
191 " (blocks = %d, sample rate = %d)\n", ctx->
dtshd_rate, period,
192 blocks << 5, sample_rate);
206 if (
sizeof(dtshd_start_code) + 2 + pkt_size
210 "temporarily sending core only\n");
219 pkt_size = core_size;
224 ctx->
out_bytes =
sizeof(dtshd_start_code) + 2 + pkt_size;
236 memcpy(ctx->
hd_buf, dtshd_start_code,
sizeof(dtshd_start_code));
238 memcpy(ctx->
hd_buf +
sizeof(dtshd_start_code) + 2, pkt->
data, pkt_size);
254 switch (syncword_dts) {
257 core_size = ((
AV_RB24(pkt->
data + 5) >> 4) & 0x3fff) + 1;
266 (((pkt->
data[5] & 0x07) << 4) | ((pkt->
data[6] & 0x3f) >> 2));
270 (((pkt->
data[4] & 0x07) << 4) | ((pkt->
data[7] & 0x3f) >> 2));
300 if (core_size && core_size < pkt->
size) {
330 int layer = 3 - ((pkt->
data[1] >> 1) & 3);
331 int extension = pkt->
data[2] & 1;
333 if (layer == 3 || version == 1) {
337 av_log(s,
AV_LOG_DEBUG,
"version: %i layer: %i extension: %i\n", version, layer, extension);
338 if (version == 2 && extension) {
376 "%"PRIu32
" samples in AAC frame not supported\n", hdr.
samples);
393 #define MAT_FRAME_SIZE 61424
394 #define TRUEHD_FRAME_OFFSET 2560
395 #define MAT_MIDDLE_CODE_OFFSET -4
400 int mat_code_length = 0;
401 static const char mat_end_code[16] = { 0xC3, 0xC2, 0xC0, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x97, 0x11 };
404 static const char mat_start_code[20] = { 0x07, 0x9E, 0x00, 0x03, 0x84, 0x01, 0x01, 0x01, 0x80, 0x00, 0x56, 0xA5, 0x3B, 0xF4, 0x81, 0x83, 0x49, 0x80, 0x77, 0xE0 };
406 memcpy(ctx->
hd_buf, mat_start_code,
sizeof(mat_start_code));
409 static const char mat_middle_code[12] = { 0xC3, 0xC1, 0x42, 0x49, 0x3B, 0xFA, 0x82, 0x83, 0x49, 0x80, 0x77, 0xE0 };
412 mat_middle_code,
sizeof(mat_middle_code));
432 memcpy(&ctx->
hd_buf[
MAT_FRAME_SIZE -
sizeof(mat_end_code)], mat_end_code,
sizeof(mat_end_code));
550 .extensions =
"spdif",
558 .priv_class = &spdif_class,