diff options
author | Philip Langdale <philipl@overt.org> | 2011-06-12 20:22:20 -0700 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2011-06-13 22:25:13 -0700 |
commit | 4ac5dffc5a4daf315fb908ec689366e179a59ad3 (patch) | |
tree | 35260eed14fe382d580d125940673c9b72eb2810 /libavcodec/crystalhd.c | |
parent | 7d2714d1abb432575e667870e0248e2ee77ed9a4 (diff) | |
download | ffmpeg-4ac5dffc5a4daf315fb908ec689366e179a59ad3.tar.gz |
CrystalHD: Use mp4toannexb bitstream filter.
The H.264 parser that we use to detect interlacing can only handle
an Annex B stream, so we need to actually use the filter. This is
unfortunate as the crystalhd library is already doing this conversion
internally. A future change will reorganise the decode path more
completely so that we can feed the converted stream into libcrystalhd
and avoid the second conversion.
Signed-off-by: Philip Langdale <philipl@overt.org>
Diffstat (limited to 'libavcodec/crystalhd.c')
-rw-r--r-- | libavcodec/crystalhd.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 851abd7ddd..ce1cd55228 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -514,6 +514,7 @@ static av_cold int init(AVCodecContext *avctx) av_log(avctx, AV_LOG_WARNING, "Cannot open the h.264 parser! Interlaced h.264 content " "will not be detected reliably.\n"); + priv->parser->flags = PARSER_FLAG_COMPLETE_FRAMES; } av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Init complete.\n"); @@ -833,24 +834,49 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a int32_t tx_free = (int32_t)DtsTxFreeSize(dev); if (priv->parser) { - uint8_t *pout; - int psize; - const uint8_t *in_data = avpkt->data; + uint8_t *in_data = avpkt->data; int in_len = len; - H264Context *h = priv->parser->priv_data; + int ret = 0; - while (in_len) { + if (priv->bsfc) { + ret = av_bitstream_filter_filter(priv->bsfc, avctx, NULL, + &in_data, &in_len, + avpkt->data, len, 0); + } + + if (ret >= 0) { + uint8_t *pout; + int psize; int index; + H264Context *h = priv->parser->priv_data; + index = av_parser_parse2(priv->parser, avctx, &pout, &psize, in_data, in_len, avctx->pkt->pts, avctx->pkt->dts, 0); - in_data += index; - in_len -= index; + if (index < 0) { + av_log(avctx, AV_LOG_WARNING, + "CrystalHD: Failed to parse h.264 packet to " + "detect interlacing.\n"); + } else if (index != in_len) { + av_log(avctx, AV_LOG_WARNING, + "CrystalHD: Failed to parse h.264 packet " + "completely. Interlaced frames may be " + "incorrectly detected\n."); + } else { + av_log(avctx, AV_LOG_VERBOSE, + "CrystalHD: parser picture type %d\n", + h->s.picture_structure); + pic_type = h->s.picture_structure; + } + } else { + av_log(avctx, AV_LOG_WARNING, + "CrystalHD: mp4toannexb filter failed to filter " + "packet. Interlaced frames may be incorrectly " + "detected.\n"); + } + if (ret > 0) { + av_freep(&in_data); } - av_log(avctx, AV_LOG_VERBOSE, - "CrystalHD: parser picture type %d\n", - h->s.picture_structure); - pic_type = h->s.picture_structure; } if (len < tx_free - 1024) { |