From 523b8ff86604d789c92481c9588d72c91d7ef9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Tue, 23 Feb 2021 19:50:23 +0000 Subject: [PATCH] matroska: write flac as is; prepend codec private data when writing as-is data --- common.h | 3 ++- matroska.c | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common.h b/common.h index 58f7724..1ae23ab 100644 --- a/common.h +++ b/common.h @@ -14,7 +14,8 @@ enum { FmtVorbis = 0x766f7262u, FmtSrt = 0x00737274u, /* srt subtitles */ FmtMp3 = 0x006d7033u, - FmtTheora = 0x74687261, + FmtTheora = 0x74687261u, + FmtFlac = 0x666c6163u, }; #define min(a,b) ((a)<=(b)?(a):(b)) diff --git a/matroska.c b/matroska.c index 339e2b6..7480374 100644 --- a/matroska.c +++ b/matroska.c @@ -102,12 +102,16 @@ format(Ebml *e) } static int -asispacket(Biobuf *out, Packetctx *, Packet *p, int np, uvlong, int) +asispacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong, int) { int i; + if(ctx->frid == 0) + Bwrite(out, ctx->codec.priv.data, ctx->codec.priv.sz); + for(i = 0; i < np; i++, p++) Bwrite(out, p->data, p->sz); + ctx->frid++; return 0; } @@ -147,6 +151,9 @@ initctx(Ebml *e, double duration) }else if(strcmp(c, "aac") == 0){ e->fmt = FmtMp4a; e->fpacket = aacpacket; + }else if(strcmp(c, "flac") == 0){ + e->fmt = FmtFlac; + e->fpacket = asispacket; }else goto err; return 0; -- 2.38.5