diff options
author | Alfred E. Heggestad <alfred.heggestad@gmail.com> | 2017-07-29 15:13:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-29 15:13:00 +0200 |
commit | 6c56980cbeecaaeac0367ad9aa48eaa84fd8314b (patch) | |
tree | 062e0fa2e0ecf1a3072386972a87886fa38fe3ec /modules/h265 | |
parent | 5d297b1594765b681466b13257af0a59bf765ff8 (diff) |
Video timestamp (#286)
* add timestamp to video encoder/decoder
* update vp8 vp9
* random offset
* revert decoder timestamp
* cleanup
* gst_video1: add timestamp
* change timestamp to RTP-timestamp
* update modules
* timestamp things
* save rtp timestamp
* packet_handler: align params same as RTP header
* align parameters same way like RTP-header
* avcodec: calc ts for old FFmpeg versions
* cleanup
* fix gst
avcodec: use correct AVPacket
* minor cleanup
Diffstat (limited to 'modules/h265')
-rw-r--r-- | modules/h265/encode.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/h265/encode.c b/modules/h265/encode.c index 239abe6..f4835a3 100644 --- a/modules/h265/encode.c +++ b/modules/h265/encode.c @@ -140,12 +140,13 @@ static int open_encoder(struct videnc_state *st, const struct vidsz *size) static inline int packetize(bool marker, const uint8_t *buf, size_t len, - size_t maxlen, videnc_packet_h *pkth, void *arg) + size_t maxlen, uint32_t rtp_ts, + videnc_packet_h *pkth, void *arg) { int err = 0; if (len <= maxlen) { - err = pkth(marker, NULL, 0, buf, len, arg); + err = pkth(marker, rtp_ts, NULL, 0, buf, len, arg); } else { struct h265_nal nal; @@ -168,7 +169,8 @@ static inline int packetize(bool marker, const uint8_t *buf, size_t len, len-=2; while (len > flen) { - err |= pkth(false, fu_hdr, 3, buf, flen, arg); + err |= pkth(false, rtp_ts, fu_hdr, 3, buf, flen, + arg); buf += flen; len -= flen; @@ -177,7 +179,8 @@ static inline int packetize(bool marker, const uint8_t *buf, size_t len, fu_hdr[2] |= 1<<6; /* set END bit */ - err |= pkth(marker, fu_hdr, 3, buf, len, arg); + err |= pkth(marker, rtp_ts, fu_hdr, 3, buf, len, + arg); } return err; @@ -192,6 +195,7 @@ int h265_encode(struct videnc_state *st, bool update, uint32_t i, nalc = 0; int colorspace; int n, err = 0; + uint32_t ts; if (!st || !frame) return EINVAL; @@ -253,6 +257,8 @@ int h265_encode(struct videnc_state *st, bool update, if (n <= 0) goto out; + ts = video_calc_rtp_timestamp(pic_out.pts, st->fps); + for (i=0; i<nalc; i++) { x265_nal *nal = &nalv[i]; @@ -273,7 +279,7 @@ int h265_encode(struct videnc_state *st, bool update, marker = (i+1)==nalc; /* last NAL */ err = packetize(marker, p, len, st->pktsize, - st->pkth, st->arg); + ts, st->pkth, st->arg); if (err) goto out; } |