~ft/mcfs

7996b424b3ec858adcf6507c424bc5e06773e3fa — Sigrid Solveig Haflínudóttir 2 years ago 721b071
ivf/h264: repeat sps/pps on every key frame
1 files changed, 14 insertions(+), 8 deletions(-)

M ivf.c
M ivf.c => ivf.c +14 -8
@@ 38,11 38,11 @@ ivfframe(Biobuf *out, u8int *p, int sz, uvlong ts, int avcsplit)
		}
	}

	return Bwrite(out, p, sz) != sz ? -1 : 0;
	return sz > 0 ? (Bwrite(out, p, sz) != sz ? -1 : 0) : 0;
}

int
ivfpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts)
ivfpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts, int key)
{
	u8int d[0x20], *x, *y, *e;
	int i, n, len;


@@ 127,9 127,10 @@ ivfpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts)
						werrstr("sps out of range");
						goto err;
					}
					memmove(x+4, y, len);
					if(ivfframe(out, x, 4+len, 0, 0) != 0)
						goto err;
					ctx->ps[ctx->nps].p = malloc(4+len);
					memmove(ctx->ps[ctx->nps].p, x, 4);
					memmove(ctx->ps[ctx->nps].p+4, y, len);
					ctx->ps[ctx->nps++].n = 4+len;
					ctx->frid++;
					y += len;
				}


@@ 142,15 143,20 @@ ivfpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts)
						werrstr("pps out of range");
						goto err;
					}
					memmove(x+4, y, len);
					if(ivfframe(out, x, 4+len, 0, 0) != 0)
						goto err;
					ctx->ps[ctx->nps].p = malloc(4+len);
					memmove(ctx->ps[ctx->nps].p, x, 4);
					memmove(ctx->ps[ctx->nps].p+4, y, len);
					ctx->ps[ctx->nps++].n = 4+len;
					ctx->frid++;
					y += len;
				}
			}
		}

		if(key && ctx->fmt == FmtAvc1){
			for(i = 0; i < ctx->nps; i++)
				ivfframe(out, ctx->ps[i].p, ctx->ps[i].n, 0, 0);
		}
		if(ivfframe(out, p->data, p->sz, ts, ctx->fmt == FmtAvc1) != 0)
			goto err;
		ctx->frid++;