~ft/mcfs

523b8ff86604d789c92481c9588d72c91d7ef9bb — Sigrid Solveig Haflínudóttir 3 years ago c5d4cd0
matroska: write flac as is; prepend codec private data when writing as-is data
2 files changed, 10 insertions(+), 2 deletions(-)

M common.h
M matroska.c
M common.h => common.h +2 -1
@@ 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))

M matroska.c => matroska.c +8 -1
@@ 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;