Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
transcode: fix H264 decoding
  • Loading branch information
perexg committed Oct 20, 2014
1 parent 0fa68f7 commit 4b63409
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/plumbing/transcoding.c
Expand Up @@ -368,6 +368,19 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
ocodec = as->aud_ocodec;

if (ictx->codec_id == AV_CODEC_ID_NONE) {

if (icodec->id == AV_CODEC_ID_AAC || icodec->id == AV_CODEC_ID_VORBIS) {
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;
}
}

ictx->codec_id = icodec->id;

if (avcodec_open2(ictx, icodec, NULL) < 0) {
Expand Down Expand Up @@ -922,6 +935,19 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
opts = NULL;

if (ictx->codec_id == AV_CODEC_ID_NONE) {

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;
}
}

ictx->codec_id = icodec->id;

if (avcodec_open2(ictx, icodec, NULL) < 0) {
Expand All @@ -932,6 +958,13 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
}

av_init_packet(&packet);

if (ictx->codec_id == AV_CODEC_ID_H264 && pkt->pkt_meta) {
uint8_t *buf = av_packet_new_side_data(&packet, AV_PKT_DATA_NEW_EXTRADATA,
pktbuf_len(pkt->pkt_meta));
memcpy(buf, pktbuf_ptr(pkt->pkt_meta), pktbuf_len(pkt->pkt_meta));
}

packet.data = pktbuf_ptr(pkt->pkt_payload);
packet.size = pktbuf_len(pkt->pkt_payload);
packet.pts = pkt->pkt_pts;
Expand Down

1 comment on commit 4b63409

@bagong
Copy link

@bagong bagong commented on 4b63409 Oct 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a build from current master aac works with all profiles/containers for me... That is on Ubuntu 14.04 using the libav_static-enabled option.

Please sign in to comment.