From patchwork Sun Aug 14 15:02:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jens Ziller X-Patchwork-Id: 164 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1118935vsd; Sun, 14 Aug 2016 08:04:24 -0700 (PDT) X-Received: by 10.194.148.19 with SMTP id to19mr30044051wjb.81.1471187064678; Sun, 14 Aug 2016 08:04: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 f3si15596358wje.178.2016.08.14.08.04.19; Sun, 14 Aug 2016 08:04: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; 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 6AD67689A8D; Sun, 14 Aug 2016 18:04:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2354068980D for ; Sun, 14 Aug 2016 18:03:48 +0300 (EEST) Received: from Schleppi.lan ([79.241.200.101]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0Ln8gj-1aynur3MxJ-00hMEu for ; Sun, 14 Aug 2016 17:03:48 +0200 Message-ID: <1471186923.1575.7.camel@gmx.de> From: Jens Ziller To: FFmpeg development discussions and patches Date: Sun, 14 Aug 2016 17:02:03 +0200 In-Reply-To: <1471086961.1498.8.camel@gmx.de> References: <20160716124150.GK22139@nb4> <1468682828.1612.28.camel@gmx.de> <1469890252.1521.28.camel@gmx.de> <0e513af2-48bf-a61e-0b07-c7c15f6d1955@jkqxz.net> <1469976696.1531.37.camel@gmx.de> <1469984966.1531.70.camel@gmx.de> <20160812151225.GP5460@nb4> <1471086961.1498.8.camel@gmx.de> X-Mailer: Evolution 3.18.5.1 Mime-Version: 1.0 X-Provags-ID: V03:K0:DWt3WS0Sy0brHEHgAPqDV+vn9NI0xKML+D4OaWqfptnug+j7vzR Lo9o2WWDzStSQsHsAPCRe9oYUx5hcI0JYg/qHwK2fp+cYqGa0CScNTNKOE40lCaVgC6M/4U 7LECyZewA+shDzOSVbEZVQn8nZaHwXyGx0A7lNxQCz4m4T3M6a3bAhIBWQENkAfS2Wc5Ycc EVltd7xD0F2J5UuZT/fKg== X-UI-Out-Filterresults: notjunk:1; V01:K0:HGVbjvflL8A=:vHPTGNvYdWQknDoY/nMWxZ RyZBhtbKFPDgVFjkhaFUZjlBtCGsxrTmmd+r+9Wa7YRQIxMSyRJ5l9E4YtMEz16tyFsWt3f2g lgYAv4DYcSxnxEb6hzuz9O0ubX6B5D3nz5eDXfe7di/qmTgm2pLpu2Pn1mI/NsW4ZBrJXlyiE 296LR8esaaikDWZY3vkXffgWtdiSABGNrFqmEVfU9vcy9LIlpATz584HhwgKGUSB5r6OzaJ6a Mr+taXOoZoSa8K84CbHCnV9FZYz74fXSsjaRRGLA1CYHj6GEVLnharwiZTyGC1uMGduG5K/Mm iBgEH3qGdT6rgJ/AHtS5CnRNL7Ces6RYjleiPJwuu2A256hOl1dnnQptc+C6rCNRzYpo1CFZJ vg+YLctGBy2Y0t7eEgx9D1jsb80IjubBpsxYNcsI99IGLY678baJ/+zSXKRBS9MirjCzAhQ51 AyaeE2si9qz3PETRPQ1MB1Ucw1eiiZvIoaRifKqytrzC4+L14HKPsFQPypBm/Yv4tBEM7F8Pm IUDYZlLgaCcG0y3+Rt/zBbkW+z+KawKDAnRJeDbpmMx0D7OJQJwWE4jFdUQTInf8a6Ftp+Y+q 5m9jZ7QZFgyBi6Vgha2/z+SAhI/dZNYzn0YgA5mFETRMDPcRAskG7Wo406cnkcRJ1mML1cf7n 6Nyg/1EKniTgbTC79seeV3fCPbvvYgyDnGhv4FI03lByu6iCrhkQcOnzxHyZRdmqnbNuXLsli H8PFGdeoPKnITkihUjd4EYJVI/7gVtmsuQXeNV5KdorvGFTULCrt951s0go= Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/mmaldec.c: add interlaced_frame and format struct to AVFrame for deinterlacing] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Am Samstag, den 13.08.2016, 13:16 +0200 schrieb Jens Ziller: > Am Freitag, den 12.08.2016, 17:12 +0200 schrieb Michael Niedermayer: > > > > On Sun, Jul 31, 2016 at 07:09:26PM +0200, Jens Ziller wrote: > > > > > > > > > Am Sonntag, den 31.07.2016, 16:33 +0100 schrieb Mark Thompson: > > > > > > > > > > > > On 31/07/16 15:51, Jens Ziller wrote: > > > > > > > > > > > > > > > > > > > > Am Samstag, den 30.07.2016, 17:30 +0100 schrieb Mark > > > > > Thompson: > > [...] > > > > > > > > > > > > > > > > > > Consider this sequence, where we want to decode a single image > > > > and > > > > then do something with it: > > > > > > > > open decoder > > > > decode frame > > > > close decoder > > > > open > > > > give it the frame we got from the decoder > > > > > > > > To me that looks like it will invoke undefined behaviour > > > > (segfault or > > > > read garbage) when trying to access data[2] in the second > > > > component, > > > > because the pointer appears to be to the MMAL_ES_FORMAT_T in > > > > the > > > > MMAL_PORT_T on the decoder which we just destroyed.  If not, > > > > where is > > > > the reference which keeps that pointer valid living? > > > With MMAL decoder it works: > > > > > > - configure decoder > > > - send many frames (in my tests between 5 and 20+) to decoder > > > - decoder give MMAL_ES_FORMAT_T > > > - configure decoder output port with given struct <- here we have > > > the > > > pointer > > > - decoder send the first decoded frame > > > > > > The struct lives before the first frame is available. Decode a > > > single > > > frame is a spezial thing. The MMAL decoder is not made for this. > > > > > > A > > > local copy from format struct make no sense for me. > > well, it makes sense to us for the code to work and not have > > undefined > > behavior. > > Please correct me if iam wrong but Hendrik, Mark and me are saying > > the same thing more or less, i think you should change the patch > > > > also additionally, its nice if we can keep data[0..2] available for > > the raw 3 YUV planes, it might one day somewhere be nice to > > download > > the raw data into [0..2], using up the 2nd for this struct is not > > pretty > For YUV planes AV_PIX_FMT_YUV420P are the better choice > not AV_PIX_FMT_MMAL.  > But you have me convinced that I write a new patch, test it and send > it > to the ml. > Here are the new version. No data[2] pointer more. For this AVFrame top_field_first and AVCodecContext->framerate is used. regards jens From 66f0e12eb3e7d83113b76d8e0a71d0da328de195 Mon Sep 17 00:00:00 2001 From: Jens Ziller Date: Sun, 14 Aug 2016 16:44:39 +0200 Subject: [PATCH] v5 fill AVFrame->interlaced_frame and top_field_first with MMAL_PARAMETER_VIDEO_INTERLACE_TYPE_T and AVCodecContext->framerate from MMAL_ES_FORMAT_T for deinterlacer and renderer --- libavcodec/mmaldec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index 099a8c5..56ad948 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -88,6 +88,8 @@ typedef struct MMALDecodeContext { int eos_received; int eos_sent; int extradata_sent; + int interlaced_frame; + int top_field_first; } MMALDecodeContext; // Assume decoder is guaranteed to produce output after at least this many @@ -274,6 +276,7 @@ static int ffmal_update_format(AVCodecContext *avctx) int ret = 0; MMAL_COMPONENT_T *decoder = ctx->decoder; MMAL_ES_FORMAT_T *format_out = decoder->output[0]->format; + MMAL_PARAMETER_VIDEO_INTERLACE_TYPE_T interlace_type; ffmmal_poolref_unref(ctx->pool_out); if (!(ctx->pool_out = av_mallocz(sizeof(*ctx->pool_out)))) { @@ -300,6 +303,16 @@ static int ffmal_update_format(AVCodecContext *avctx) if ((status = mmal_port_format_commit(decoder->output[0]))) goto fail; + interlace_type.hdr.id = MMAL_PARAMETER_VIDEO_INTERLACE_TYPE; + interlace_type.hdr.size = sizeof(MMAL_PARAMETER_VIDEO_INTERLACE_TYPE_T); + status = mmal_port_parameter_get(decoder->output[0], &interlace_type.hdr); + if (status != MMAL_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "Cannot read MMAL interlace information!\n"); + } else { + ctx->interlaced_frame = (interlace_type.eMode != MMAL_InterlaceProgressive); + ctx->top_field_first = (interlace_type.eMode == MMAL_InterlaceFieldsInterleavedUpperFirst); + } + if ((ret = ff_set_dimensions(avctx, format_out->es->video.crop.x + format_out->es->video.crop.width, format_out->es->video.crop.y + format_out->es->video.crop.height)) < 0) goto fail; @@ -308,6 +321,10 @@ static int ffmal_update_format(AVCodecContext *avctx) avctx->sample_aspect_ratio.num = format_out->es->video.par.num; avctx->sample_aspect_ratio.den = format_out->es->video.par.den; } + if (format_out->es->video.frame_rate.num && format_out->es->video.frame_rate.den) { + avctx->framerate.num = format_out->es->video.frame_rate.num; + avctx->framerate.den = format_out->es->video.frame_rate.den; + } avctx->colorspace = ffmmal_csp_to_av_csp(format_out->es->video.color_space); @@ -609,6 +626,9 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame, MMALDecodeContext *ctx = avctx->priv_data; int ret = 0; + frame->interlaced_frame = ctx->interlaced_frame; + frame->top_field_first = ctx->top_field_first; + if (avctx->pix_fmt == AV_PIX_FMT_MMAL) { if (!ctx->pool_out) return AVERROR_UNKNOWN; // format change code failed with OOM previously -- 2.7.3