From patchwork Thu Feb 27 16:13:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 17937 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 600AF449E99 for ; Thu, 27 Feb 2020 18:17:21 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3017368B738; Thu, 27 Feb 2020 18:17:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 21C9268B0F1 for ; Thu, 27 Feb 2020 18:17:13 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2020 08:17:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,492,1574150400"; d="scan'208";a="272276175" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by fmsmga002.fm.intel.com with ESMTP; 27 Feb 2020 08:17:10 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Feb 2020 00:13:28 +0800 Message-Id: <1582820008-22183-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH 1/3] lavc/avcodec.h: fix missing line breaks in API documentation 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" "In both cases.." and "Repeat this call until.." would be better to be in a separate line. http://ffmpeg.org/doxygen/trunk/group__lavc__encdec.html Signed-off-by: Linjie Fu --- libavcodec/avcodec.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 894a9e5..5a0fc34 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -92,6 +92,7 @@ * compressed data in an AVPacket. * - For encoding, call avcodec_send_frame() to give the encoder an AVFrame * containing uncompressed audio or video. + * * In both cases, it is recommended that AVPackets and AVFrames are * refcounted, or libavcodec might have to copy the input data. (libavformat * always returns refcounted AVPackets, and av_frame_get_buffer() allocates @@ -102,6 +103,7 @@ * an AVFrame containing uncompressed audio or video data. * - For encoding, call avcodec_receive_packet(). On success, it will return * an AVPacket with a compressed frame. + * * Repeat this call until it returns AVERROR(EAGAIN) or an error. The * AVERROR(EAGAIN) return value means that new input data is required to * return new output. In this case, continue with sending input. For each From patchwork Thu Feb 27 16:13:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 17938 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 76FA9449E99 for ; Thu, 27 Feb 2020 18:17:37 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5D66968B754; Thu, 27 Feb 2020 18:17:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E8A5068B738 for ; Thu, 27 Feb 2020 18:17:30 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2020 08:17:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,492,1574150400"; d="scan'208";a="242092257" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by orsmga006.jf.intel.com with ESMTP; 27 Feb 2020 08:17:27 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Feb 2020 00:13:45 +0800 Message-Id: <1582820025-22302-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH 2/3] lavc/avcodec.h: add an AVCodecContext flag to indicate caps of encoding 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Linjie Fu --- doc/APIchanges | 3 +++ fftools/cmdutils.c | 2 ++ libavcodec/avcodec.h | 9 ++++++++- libavcodec/rawenc.c | 1 + libavcodec/version.h | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5bfb0a6..ec4531f 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-xx-xx - xxxxxxxxxx - lavc 58.73.103 - avcodec.h + Add AV_CODEC_CAP_VARIABLE_DIMENSIONS. + 2020-02-21 - xxxxxxxxxx - lavc 58.73.101 - avcodec.h Add AV_CODEC_EXPORT_DATA_PRFT. diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index f0f2b4f..30bbbcc 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -1431,6 +1431,8 @@ static void print_codec(const AVCodec *c) printf("hardware "); if (c->capabilities & AV_CODEC_CAP_HYBRID) printf("hybrid "); + if (c->capabilities & AV_CODEC_CAP_VARIABLE_DIMENSIONS) + printf("multidimension "); if (!c->capabilities) printf("none"); printf("\n"); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 5a0fc34..87ca79f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -91,7 +91,9 @@ * - For decoding, call avcodec_send_packet() to give the decoder raw * compressed data in an AVPacket. * - For encoding, call avcodec_send_frame() to give the encoder an AVFrame - * containing uncompressed audio or video. + * containing uncompressed audio or video. Video encoder requires input + * frames to be in constant dimensions unless it declare the capability + * of AV_CODEC_CAP_VARIABLE_DIMENSIONS. * * In both cases, it is recommended that AVPackets and AVFrames are * refcounted, or libavcodec might have to copy the input data. (libavformat @@ -1116,6 +1118,11 @@ typedef struct RcOverride{ * Export encoder Producer Reference Time through packet side data */ #define AV_CODEC_EXPORT_DATA_PRFT (1 << 1) +/** + * Codec supports variable dimensions encoding. This indicates that input frames are + * allowed to be in variable dimensions/resolutions, otherwise they have to keep constant. + */ +#define AV_CODEC_CAP_VARIABLE_DIMENSIONS (1 << 21) /** * Pan Scan area. diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c index d181b74..486c0d7 100644 --- a/libavcodec/rawenc.c +++ b/libavcodec/rawenc.c @@ -92,4 +92,5 @@ AVCodec ff_rawvideo_encoder = { .id = AV_CODEC_ID_RAWVIDEO, .init = raw_encode_init, .encode2 = raw_encode, + .capabilities = AV_CODEC_CAP_VARIABLE_DIMENSIONS, }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 36536c3..03d7f32 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MINOR 73 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MICRO 103 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From patchwork Thu Feb 27 16:14:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 17939 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 70A04449E99 for ; Thu, 27 Feb 2020 18:17:57 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4E88768B756; Thu, 27 Feb 2020 18:17:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B694368B754 for ; Thu, 27 Feb 2020 18:17:50 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2020 08:17:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,492,1574150400"; d="scan'208";a="242092412" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by orsmga006.jf.intel.com with ESMTP; 27 Feb 2020 08:17:47 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Feb 2020 00:14:03 +0800 Message-Id: <1582820043-22426-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: check caps of encoders for encoding frame with variable dimension 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This ensures that an encoder is able to cope with input frames with changing resolution only if it declares the capability of AV_CODEC_CAP_VARIABLE_DIMENSIONS. Signed-off-by: Linjie Fu --- fftools/ffmpeg.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index e5fbd47..5c4cf03 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1068,6 +1068,15 @@ static void do_video_out(OutputFile *of, InputStream *ist = NULL; AVFilterContext *filter = ost->filter->filter; + if (next_picture && (enc->width != next_picture->width || + enc->height != next_picture->height)) { + if (!(enc->codec->capabilities & AV_CODEC_CAP_VARIABLE_DIMENSIONS)) { + av_log(NULL, AV_LOG_ERROR, "Variable dimension encoding " + "is not supported by %s.\n", enc->codec->name); + goto error; + } + } + if (ost->source_index >= 0) ist = input_streams[ost->source_index];