[FFmpeg-devel] [RFC/PATCH]lavf/spdifenc: Support muxing eac3 as specified by smpte

Carl Eugen Hoyos cehoyos at ag.or.at
Sat Jan 9 11:37:31 CET 2016


Hi!

A user has provided a "spdif" file that is incompatible with my hardware 
receiver but used together with SDI and MXF as specified by SMPTE (iiuc).
See "Ingest of SMPTE-377M" on the FFmpeg user mailing list.

Attached patch allows to write such files, I cannot test.

Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index b4608a1..faba9de 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -80,6 +80,7 @@ typedef struct IEC61937Context {
     int dtshd_rate;
     int dtshd_fallback;
 #define SPDIF_FLAG_BIGENDIAN    0x01
+#define SPDIF_FLAG_SMPTE        0x02
     int spdif_flags;
 
     /// function, which generates codec dependent header information.
@@ -90,6 +91,7 @@ typedef struct IEC61937Context {
 static const AVOption options[] = {
 { "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" },
 { "be", "output in big-endian format (for use as s16be)", 0, AV_OPT_TYPE_CONST, {.i64 = SPDIF_FLAG_BIGENDIAN},  0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" },
+{ "smpte", "use smpte specification instead of iec", 0, AV_OPT_TYPE_CONST, {.i64 = SPDIF_FLAG_SMPTE},  0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" },
 { "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 },
 { "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 },
 { NULL },
@@ -132,11 +134,17 @@ static int spdif_header_eac3(AVFormatContext *s, AVPacket *pkt)
         ctx->pkt_offset = 0;
         return 0;
     }
+    if (ctx->spdif_flags & SPDIF_FLAG_SMPTE) {
+        ctx->data_type   = 16;
+        ctx->length_code =
+        ctx->pkt_offset  = 6144;
+    } else {
     ctx->data_type   = IEC61937_EAC3;
     ctx->pkt_offset  = 24576;
+    ctx->length_code = ctx->hd_buf_filled;
+    }
     ctx->out_buf     = ctx->hd_buf;
     ctx->out_bytes   = ctx->hd_buf_filled;
-    ctx->length_code = ctx->hd_buf_filled;
 
     ctx->hd_buf_count  = 0;
     ctx->hd_buf_filled = 0;


More information about the ffmpeg-devel mailing list