From patchwork Wed Oct 26 19:40:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 1191 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp220259vsd; Wed, 26 Oct 2016 12:52:32 -0700 (PDT) X-Received: by 10.28.68.213 with SMTP id r204mr4155590wma.105.1477511552099; Wed, 26 Oct 2016 12:52:32 -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 x14si12444220wmf.41.2016.10.26.12.52.31; Wed, 26 Oct 2016 12:52:32 -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 6A839689E94; Wed, 26 Oct 2016 22:51:44 +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 3BFD7689E6B for ; Wed, 26 Oct 2016 22:51:42 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1477511505; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=ZDEOU22oy94hh2YhnNKoqPT6r2MciJ6Vbk4B7eb3ki8=; b=NOZKQthlkufjkD8oFxKTRSfAwIxrIJK2RSNr6T4SVgRf2g0y0AmJrmh+Q38srTP3qJ994laq sdo/SQbrylnM9kri9fs0flnx+u+ON0s9CvU3ikmtED92pBfVr8EDdBI1ING6bbo7ZSKIlo6k ZTb1jAQD7QepsRwptm9oljHCXvY= 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=Jk6n406PyYMBEocIpSvatZ+F4s9ND33eMYGw9eozNeIRjIirCngjabUiQkgyVYko/PdPS9 1gm17xUe2aFiex5AfjKBDcL1Ilh9VbgVNKC22glPxFk8nI86lWTdkGr6myMLGcmLgZwqKTzF CjRuciw0did+u8zvEyFNs/eZh7UPY= 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 581106b5.7f6d28646b90-in7; Wed, 26 Oct 2016 19:40:37 -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 6D53461643; Wed, 26 Oct 2016 19:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1477510837; bh=OLbom16GWBbWm5oLVplFIgkSKsBb3LwLyRo3X1o1iK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XoNu4ZeWayibBjSHbh4vDi3oM851p4QhRYVf4+yk9xN+AdIVQ8bMlDbcwbjtzEQTR 5eBQZX0Lh07aZhPI+PIUyGKXKb49Qf6u8R6sCUVvYza5jBS8xtxS4iK5EHZLOG/rCy puHIxvovI2ommE53D64G14imwD8bCq91jDMmwYya7rCnnno95qoSPws9U96Tz1+DJx 1fCIRbU66mnQr8k3skk5VzPbzMVFyeAE4rXUPIG24rHKaHFvl+Kwl0faD3qrh/uakH S3LK6/BSHlyDfFrx45U/4RyL4Yddr+s6VG/PvTdNW7kkuWx3buwAiBQm6qYPgoI2+g N0U+GBU0v4Wtg== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Oct 2016 12:40:27 -0700 Message-Id: <20161026194028.26438-10-philipl@overt.org> In-Reply-To: <20161026194028.26438-1-philipl@overt.org> References: <20161026194028.26438-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 09/10] crystalhd: Simplify output frame handling 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" The old code had to retain a partial frame across two calls in the case of separate interlaced fields. Now, we know that we'll get both fields within the same receive_frame call, and so we don't need to manage the frame as private state any more. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 2d803ab..7cf2c75 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -117,7 +117,6 @@ typedef struct OpaqueList { typedef struct { AVClass *av_class; AVCodecContext *avctx; - AVFrame *pic; HANDLE dev; uint8_t *orig_extradata; @@ -308,8 +307,6 @@ static void flush(AVCodecContext *avctx) priv->need_second_field = 0; priv->draining = 0; - av_frame_unref (priv->pic); - /* Flush mode 4 flushes all software and hardware buffers. */ DtsFlushInput(priv->dev, 4); } @@ -344,8 +341,6 @@ static av_cold int uninit(AVCodecContext *avctx) av_freep(&priv->sps_pps_buf); - av_frame_free (&priv->pic); - if (priv->head) { OpaqueList *node = priv->head; while (node) { @@ -440,7 +435,6 @@ static av_cold int init(AVCodecContext *avctx) priv = avctx->priv_data; priv->avctx = avctx; priv->is_nal = avctx->extradata_size > 0 && *(avctx->extradata) == 1; - priv->pic = av_frame_alloc(); priv->draining = 0; subtype = id2subtype(priv, avctx->codec->id); @@ -543,7 +537,7 @@ static av_cold int init(AVCodecContext *avctx) static inline CopyRet copy_frame(AVCodecContext *avctx, BC_DTS_PROC_OUT *output, - void *data, int *got_frame) + AVFrame *frame, int *got_frame) { BC_STATUS ret; BC_DTS_STATUS decoder_status = { 0, }; @@ -594,13 +588,10 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_VERBOSE, "Interlaced state: %d\n", interlaced); - if (priv->pic->data[0] && !priv->need_second_field) - av_frame_unref(priv->pic); - priv->need_second_field = interlaced && !priv->need_second_field; - if (!priv->pic->data[0]) { - if (ff_get_buffer(avctx, priv->pic, AV_GET_BUFFER_FLAG_REF) < 0) + if (!frame->data[0]) { + if (ff_get_buffer(avctx, frame, 0) < 0) return RET_ERROR; } @@ -618,8 +609,8 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, sStride = bwidth; } - dStride = priv->pic->linesize[0]; - dst = priv->pic->data[0]; + dStride = frame->linesize[0]; + dst = frame->data[0]; av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n"); @@ -653,27 +644,24 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, av_image_copy_plane(dst, dStride, src, sStride, bwidth, height); } - priv->pic->interlaced_frame = interlaced; + frame->interlaced_frame = interlaced; if (interlaced) - priv->pic->top_field_first = !bottom_first; + frame->top_field_first = !bottom_first; if (pkt_pts != AV_NOPTS_VALUE) { - priv->pic->pts = pkt_pts; + frame->pts = pkt_pts; #if FF_API_PKT_PTS FF_DISABLE_DEPRECATION_WARNINGS - priv->pic->pkt_pts = pkt_pts; + frame->pkt_pts = pkt_pts; FF_ENABLE_DEPRECATION_WARNINGS #endif } - av_frame_set_pkt_pos(priv->pic, -1); - av_frame_set_pkt_duration(priv->pic, 0); - av_frame_set_pkt_size(priv->pic, -1); + av_frame_set_pkt_pos(frame, -1); + av_frame_set_pkt_duration(frame, 0); + av_frame_set_pkt_size(frame, -1); if (!priv->need_second_field) { *got_frame = 1; - if ((ret = av_frame_ref(data, priv->pic)) < 0) { - return ret; - } } else { return RET_COPY_AGAIN; } @@ -683,7 +671,7 @@ FF_ENABLE_DEPRECATION_WARNINGS static inline CopyRet receive_frame(AVCodecContext *avctx, - void *data, int *got_frame) + AVFrame *frame, int *got_frame) { BC_STATUS ret; BC_DTS_PROC_OUT output = { @@ -767,7 +755,7 @@ static inline CopyRet receive_frame(AVCodecContext *avctx, print_frame_info(priv, &output); - copy_ret = copy_frame(avctx, &output, data, got_frame); + copy_ret = copy_frame(avctx, &output, frame, got_frame); } else { /* * An invalid frame has been consumed. @@ -945,7 +933,7 @@ static int crystalhd_receive_frame(AVCodecContext *avctx, AVFrame *frame) .send_packet = crystalhd_decode_packet, \ .receive_frame = crystalhd_receive_frame, \ .flush = flush, \ - .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \ + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \ .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, \ };