]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
transcode: set metadata (extradata) for H264
authorJaroslav Kysela <perex@perex.cz>
Tue, 24 Nov 2015 10:45:53 +0000 (11:45 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 24 Nov 2015 10:45:53 +0000 (11:45 +0100)
src/plumbing/transcoding.c

index 1956e55aefb6491008a69326518bc0b846119f5a..c5aad65c1cf2316736dd2aae3c6e3e16337a0082 100644 (file)
@@ -1178,6 +1178,18 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
   got_ref = 0;
 
   if (!avcodec_is_open(ictx)) {
+    if (icodec->id == AV_CODEC_ID_H264) {
+      if (pkt->pkt_meta) {
+        ictx->extradata_size = pktbuf_len(pkt->pkt_meta);
+        ictx->extradata = av_malloc(ictx->extradata_size);
+        memcpy(ictx->extradata,
+               pktbuf_ptr(pkt->pkt_meta), pktbuf_len(pkt->pkt_meta));
+      } else {
+        /* wait for metadata */
+        return;
+      }
+    }
+
     if (avcodec_open2(ictx, icodec, NULL) < 0) {
       tvherror("transcode", "%04X: Unable to open %s decoder", shortid(t), icodec->name);
       transcoder_stream_invalidate(ts);