aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2011-03-25 22:46:22 -0700
committerPhilip Langdale <philipl@overt.org>2011-04-08 20:17:47 -0700
commitf6421e0b5c028b5eaf24377b074b1e50b2c32419 (patch)
tree5e76e16f5c42db6f539c0396bbcf17c0dd21ec69
parente99fd6ee197f77e512c4092667eed70232f9c875 (diff)
downloadffmpeg-f6421e0b5c028b5eaf24377b074b1e50b2c32419.tar.gz
CrystalHD: Bring in h.264 parser to establish picture type.
As the hardware is unreliable, we will have to use the h.264 parser to identify whether an input picture is a field or a frame. This change loads the parser and extracts the picture type. Signed-off-by: Philip Langdale <philipl@overt.org>
-rwxr-xr-xconfigure2
-rw-r--r--libavcodec/crystalhd.c29
2 files changed, 30 insertions, 1 deletions
diff --git a/configure b/configure
index 3fceb31b2a..e2f805eab8 100755
--- a/configure
+++ b/configure
@@ -1279,7 +1279,7 @@ h263_vaapi_hwaccel_select="vaapi h263_decoder"
h263i_decoder_select="h263_decoder"
h263p_encoder_select="h263_encoder"
h264_decoder_select="golomb h264dsp h264pred"
-h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf"
+h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
h264_dxva2_hwaccel_deps="dxva2api_h"
h264_dxva2_hwaccel_select="dxva2 h264_decoder"
h264_vaapi_hwaccel_select="vaapi"
diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index f971056ffe..db6a8f997a 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -84,6 +84,7 @@
#include <libcrystalhd/libcrystalhd_if.h>
#include "avcodec.h"
+#include "h264.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
@@ -120,6 +121,8 @@ typedef struct {
AVFrame pic;
HANDLE dev;
+ AVCodecParserContext *parser;
+
uint8_t is_70012;
uint8_t *sps_pps_buf;
uint32_t sps_pps_size;
@@ -316,6 +319,8 @@ static av_cold int uninit(AVCodecContext *avctx)
DtsCloseDecoder(device);
DtsDeviceClose(device);
+ av_parser_close(priv->parser);
+
av_free(priv->sps_pps_buf);
if (priv->pic.data[0])
@@ -478,6 +483,13 @@ static av_cold int init(AVCodecContext *avctx)
goto fail;
}
+ if (avctx->codec->id == CODEC_ID_H264) {
+ priv->parser = av_parser_init(avctx->codec->id);
+ if (!priv->parser)
+ av_log(avctx, AV_LOG_WARNING,
+ "Cannot open the h.264 parser! Interlaced h.264 content "
+ "will not be detected reliably.\n");
+ }
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Init complete.\n");
return 0;
@@ -737,11 +749,28 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a
CHDContext *priv = avctx->priv_data;
HANDLE dev = priv->dev;
int len = avpkt->size;
+ uint8_t pic_type = 0;
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n");
if (len) {
int32_t tx_free = (int32_t)DtsTxFreeSize(dev);
+
+ if (priv->parser) {
+ uint8_t *pout;
+ int psize = len;
+ H264Context *h = priv->parser->priv_data;
+
+ while (psize)
+ ret = av_parser_parse2(priv->parser, avctx, &pout, &psize,
+ avpkt->data, len, avctx->pkt->pts,
+ avctx->pkt->dts, len - psize);
+ 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) {
/*
* Despite being notionally opaque, either libcrystalhd or