From patchwork Sat Jul 30 14:50:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jens Ziller X-Patchwork-Id: 36 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1877109vsd; Sat, 30 Jul 2016 07:53:07 -0700 (PDT) X-Received: by 10.28.15.194 with SMTP id 185mr39742104wmp.58.1469890387860; Sat, 30 Jul 2016 07:53:07 -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 on9si23683585wjc.179.2016.07.30.07.53.06; Sat, 30 Jul 2016 07:53:07 -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 A64F9689CF4; Sat, 30 Jul 2016 17:52:47 +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 1BF6A689CF4 for ; Sat, 30 Jul 2016 17:52:28 +0300 (EEST) Received: from Schleppi.lan ([84.183.225.215]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0Ltqmn-1bJmEE0G6n-011CXf; Sat, 30 Jul 2016 16:52:31 +0200 Message-ID: <1469890252.1521.28.camel@gmx.de> From: Jens Ziller To: FFmpeg development discussions and patches , rodger.combs@gmail.com, nfxjfg@googlemail.com, michael@niedermayer.cc Date: Sat, 30 Jul 2016 16:50:52 +0200 In-Reply-To: <1468682828.1612.28.camel@gmx.de> References: <20160716124150.GK22139@nb4> <1468682828.1612.28.camel@gmx.de> X-Mailer: Evolution 3.18.5.1 Mime-Version: 1.0 X-Provags-ID: V03:K0:1Yz6sCfTZgFSMqr6YpgtR3AELJmQVPwPHtLYOVY2kiTOcMgh5av ehqxjmy6XhKctASKG4fbi02GWpeX8URFgSNLMBpx7iRT4T0uFVCY/731/OEDRGUsXqZ49T0 5OB/5Q37WxU7zmwjpalaIrvhGZIexH+rKIOl2FCVLbwkzAphBLB5pXnKWECDg3Ru80ss8CO mSOTJpDUjufSVokBmVoqQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:gTsApOxiGTU=:1jlj1/AyU0ruVR4/e+jRCk 0fKbaYSF0oX3JVJyrJhqaZgPgTEYLrBhVuPNiQBWay5f99L1hZaQ2sUIv51TwIQR2GwJMHb0n ACPuJfY4ptTlIfD77J6c1rHgXHn21bwGpjmBo06AyAbtal0EvcmjOlPEIRJoM3v3HtRLOJ46W TEih4G3i0PIIm6Sp75bMmkX8DqoIJlxsehoJuhPIwamGuuUQYIy4pI1sDz/+0xD2XbdDA0JYT EFrDO2zIqm8XFR/YkjaBf5wsNauHEIYpdobzSc0K+oBGKoa4T/2mC/y+2xeNtKGfb2eXSQDnd Y1h2ISxVI8BYk+xmp/eJRyEEApd2sKqEt7Ce+peFwVS6JaBnu1nldF6FbluXgXPiduEsnUPR8 1H4OAWVih2h+iqROLsCBvd89hZEoP787IymhKQyi4hEYtAt5vZ+sPZGMUyANBL2YXnfdQH1jV 7nhbn51pSH4d+zRFMtqhHC+MJ6/gloylDBc91TotWN5egO1o/yl06uxFEf5L8DE0RRm1y6OLJ BO0rZmRoK0vJeFYebnFy/1PJp+yiJEO3V/DAk1lOMcPueldYNPEh+4vc7KFKyrlramB0z7omD idnsJlyfK+79XA6U9zhXynn0YWFLfM+0Py8rcPYFaHf0Y8YyNmAGdNIKCsUECfkLYHTh6Zz/S OD8ZL49tEa2gMQbQgEhQbZf9wGCyk6q18fxgHf10mc/jtf69pfYEnFJ6+AQN2zONDVS2qpw5n hIjtPd3QrJrkKmdJC6arzlwrNDkbZSO6fq8RPImVXJGD9guqHusfONLefpY= 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 16.07.2016, 17:27 +0200 schrieb Jens Ziller: > Hello Rodger and wm4, > > for interlaced frames I need AVFrame->interlaced_frame. For invoke > MMAL > components like deinterlacer and renderer added a pointer data[2] to > existing MMAL_ES_FORMAT_T. I don't have find a better solution to > give > a pointer to user app. I have added a patch as suggestion. Please > help  > me that I can release my code. > > regards Jens > > > -------- Weitergeleitete Nachricht -------- > Von: Michael Niedermayer > Reply-to: FFmpeg development discussions and patches devel@ffmpeg.org> > An: FFmpeg development discussions and patches rg > > > > > Betreff: Re: [FFmpeg-devel] [PATCH] libavcodec/mmaldec.c: add > interlaced_frame and format struct to AVFrame for deinterlacing > Datum: Sat, 16 Jul 2016 14:41:50 +0200 > > On Sat, Jul 16, 2016 at 11:08:12AM +0200, Jens Ziller wrote: > > > > > > Am Sonntag, den 03.07.2016, 19:36 +0200 schrieb Jens Ziller: > > > > > > > > > Am Sonntag, den 03.07.2016, 18:05 +0200 schrieb Moritz Barsnick: > > > > > > > > > > > > > > > > On Sun, Jul 03, 2016 at 17:20:41 +0200, Jens Ziller wrote: > > > > > > > > > > > > > > > > > > > > > > > > > Am Samstag, den 02.07.2016, 17:54 +0200 schrieb Moritz > > > > > Barsnick: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sun, Jun 26, 2016 at 17:12:14 +0200, Jens Ziller wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > +        ctx->interlaced_frame = !(interlace_type.eMode > > > > > > > == > > > > > > > MMAL_InterlaceProgressive); > > > > > > What's wrong with using the "!=" operator instead? > > > > > "!=" is a comparing. "= !()" assign with a negate. Here is "= > > > > > !()" > > > > > needed. > > > > I meant the comparison, not the assignment, so replacing: > > > >   ctx->interlaced_frame = !(interlace_type.eMode == > > > > MMAL_InterlaceProgressive) > > > > with > > > >   ctx->interlaced_frame = (interlace_type.eMode != > > > > MMAL_InterlaceProgressive) > > > > > > > > The former is rather ... convoluted. > > > > (Brackets optional, but probably better for readability.) > > > > > > > > Moritz > > > Oh, sorry! I'am so blind. Yes, that's not really smart. I changed > > > that. > > > The new patch is attached. > > > > > > Regards Jens > > > > > Hello Michael and list, > > > > this patch was discussed and improved on the ML. What can I still > > do > > that my app get interlaced_frame and a pointer to the existing > > > > MMAL_ES_FORMAT_T from ffmpeg? mmaldec.c have unfortunately no > > maintainer. > But it has authors, > you can ask rodger combs and wm4 > > If they do not reply then please explain why you need this structure > in data[2] > Also what is the lifetime of this structure and what is the liftime > of the AVFrame that contains it. Its neccessary that the struct stays > valid as long as the AVFrame could be > > [...] > Hello Michael, I have ask rodger combs and wm4 two weeks ago, but unfortunately no reply. Please integrate the attached patch. MMAL_ES_FORMAT_T is needed for invoke the MMAL deinterlacer and renderer in an application. This struct give the decoder before the first frame gives out. In mmaldec.c line 689 ask the flag MMAL_EVENT_FORMAT_CHANGED and if this flag is set MMAL_ES_FORMAT_T is filled. This struct was cleaned if the decoder was stopped in mmaldec.c line 150. There are no lifetime issue. regards jens From b724bbe3a13addb055da883cbe802eee74d7c65e Mon Sep 17 00:00:00 2001 From: Jens Ziller Date: Sun, 3 Jul 2016 19:25:23 +0200 Subject: [PATCH] v4 fill AVFrame->interlaced_frame with MMAL_PARAMETER_VIDEO_INTERLACE_TYPE_T, add a pointer data[2] to MMAL_ES_FORMAT_T that user application can invoke MMAL components like deinterlacer and renderer with it --- libavcodec/mmaldec.c | 17 +++++++++++++++++ libavutil/pixfmt.h | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index 099a8c5..2e7b43c 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -88,6 +88,7 @@ typedef struct MMALDecodeContext { int eos_received; int eos_sent; int extradata_sent; + int interlaced_frame; } MMALDecodeContext; // Assume decoder is guaranteed to produce output after at least this many @@ -274,6 +275,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 +302,15 @@ 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); + } + 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; @@ -609,7 +620,13 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame, MMALDecodeContext *ctx = avctx->priv_data; int ret = 0; + frame->interlaced_frame = ctx->interlaced_frame; + if (avctx->pix_fmt == AV_PIX_FMT_MMAL) { + + // in data[2] give the format struct for configure deinterlacer and renderer + frame->data[2] = ctx->decoder->output[0]->format; + if (!ctx->pool_out) return AVERROR_UNKNOWN; // format change code failed with OOM previously diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 0ed01c4..98982f8 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -235,7 +235,8 @@ enum AVPixelFormat { AV_PIX_FMT_QSV, /** * HW acceleration though MMAL, data[3] contains a pointer to the - * MMAL_BUFFER_HEADER_T structure. + * MMAL_BUFFER_HEADER_T structure and data[2] contains a pointer to the + * MMAL_ES_FORMAT_T structure. */ AV_PIX_FMT_MMAL, -- 2.7.3