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>
This commit is contained in:
parent
e99fd6ee19
commit
f6421e0b5c
2
configure
vendored
2
configure
vendored
@ -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"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user