81 #define SPDIF_FLAG_BIGENDIAN 0x01
90 {
"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" },
92 {
"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 },
93 {
"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 },
107 int bitstream_mode = pkt->
data[5] & 0x7;
117 static const uint8_t eac3_repeat[4] = {6, 3, 2, 1};
120 if ((pkt->
data[4] & 0xc0) != 0xc0)
121 repeat = eac3_repeat[(pkt->
data[4] & 0x30) >> 4];
155 case 512:
return 0x0;
156 case 1024:
return 0x1;
157 case 2048:
return 0x2;
158 case 4096:
return 0x3;
159 case 8192:
return 0x4;
160 case 16384:
return 0x5;
169 static const char dtshd_start_code[10] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe };
170 int pkt_size = pkt->
size;
184 period = ctx->
dtshd_rate * (blocks << 5) / sample_rate;
189 "impossible repetition period of %d for the current DTS stream"
190 " (blocks = %d, sample rate = %d)\n", ctx->
dtshd_rate, period,
191 blocks << 5, sample_rate);
205 if (
sizeof(dtshd_start_code) + 2 + pkt_size
209 "temporarily sending core only\n");
218 pkt_size = core_size;
223 ctx->
out_bytes =
sizeof(dtshd_start_code) + 2 + pkt_size;
235 memcpy(ctx->
hd_buf, dtshd_start_code,
sizeof(dtshd_start_code));
237 memcpy(ctx->
hd_buf +
sizeof(dtshd_start_code) + 2, pkt->
data, pkt_size);
253 switch (syncword_dts) {
256 core_size = ((
AV_RB24(pkt->
data + 5) >> 4) & 0x3fff) + 1;
265 (((pkt->
data[5] & 0x07) << 4) | ((pkt->
data[6] & 0x3f) >> 2));
269 (((pkt->
data[4] & 0x07) << 4) | ((pkt->
data[7] & 0x3f) >> 2));
299 if (core_size && core_size < pkt->
size) {
329 int layer = 3 - ((pkt->
data[1] >> 1) & 3);
330 int extension = pkt->
data[2] & 1;
332 if (layer == 3 || version == 1) {
336 av_log(s,
AV_LOG_DEBUG,
"version: %i layer: %i extension: %i\n", version, layer, extension);
337 if (version == 2 && extension) {
375 "%"PRIu32
" samples in AAC frame not supported\n", hdr.
samples);
392 #define MAT_FRAME_SIZE 61424
393 #define TRUEHD_FRAME_OFFSET 2560
394 #define MAT_MIDDLE_CODE_OFFSET -4
399 int mat_code_length = 0;
400 static const char mat_end_code[16] = { 0xC3, 0xC2, 0xC0, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x97, 0x11 };
403 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 };
405 memcpy(ctx->
hd_buf, mat_start_code,
sizeof(mat_start_code));
408 static const char mat_middle_code[12] = { 0xC3, 0xC1, 0x42, 0x49, 0x3B, 0xFA, 0x82, 0x83, 0x49, 0x80, 0x77, 0xE0 };
411 mat_middle_code,
sizeof(mat_middle_code));
431 memcpy(&ctx->
hd_buf[
MAT_FRAME_SIZE -
sizeof(mat_end_code)], mat_end_code,
sizeof(mat_end_code));
549 .extensions =
"spdif",
557 .priv_class = &spdif_class,