From patchwork Wed Oct 26 19:40:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 1187 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp219908vsd; Wed, 26 Oct 2016 12:51:24 -0700 (PDT) X-Received: by 10.194.77.237 with SMTP id v13mr3687868wjw.220.1477511484339; Wed, 26 Oct 2016 12:51:24 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ql1si4475990wjc.85.2016.10.26.12.51.23; Wed, 26 Oct 2016 12:51:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org; dkim=neutral (body hash did not verify) header.i=@overt.org; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B817689E47; Wed, 26 Oct 2016 22:51:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from rs224.mailgun.us (rs224.mailgun.us [209.61.151.224]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7CE99689E0D for ; Wed, 26 Oct 2016 22:51:11 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1477511473; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=IZRYTvi3oYQaamzH8d+7/h7fKrAkJ61sH1PZdMX5jn0=; b=jIkdO4iBV+szq+3fkHZCjpOhuu1r3tO2XLSIWTJhOiyQtCUHG4VPhE9486BDDrKdNZPaYSgS 7pVBHgZJ/07ifS4dUv2CYsr4QZxaMstzcrSKnA1ItqJiSUDxZB78sNmI3bO/sAxmXQk3lEO2 PKZ/xBdiBn4cpRJUoiDuHXG7P4o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=overt.org; s=k1; q=dns; h=Sender: From: To: Cc: Subject: Date: Message-Id: In-Reply-To: References; b=gD0DXFcrhbsutTnqSErlregbEL+4Tqdmf2DoGKBr4qKRF8ktpKMPA1gxe+3S8B0SoF1JcB ae1374C4IsNUeFSHX/64YYIG0ieQUNtHgfZiLC5JZGo7one4MXqRm8E670+UUk1Fi8ZgSiAi fU1D7dK/VFErzQ+PfOiGfnAMLZt8o= X-Mailgun-Sending-Ip: 209.61.151.224 X-Mailgun-Sid: WyIyM2Q3MCIsICJmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZyIsICI0YTg5NjEiXQ== Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com [107.178.208.155]) by mxa.mailgun.org with ESMTP id 581106b4.7f4aa0ce2068-in03; Wed, 26 Oct 2016 19:40:36 -0000 (UTC) Received: from authenticated-user (mail.overt.org [107.178.208.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 2924061645; Wed, 26 Oct 2016 19:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1477510836; bh=gmeJ5cXThbrRSWchU4QQiJK49DXXEHXvb1QThlWnYCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NHushcSFOinwSxkv+QndRu/4Cy4kPR5d9Y/Ehix2uyMd66MCBuCheniH1sTcDFttP xKkfhdOcDqWsfmew+xYZ4sLUhTXxm7eNcfzbghuvYCHlVHWMEk03sPsYtdey+Iq2io yfnZnDb8G6r6NVJq8cZQhZoH+AFhQKkWjRn8kdG/rIbaiWsr5HJQpDbDDICkT8V8Zr THr9hlEkZiEnt5Ar5syFYxtbi0ToSMFp8r3wBswim5jYuTkYwNUp67PaN8Xy/BOxE4 Q+ZA6R2g0+IcJb3PdLlkwRkaKlnPA0nSqqjOzgnmSSswksDb9Q6Yr3ypvTWhWo6fD1 /vzEq1nTELwWQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Oct 2016 12:40:24 -0700 Message-Id: <20161026194028.26438-7-philipl@overt.org> In-Reply-To: <20161026194028.26438-1-philipl@overt.org> References: <20161026194028.26438-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 06/10] crystalhd: Remove h.264 parser X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Philip Langdale MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Now that we don't need to do ridiculous things to work out if a frame is interlaced or not, we don't need an extra h.264 parser. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 55 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 3db0e17..b68701a 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -83,7 +83,6 @@ #include #include "avcodec.h" -#include "h264dec.h" #include "internal.h" #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" @@ -112,7 +111,6 @@ typedef struct OpaqueList { struct OpaqueList *next; uint64_t fake_timestamp; uint64_t reordered_opaque; - uint8_t pic_type; } OpaqueList; typedef struct { @@ -125,7 +123,6 @@ typedef struct { uint32_t orig_extradata_size; AVBSFContext *bsfc; - AVCodecParserContext *parser; uint8_t is_70012; uint8_t *sps_pps_buf; @@ -221,8 +218,7 @@ static inline void print_frame_info(CHDContext *priv, BC_DTS_PROC_OUT *output) * OpaqueList functions ****************************************************************************/ -static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque, - uint8_t pic_type) +static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque) { OpaqueList *newNode = av_mallocz(sizeof (OpaqueList)); if (!newNode) { @@ -239,7 +235,6 @@ static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque, } priv->tail = newNode; newNode->reordered_opaque = reordered_opaque; - newNode->pic_type = pic_type; return newNode->fake_timestamp; } @@ -340,7 +335,6 @@ static av_cold int uninit(AVCodecContext *avctx) priv->orig_extradata_size = 0; } - av_parser_close(priv->parser); if (priv->bsfc) { av_bsf_free(&priv->bsfc); } @@ -533,14 +527,6 @@ static av_cold int init(AVCodecContext *avctx) goto fail; } - if (avctx->codec->id == AV_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"); - priv->parser->flags = PARSER_FLAG_COMPLETE_FRAMES; - } av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Init complete.\n"); return 0; @@ -561,7 +547,6 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, CHDContext *priv = avctx->priv_data; int64_t pkt_pts = AV_NOPTS_VALUE; - uint8_t pic_type = 0; uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) == VDEC_FLAG_BOTTOMFIELD; @@ -579,23 +564,18 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp); if (node) { pkt_pts = node->reordered_opaque; - pic_type = node->pic_type; av_free(node); } else { /* * We will encounter a situation where a timestamp cannot be * popped if a second field is being returned. In this case, * each field has the same timestamp and the first one will - * cause it to be popped. To keep subsequent calculations - * simple, pic_type should be set a FIELD value - doesn't - * matter which, but I chose BOTTOM. + * cause it to be popped. We'll avoid overwriting the valid + * timestamp below. */ - pic_type = PICT_BOTTOM_FIELD; } av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n", output->PicInfo.timeStamp); - av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n", - pic_type); } ret = DtsGetDriverStatus(priv->dev, &decoder_status); @@ -806,7 +786,6 @@ static int crystalhd_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) BC_STATUS bc_ret; CHDContext *priv = avctx->priv_data; HANDLE dev = priv->dev; - uint8_t pic_type = 0; AVPacket filtered_packet = { 0 }; int ret = 0; @@ -859,32 +838,6 @@ static int crystalhd_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) av_packet_unref(&filter_packet); } - if (priv->parser) { - uint8_t *pout; - int psize; - int index; - H264Context *h = priv->parser->priv_data; - - index = av_parser_parse2(priv->parser, avctx, &pout, &psize, - avpkt->data, avpkt->size, avpkt->pts, - avpkt->dts, 0); - if (index < 0) { - av_log(avctx, AV_LOG_WARNING, - "CrystalHD: Failed to parse h.264 packet to " - "detect interlacing.\n"); - } else if (index != avpkt->size) { - 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->picture_structure); - pic_type = h->picture_structure; - } - } - if (avpkt->size < tx_free) { /* * Despite being notionally opaque, either libcrystalhd or @@ -896,7 +849,7 @@ static int crystalhd_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) * we know will not be mangled. */ int64_t safe_pts = avpkt->pts == AV_NOPTS_VALUE ? 0 : avpkt->pts; - uint64_t pts = opaque_list_push(priv, safe_pts, pic_type); + uint64_t pts = opaque_list_push(priv, safe_pts); if (!pts) { ret = AVERROR(ENOMEM); goto exit;