79 #define SPDIF_FLAG_BIGENDIAN 0x01
88 {
"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" },
90 {
"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 },
91 {
"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 },
105 int bitstream_mode = pkt->
data[5] & 0x7;
115 static const uint8_t eac3_repeat[4] = {6, 3, 2, 1};
118 if ((pkt->
data[4] & 0xc0) != 0xc0)
119 repeat = eac3_repeat[(pkt->
data[4] & 0x30) >> 4];
153 case 512:
return 0x0;
154 case 1024:
return 0x1;
155 case 2048:
return 0x2;
156 case 4096:
return 0x3;
157 case 8192:
return 0x4;
158 case 16384:
return 0x5;
167 static const char dtshd_start_code[10] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe };
168 int pkt_size = pkt->
size;
182 period = ctx->
dtshd_rate * (blocks << 5) / sample_rate;
187 "impossible repetition period of %d for the current DTS stream"
188 " (blocks = %d, sample rate = %d)\n", ctx->
dtshd_rate, period,
189 blocks << 5, sample_rate);
203 if (
sizeof(dtshd_start_code) + 2 + pkt_size
207 "temporarily sending core only\n");
216 pkt_size = core_size;
221 ctx->
out_bytes =
sizeof(dtshd_start_code) + 2 + pkt_size;
233 memcpy(ctx->
hd_buf, dtshd_start_code,
sizeof(dtshd_start_code));
235 memcpy(ctx->
hd_buf +
sizeof(dtshd_start_code) + 2, pkt->
data, pkt_size);
251 switch (syncword_dts) {
254 core_size = ((
AV_RB24(pkt->
data + 5) >> 4) & 0x3fff) + 1;
263 (((pkt->
data[5] & 0x07) << 4) | ((pkt->
data[6] & 0x3f) >> 2));
267 (((pkt->
data[4] & 0x07) << 4) | ((pkt->
data[7] & 0x3f) >> 2));
297 if (core_size && core_size < pkt->
size) {
327 int layer = 3 - ((pkt->
data[1] >> 1) & 3);
328 int extension = pkt->
data[2] & 1;
330 if (layer == 3 || version == 1) {
334 av_log(s,
AV_LOG_DEBUG,
"version: %i layer: %i extension: %i\n", version, layer, extension);
335 if (version == 2 && extension) {
390 #define MAT_FRAME_SIZE 61424
391 #define TRUEHD_FRAME_OFFSET 2560
392 #define MAT_MIDDLE_CODE_OFFSET -4
397 int mat_code_length = 0;
398 const char mat_end_code[16] = { 0xC3, 0xC2, 0xC0, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x97, 0x11 };
401 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 };
403 memcpy(ctx->
hd_buf, mat_start_code,
sizeof(mat_start_code));
406 const char mat_middle_code[12] = { 0xC3, 0xC1, 0x42, 0x49, 0x3B, 0xFA, 0x82, 0x83, 0x49, 0x80, 0x77, 0xE0 };
409 mat_middle_code,
sizeof(mat_middle_code));
429 memcpy(&ctx->
hd_buf[
MAT_FRAME_SIZE -
sizeof(mat_end_code)], mat_end_code,
sizeof(mat_end_code));
547 .extensions =
"spdif",
555 .priv_class = &spdif_class,